5.1.10 · D1Instruction Set Architecture (ISA)

Foundations — Calling conventions and ABI

1,542 words7 min readBack to topic

This page builds every word, register name, and symbol the parent note throws at you, starting from a reader who has never seen assembly. Nothing below assumes anything above it.


1. The register — a named box inside the CPU

Look at the figure: the CPU is the box on the left, holding a small row of labelled cells. That's all the registers there are. Memory is the long strip on the right.

Figure — Calling conventions and ABI

The name r in rax, rdi, rsp just means "register, 64-bit". The letters after it are historical (a = accumulator, di = destination index, sp = stack pointer). Treat them as names of boxes, nothing more. See Registers and Register File for the full set.


2. Memory and the address — the long numbered strip

The square brackets are the single most important notation the parent uses without defining it:

Without brackets = the box's own value. With brackets = follow the box like an arrow into memory.

Figure — Calling conventions and ABI

Reveal-test:

The value in rsp
a number that is an address (a location in memory)
[rsp]
the actual data stored at that location

3. The stack — a scratch region that grows downward

This "grows downward" fact explains why the parent writes : making room means moving down.

Figure — Calling conventions and ABI

4. The instruction pointer and push / pop / call / ret

The symbol (or ::=) the parent uses just means "is defined to be exactly the same as". So call f ≡ push rip_next; jmp f reads: "the call instruction is nothing but a push followed by a jump." Nothing magical — it is built from the pieces above.


5. Arguments, return value, and the "convention" itself

Reveal-test:

?
yes — , remainder 8
?
no — is a multiple of 16, remainder 0

Prerequisite map

Register - box in CPU

Calling convention

Memory and address

Stack grows down

Stack frame

Bracket notation - deref

rsp and rip

push pop call ret

Arg and return slots

ABI - full rulebook


Equipment checklist

What is a register?
A tiny fast named storage box inside the CPU, holding one 64-bit word; there are only a few.
What does rsp hold?
The address of the current top of the stack.
What does [rsp+8] mean?
The memory contents at the address (value in rsp) + 8.
Which direction does the stack grow on x86-64?
Downward — toward smaller addresses; push subtracts from rsp, pop adds.
What does call f do, in terms of simpler pieces?
Push the return address onto the stack, then jump to f (set rip = f).
What does ret do?
Pop the return address off the stack into rip, resuming the caller.
Why do arguments and return values need a convention at all?
The CPU has no concept of them; only agreement on fixed registers/slots makes "argument" and "return value" meaningful.
What does rsp ≡ 8 (mod 16) mean at function entry?
rsp divided by 16 leaves remainder 8, so the stack was 16-aligned before the call pushed the 8-byte return address.
What does mean in "calling convention ⊂ ABI"?
"Is a part of / subset of" — the convention is one chapter of the larger ABI rulebook.