Table 1: Use of CPU registers

This table gives an overview of how registers are used in Delphi 32-bit applications. The first column lists the different CPU registers. The second column shows what the register contains upon entry and the third indicates what the register holds upon exit. The fourth column tells you whether or not you are allowed to use the register inside your own code and the last column indicates if you need to preserve the content of the register (save it upon entry and restore it before leaving).

RegisterOn EntryOn ExitCan be Used?Preserve?
eaxSelf (1), First parameter (2) or undefined (3)Function result (4)YesNo
ebxUnknownn/aYesYes
ecxSecond parameter (1), Third parameter (2) or undefined (3)n/aYesNo
edxFirst parameter (1), Second parameter (2) or undefined (3)For Int64 result type: highest dword, otherwise n/aYesNo
esiUndefinedn/aYesYes
ediUndefinedn/a/YesYes
ebpStack frame pointerStack frame pointerYes (5)Yes
espStack pointerStack pointerYes (5)Yes
csCode selectorn/aNoYes
dsData selectorn/aNoYes
esData selectorn/aNoYes
fsSelector for thread information block (TIB)n/aNoYes
gsReservedn/aNoYes
ssStack segmentStack segmentNoYes

(1) Upon entry of methods when using the Register calling convention.
(2) Upon entry of stand-alone functions and procedures while using the Register calling convention.
(3) Upon entry for methods and stand-alone functions and procedures in all calling conventions except Register.
(4) Only for Result types that qualify to go into a register. See table 4 for a complete overview of how results are returned to the caller.
(5) While you are allowed to use these registers inside your code, such practise is strongly discouraged. The stack pointer itself changes with every stack operation and its content is therefore highly volatile, making it difficult to manage in code. The ebp register is used to access the stack frame and other uses are therefore to be avoided.


Source: www.guidogybels.net.