Passing Arguments (Recap)
System V AMD64 (Linux, macOS):
- First 6 integer/pointer args:
RDI, RSI, RDX, RCX, R8, R9. - Floating-point args:
XMM0—XMM7. - Additional args pushed on the stack, right to left.
- Return value in
RAX(andRDXfor 128-bit). - 128-byte red zone below
RSPusable by leaf functions.
Microsoft x64 (Windows):
- First 4 args:
RCX, RDX, R8, R9. - Caller allocates 32 bytes of shadow space for those 4 registers.
- Extra args on the stack; return value in
RAX.
Key Takeaway
Which ABI you are reading changes which registers hold the arguments — always confirm the platform first.