4 ms·
i think they mean its more about remembering which variables are in which registers. i dont think macros can keep track of which registers are available for ne
by chillingeffect 8y ago
i think they mean its more about remembering which variables are in which registers. i dont think macros can keep track of which registers are available for new use.
- kazinator 8y agoMacros help remember which variables are in which registers by giving alias names to registers. I didn't think this requires explanation. If a register is used for more than one purpose and there are multiple macros aliasing for it which look like distinct variable, that could be a problem. If there are enough registers so that a function can avoid this, then it isn't a problem.
- chillingeffect 8y agoi'm curious if you've written optimized code for these platforms... it's not about remembering the registers within a routine. it's about maximizing register use across several routines. E.g. You call "circle" which uses registers d0-d3. Then it calls "line" which uses d4 and d5. Then you want to call "draw_point" which uses d3 and d7, but you realize you don't want to stomp on d3, so you write an alternate version of draw_point which uses d6 and d7 instead. The OP is that platforms with few registers, such as x86, rely on the stack and don't have this problem. Macros won't help either, bc it's not about naming, it's about resource allocation. A good C compiler could do it well, but OP was talking about programming in Assembly.