More on restoring registers in an assembly routine

More on restoring registers in an assembly routine

For an assembly routine that is to be called from a CVF Fortran routine, what what are the rules regarding restoring registers?

The documentation says that any register that is used must be restored to the value it had on entry to the routine. However, in two of the examples in the SAMPLESMIXLANGMASM folder, several registers are used but only the EBX register is saved and restored.

Are there any other registers which, if used, must be restored?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The usual calling conventions for Win32 state that EAX, ECX, and EDX may be destroyed by the callee. Also, EFLAGS may be modified by the callee, however the direction flag DF in EFLAGS must be preserved (or reset to "UP" before exit from the function). On function exit, EAX contains a function result of integral or pointer type, if any.

CVF follows the above rules, as does IFL, MSVC etc. Interestingly enough the Win32 conventions seem to match the System V ABI.

Thanks for the information!

Is "System V ABI" a Unix calling convention standard, or what?

The "System V ABI" is a fairly large document that devotes a rather small section to calling conventions used by Unix systems on various platforms. Specifically it covers these in the psABI (processor specific ABI) documents, wheras processor independent stuff is found in the GABI (general ABI) document. The current psABI for 32-bit x86 platforms can be found here, among other places:

stage.caldera.com/developer/devspecs/abi386-4.pdf

There are also downloadable psABI document on the web for PPC, MIPS, SPARC, and x86-64. I figure it might not be politically correct to list pointers to these in this Intel forum, but there is always Google :-)

Leave a Comment

Please sign in to add a comment. Not a member? Join today