Register conventions in FreeBSD assembler

Matthew Dillon dillon at apollo.backplane.com
Thu Aug 25 08:44:49 PDT 2005


:Hi all,
:
:I'm doing some fun encryption stuff with assembler, and I was wondering if
:there are any register usage conventions I should be aware of.  Here's what I
:have so far.
:
:These are pretty obvious:
:
:1.  The return value of EAX is the C function return value.
:2.  ECX is often used as a counter.
:3.  ESI/EDI are used as source/destination for array/string operations.
:
:But I'm looking for less obvious stuff that might be important, like these
:I found:
:
:1.  EBX is expected to be unchanged over C function calls.
:2.  ESI/EDI are also expected to be unchanged over C calls.
:
:Are there any others I should be aware of?
:
:jm
:-- 

    call-used registers are EAX, ECX, and EDX.  All other registers
    must be left intact across a procedure call (i.e. the called procedure
    must save and restore them if it uses them).  That is, EBX, EBP, ESI,
    and EDI must be preserved.

    32 bit return values are placed in EAX.
    64 bit return values are placed in EDX and EAX.

    There might be a standard for the string direction bit as well, I'm
    not sure though.

    I'm not sure what the standard for floating point registers is.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list