Skip to content

Commit f37c90a

Browse files
CopilotTylerMSFT
andcommitted
Update x64 calling convention terminology for stack argument passing
Co-authored-by: TylerMSFT <[email protected]>
1 parent 0b92d03 commit f37c90a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/build/x64-calling-convention.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Prologs and epilogs are highly restricted so that they can be properly described
3434

3535
## Parameter passing
3636

37-
By default, the x64 calling convention passes the first four arguments to a function in registers. The registers used for these arguments depend on the position and type of the argument. Remaining arguments get pushed on the stack in right-to-left order. All arguments passed on the stack are 8-byte aligned.
37+
By default, the x64 calling convention passes the first four arguments to a function in registers. The registers used for these arguments depend on the position and type of the argument. Remaining arguments are passed on the stack in right-to-left order. The caller reserves the required stack space and writes these arguments to stack memory using store or move instructions, maintaining 8-byte alignment for each argument.
3838

3939
Integer valued arguments in the leftmost four positions are passed in left-to-right order in RCX, RDX, R8, and R9, respectively. The fifth and higher arguments are passed on the stack as previously described. All integer arguments in registers are right-justified, so the callee can ignore the upper bits of the register and access only the portion of the register necessary.
4040

@@ -60,29 +60,29 @@ The following table summarizes how parameters are passed, by type and position f
6060

6161
```cpp
6262
func1(int a, int b, int c, int d, int e, int f);
63-
// a in RCX, b in RDX, c in R8, d in R9, f then e pushed on stack
63+
// a in RCX, b in RDX, c in R8, d in R9, f then e passed on stack
6464
```
6565
6666
### Example of argument passing 2 - all floats
6767
6868
```cpp
6969
func2(float a, double b, float c, double d, float e, float f);
70-
// a in XMM0, b in XMM1, c in XMM2, d in XMM3, f then e pushed on stack
70+
// a in XMM0, b in XMM1, c in XMM2, d in XMM3, f then e passed on stack
7171
```
7272

7373
### Example of argument passing 3 - mixed ints and floats
7474

7575
```cpp
7676
func3(int a, double b, int c, float d, int e, float f);
77-
// a in RCX, b in XMM1, c in R8, d in XMM3, f then e pushed on stack
77+
// a in RCX, b in XMM1, c in R8, d in XMM3, f then e passed on stack
7878
```
7979
8080
### Example of argument passing 4 - `__m64`, `__m128`, and aggregates
8181
8282
```cpp
8383
func4(__m64 a, __m128 b, struct c, float d, __m128 e, __m128 f);
8484
// a in RCX, ptr to b in RDX, ptr to c in R8, d in XMM3,
85-
// ptr to f pushed on stack, then ptr to e pushed on stack
85+
// ptr to f passed on stack, then ptr to e passed on stack
8686
```
8787

8888
## Varargs
@@ -112,7 +112,7 @@ These examples show how parameters and return values are passed for functions wi
112112

113113
```cpp
114114
__int64 func1(int a, float b, int c, int d, int e);
115-
// Caller passes a in RCX, b in XMM1, c in R8, d in R9, e pushed on stack,
115+
// Caller passes a in RCX, b in XMM1, c in R8, d in R9, e passed on stack,
116116
// callee returns __int64 result in RAX.
117117
```
118118
@@ -132,7 +132,7 @@ struct Struct1 {
132132
};
133133
Struct1 func3(int a, double b, int c, float d);
134134
// Caller allocates memory for Struct1 returned and passes pointer in RCX,
135-
// a in RDX, b in XMM2, c in R9, d pushed on the stack;
135+
// a in RDX, b in XMM2, c in R9, d passed on the stack;
136136
// callee returns pointer to Struct1 result in RAX.
137137
```
138138

0 commit comments

Comments
 (0)