DragonFly BSD
DragonFly kernel List (threaded) for 2005-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Register conventions in FreeBSD assembler


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 25 Aug 2005 08:42:00 -0700 (PDT)

: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@xxxxxxxxxxxxx>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]