News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Register Preservation Conventions

Started by cman, July 06, 2010, 09:26:39 PM

Previous topic - Next topic

cman

Is there any way to tell exactly which registers a specific API call will corrupt ( I know ebx , esi and edi are preserved between calls )?  It seems wastefull to have to push eax , ecx and edx before each call if not all these are used before a given call. Thanks...

oex

You could run debug however better practice would be to work on code layout/use variables I guess.... If in an inner loop you might want to know but otherwise is hardly an issue to use variable memory.... You cant test output registers because there are no guarentees a matching reg hasnt/wont changed
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Rockoon

and then they recompile the API on you for a patch, and it uses a different set of registers... or worse...

The idea of 'efficiency' doesnt jive with API calls anyways.. call overhead is way larger than a push.
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

jj2007

Quote from: cman on July 06, 2010, 09:26:39 PM
Is there any way to tell exactly which registers a specific API call will corrupt

No. Microsoft will guarantee that esi edi ebx ebp remain unchanged, and that eax ecx edx "might be" or "will probably be" changed. But it would be a dangerous strategy to check if a complex API call leaves ecx intact, because a) with a different set of parameters it could change and b) the next Windows version may trash it.

What annoys me more is that there is hardly any documentation on trashing of XMM registers.