You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/x64-calling-convention.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ Prologs and epilogs are highly restricted so that they can be properly described
34
34
35
35
## Parameter passing
36
36
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.
38
38
39
39
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.
40
40
@@ -60,29 +60,29 @@ The following table summarizes how parameters are passed, by type and position f
60
60
61
61
```cpp
62
62
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
64
64
```
65
65
66
66
### Example of argument passing 2 - all floats
67
67
68
68
```cpp
69
69
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
71
71
```
72
72
73
73
### Example of argument passing 3 - mixed ints and floats
74
74
75
75
```cpp
76
76
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
78
78
```
79
79
80
80
### Example of argument passing 4 - `__m64`, `__m128`, and aggregates
81
81
82
82
```cpp
83
83
func4(__m64 a, __m128 b, struct c, float d, __m128 e, __m128 f);
84
84
// 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
86
86
```
87
87
88
88
## Varargs
@@ -112,7 +112,7 @@ These examples show how parameters and return values are passed for functions wi
112
112
113
113
```cpp
114
114
__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,
116
116
// callee returns __int64 result in RAX.
117
117
```
118
118
@@ -132,7 +132,7 @@ struct Struct1 {
132
132
};
133
133
Struct1 func3(int a, double b, int c, float d);
134
134
// 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;
136
136
// callee returns pointer to Struct1 result in RAX.
0 commit comments