1
APPENDIX B
Calling Convention Summary
This appendix summarizes the conventions that must be observed in order to successfully
call an x86 assembly language function from a Visual C++ function. It includes synopses
of volatile and non-volatile registers, function arguments and return values, and control
flags. Chapters 2, 4, and 18 cover the calling conventions in greater detail. The Visual C++
documentation can also be consulted for further information.
Volatile and Non-Volatile Registers
Table B-1 lists the volatile and non-volatile registers for Visual C++ functions. A called
function must preserve the contents of any non-volatile register that it uses. Win32
functions can use the push and pop instructions to preserve the contents of a non-volatile
general-purpose register. Win64 functions must preserve non-volatile general-purpose
and XMM registers in accordance with the 64-bit prolog rules, which are discussed in
Chapter 18. Both Win32 and Win64 functions can use the volatile registers without any
restrictions.
Table B-1. Visual C++ Volatile and Non-Volatile Registers
C++ Win32 C++ Win64
Non-volatile, general-purpose
registers
EBP, EBX, ESI, EDI RBP, RBX, RSI, RDI, R12-R15
Volatile, general-purpose registers EAX, ECX, EDX RAX, RCX, RDX, R8-R11
Volatile x87 FPU registers ST(0)-ST(7) ST(0)-ST(7)
Volatile MMX registers MM0-MM7 MM0-MM7
Non-volatile XMM registers None XMM6-XMM15
Volatile XMM registers XMM0-XMM7 XMM0-XMM5
Volatile YMM registers (bits 255:128) YMM0-YMM7 YMM0-YMM15
评论0
最新资源