Quiz Entry - updated: 2026.07.14
What are the x86-64 memory addressing modes?
A memory operand has the general form D(Rb, Ri, S), computing the address Rb + Ri×S + D — base register, scaled index register, and a constant displacement.
* The effective address is base + index x scale + displacement; the scale (1/2/4/8) equals the element size, and the index can be any register except %rsp. *
This one flexible form is what lets a single instruction reach an array element, a struct field, or a stack slot. You use whichever pieces you need:
| Mode | Syntax | Address computed |
|---|---|---|
| Absolute | 0x1000 |
0x1000 |
| Indirect | (%rax) |
%rax |
| Base + displacement | 8(%rax) |
%rax + 8 |
| Indexed | (%rax,%rbx) |
%rax + %rbx |
| Scaled indexed | (%rax,%rbx,4) |
%rax + %rbx×4 |
| Full | 8(%rax,%rbx,4) |
%rax + %rbx×4 + 8 |
The scale S can only be 1, 2, 4, or 8 — not by accident, but because those are exactly the sizes of the primitive data types, so array[i] for any type maps onto one addressing mode. The index register can be any register except %rsp.
8(%rbp) # a local variable
(%rax,%rcx,4) # int array: base + index*4
array(,%rdi,8) # 8-byte element array[i] with no base register
Go deeper:
Addressing mode (Wikipedia) — the general base + index x scale + displacement computation.