Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28632 Discussions

More on restoring registers in an assembly routine

hweisberg
Beginner
429 Views
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?



0 Kudos
3 Replies
njuffa
Beginner
429 Views
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.
0 Kudos
hweisberg
Beginner
428 Views
Thanks for the information!

Is "System V ABI" a Unix calling convention standard, or what?
0 Kudos
njuffa
Beginner
428 Views
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 :-)
0 Kudos
Reply