Calling Conventions
x86-64x64 Calling Conventions
How arguments, return values and registers are passed across function calls in the System V (Linux/macOS) and Microsoft x64 ABIs.
Knowing the calling convention lets you recover function signatures from raw disassembly — which register holds argument 1, where the return value lands, and which registers a callee must preserve.
Integer/pointer argument registers
| Position | System V (Linux/macOS) | Microsoft x64 |
|---|---|---|
| 1 | rdi | rcx |
| 2 | rsi | rdx |
| 3 | rdx | r8 |
| 4 | rcx | r9 |
| 5 | r8 | stack |
| 6 | r9 | stack |
Return value is in rax (and rdx for 128-bit) in both ABIs.
Callee-saved registers
- System V:
rbx,rbp,r12–r15must be preserved. - Microsoft x64:
rbx,rbp,rdi,rsi,r12–r15, plus a 32-byte shadow space the caller reserves on the stack.
Why it matters
When a decompiler mislabels arguments, check which ABI the binary targets:
seeing rcx/rdx/r8/r9 set before a call strongly implies the Microsoft
convention (Windows), while rdi/rsi/rdx implies System V.