General
Calling conventions specify the low-level details for function calls. They are a part of an ABI.
Comparison
System V AMD64 | Microsoft x64 | |
---|---|---|
Arguments |
|
|
Return |
|
|
Caller-saved (volatile) | RAX, RCX, RDX, RSI, RDI, R8 – R11 | RAX, RCX, RDX, R8 – R11 |
Callee-saved (nonvolatile) | RBX, R12–R15, RBP, RSP | RBX, RSI, RDI, R12–R15, RBP, RSP |
System V AMD64
void func( int a, int b, int c, // a in RDI, b in RSI, c in RDX float d, float e, float f, // d in XMM0, e in XMM1, f in XMM2 int g, int h, int i, // g in RCX, h in R8, i in R9 float j, float k, float l, // j in XMM3, k in XMM4, l in XMM5 float m, float n); // m in XMM6, n in XMM7 // The next integer or float args would be added to the stack.
Microsoft x64
void func(int a, float b, int c, float d, int e); // a in RCX, b in XMM1, c in R8, d in XMM3 // The next integer or float args would be added to the stack.
Details
In C++ classes, the “this” pointer is the first argument.