Skip to content

Commit 12d8713

Browse files
authored
Merge pull request #810 from corob-msft/cr-regflag-feedback
Update flags register usage requirement
2 parents 383af5e + f35a769 commit 12d8713

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed

docs/build/register-usage.md

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Register Usage | Microsoft Docs"
2+
title: "Register usage | Microsoft Docs"
33
ms.custom: ""
44
ms.date: "11/04/2016"
55
ms.technology: ["cpp-tools"]
@@ -10,34 +10,41 @@ author: "corob-msft"
1010
ms.author: "corob"
1111
ms.workload: ["cplusplus"]
1212
---
13-
# Register Usage
14-
The [!INCLUDE[vcprx64](../assembler/inline/includes/vcprx64_md.md)] 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.
15-
16-
The following table describes how each register is used across function calls:
17-
18-
||||
19-
|-|-|-|
20-
|Register|Status|Use|
21-
|RAX|Volatile|Return value register|
22-
|RCX|Volatile|First integer argument|
23-
|RDX|Volatile|Second integer argument|
24-
|R8|Volatile|Third integer argument|
25-
|R9|Volatile|Fourth integer argument|
26-
|R10:R11|Volatile|Must be preserved as needed by caller; used in syscall/sysret instructions|
27-
|R12:R15|Nonvolatile|Must be preserved by callee|
28-
|RDI|Nonvolatile|Must be preserved by callee|
29-
|RSI|Nonvolatile|Must be preserved by callee|
30-
|RBX|Nonvolatile|Must be preserved by callee|
31-
|RBP|Nonvolatile|May be used as a frame pointer; must be preserved by callee|
32-
|RSP|Nonvolatile|Stack pointer|
33-
|XMM0, YMM0|Volatile|First FP argument; first vector-type argument when `__vectorcall` is used|
34-
|XMM1, YMM1|Volatile|Second FP argument; second vector-type argument when `__vectorcall` is used|
35-
|XMM2, YMM2|Volatile|Third FP argument; third vector-type argument when `__vectorcall` is used|
36-
|XMM3, YMM3|Volatile|Fourth FP argument; fourth vector-type argument when `__vectorcall` is used|
37-
|XMM4, YMM4|Volatile|Must be preserved as needed by caller; fifth vector-type argument when `__vectorcall` is used|
38-
|XMM5, YMM5|Volatile|Must be preserved as needed by caller; sixth vector-type argument when `__vectorcall` is used|
39-
|XMM6:XMM15, YMM6:YMM15|Nonvolatile (XMM), Volatile (upper half of YMM)|Must be preserved by callee. YMM registers must be preserved as needed by caller.|
40-
41-
## See Also
42-
[x64 Software Conventions](../build/x64-software-conventions.md)
43-
[__vectorcall](../cpp/vectorcall.md)
13+
# Register usage
14+
15+
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.
16+
17+
## Register volatility and preservation
18+
19+
The following table describes how each register is used across function calls:
20+
21+
||||
22+
|-|-|-|
23+
|Register|Status|Use|
24+
|RAX|Volatile|Return value register|
25+
|RCX|Volatile|First integer argument|
26+
|RDX|Volatile|Second integer argument|
27+
|R8|Volatile|Third integer argument|
28+
|R9|Volatile|Fourth integer argument|
29+
|R10:R11|Volatile|Must be preserved as needed by caller; used in syscall/sysret instructions|
30+
|R12:R15|Nonvolatile|Must be preserved by callee|
31+
|RDI|Nonvolatile|Must be preserved by callee|
32+
|RSI|Nonvolatile|Must be preserved by callee|
33+
|RBX|Nonvolatile|Must be preserved by callee|
34+
|RBP|Nonvolatile|May be used as a frame pointer; must be preserved by callee|
35+
|RSP|Nonvolatile|Stack pointer|
36+
|XMM0, YMM0|Volatile|First FP argument; first vector-type argument when `__vectorcall` is used|
37+
|XMM1, YMM1|Volatile|Second FP argument; second vector-type argument when `__vectorcall` is used|
38+
|XMM2, YMM2|Volatile|Third FP argument; third vector-type argument when `__vectorcall` is used|
39+
|XMM3, YMM3|Volatile|Fourth FP argument; fourth vector-type argument when `__vectorcall` is used|
40+
|XMM4, YMM4|Volatile|Must be preserved as needed by caller; fifth vector-type argument when `__vectorcall` is used|
41+
|XMM5, YMM5|Volatile|Must be preserved as needed by caller; sixth vector-type argument when `__vectorcall` is used|
42+
|XMM6:XMM15, YMM6:YMM15|Nonvolatile (XMM), Volatile (upper half of YMM)|Must be preserved by callee. YMM registers must be preserved as needed by caller.|
43+
44+
On function exit and on function entry to C Runtime Library calls and Windows system calls, the direction flag in the CPU flags register is expected to be cleared.
45+
46+
## See also
47+
48+
- [x64 Software Conventions](../build/x64-software-conventions.md)
49+
- [__vectorcall](../cpp/vectorcall.md)
50+
- [Direction flag](../c-runtime-library/direction-flag.md)

0 commit comments

Comments
 (0)