Quick poll: If you write a macro that uses two registers, then one is EAX, sure, but which one would you choose as No. 2 if you cannot afford a push/pop? ECX or EDX?
jj,
by spec, you can trash any of eax ecx edx are not required to be preserved. If it in the middle of a critical algo, I would see if you have another register which may be either of these or any of the others that is repeatedly overwritten with new data AFTER you have run the macro you may be able to use that instead. If you lay out the algo carefully you can often get a couple of extra registers this way.
Hutch, what you say is perfectly correct but that was not my question. Imagine you have a big fat project, and you need that macro pretty often. And you don't want to insert all the time a push/pop. In my fattest source, I use 142 times edx, and 444 times ecx, so edx would be a better choice because it's more rarely used.
Remember the abs macro thread (http://www.masm32.com/board/index.php?topic=9241.msg67112#msg67112). Surely there were macros that were just a little bit faster, but at the expense of having to sacrifice an extra register. No good for a general purpose macro, especially since many people have so much trust in Sir Hutch's macros that they would blindly write mov MyVar, abs(edx)...
I'd consider edx as a secondary data register -- in the same way that mul and div do
jj,
You could try a local or even a data? section variable so you can use MOV rather than PUSH/POP as it is almost exclusively faster.
.data?
_edx dd ?
.code
......
mov _edx, edx
; use EDX for something
mov edx, _edx