Register Usage
The x64 architecture provides for 16 general-purpose registers (hereafter referred to as integer registers) as well as 16 XMM registers available for floating-point use. Volatile registers are scratch registers presumed by the caller to be destroyed across a call. Nonvolatile registers are required to retain their values across a function call and must be saved by the callee if used.
The following table describes how each register is used across function calls:
Register |
Status |
Use |
RAX |
Volatile |
Return value register |
RCX |
Volatile |
First integer argument |
RDX |
Volatile |
Second integer argument |
R8 |
Volatile |
Third integer argument |
R9 |
Volatile |
Fourth integer argument |
R10:R11 |
Volatile |
Must be preserved as needed by caller; used in syscall/sysret instructions |
R12:R15 |
Nonvolatile |
Must be preserved by callee |
RDI |
Nonvolatile |
Must be preserved by callee |
RSI |
Nonvolatile |
Must be preserved by callee |
RBX |
Nonvolatile |
Must be preserved by callee |
RBP |
Nonvolatile |
May be used as a frame pointer; must be preserved by callee |
RSP |
Nonvolatile |
Stack pointer |
XMM0 |
Volatile |
First FP argument |
XMM1 |
Volatile |
Second FP argument |
XMM2 |
Volatile |
Third FP argument |
XMM3 |
Volatile |
Fourth FP argument |
XMM4:XMM5 |
Volatile |
Must be preserved as needed by caller |
XMM6:XMM15 |
Nonvolatile |
Must be preserved as needed by callee. |