Register Usage

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Register Usage.

The x64 architecture provides for 16 general-purpose registers (hereafter referred to as integer registers) as well as 16 XMM/YMM 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:

RegisterStatusUse
RAXVolatileReturn value register
RCXVolatileFirst integer argument
RDXVolatileSecond integer argument
R8VolatileThird integer argument
R9VolatileFourth integer argument
R10:R11VolatileMust be preserved as needed by caller; used in syscall/sysret instructions
R12:R15NonvolatileMust be preserved by callee
RDINonvolatileMust be preserved by callee
RSINonvolatileMust be preserved by callee
RBXNonvolatileMust be preserved by callee
RBPNonvolatileMay be used as a frame pointer; must be preserved by callee
RSPNonvolatileStack pointer
XMM0, YMM0VolatileFirst FP argument; first vector-type argument when __vectorcall is used
XMM1, YMM1VolatileSecond FP argument; second vector-type argument when __vectorcall is used
XMM2, YMM2VolatileThird FP argument; third vector-type argument when __vectorcall is used
XMM3, YMM3VolatileFourth FP argument; fourth vector-type argument when __vectorcall is used
XMM4, YMM4VolatileMust be preserved as needed by caller; fifth vector-type argument when __vectorcall is used
XMM5, YMM5VolatileMust be preserved as needed by caller; sixth vector-type argument when __vectorcall is used
XMM6:XMM15, YMM6:YMM15Nonvolatile (XMM), Volatile (upper half of YMM)Must be preserved as needed by callee. YMM registers must be preserved as needed by caller.

x64 Software Conventions
__vectorcall

Show: