LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What is the x86_64 calling convention for passing arguments and returning values?

The first 6 integer/pointer arguments go in %rdi, %rsi, %rdx, %rcx, %r8, %r9 (in that order); any extras go on the stack; the return value comes back in %rax.

A two-column grid of the six argument registers rdi, rsi, rdx, rcx, r8, r9 with rax as return value and a note that args 7+ go on the stack.

* First six int/pointer args in rdi, rsi, rdx, rcx, r8, r9; extras on the 16-byte-aligned stack; return in rax. *

x86_64 prefers registers over the stack for speed. There's a fixed sequence of registers for the first six integer-class arguments; argument seven onward spills onto the stack.

Argument Register
1st %rdi
2nd %rsi
3rd %rdx
4th %rcx
5th %r8
6th %r9
7th+ Stack
Return %rax

The stack frame is referenced through the stack pointer %rsp (no dedicated frame pointer is required), and the ABI mandates the stack be 16-byte aligned at each call.

Mnemonic: "Diane's silk dress costs 8 to 9 dollars" → rdi, rsi, rdx, rcx, r8, r9.

Tip: When reading disassembly, if you see values loaded into %rdi/%rsi/… right before a call, those are the function's arguments being set up.

Go deeper:

From Quiz: REVE1 / Translation of C to Assembly | Updated: Jul 14, 2026