Quiz Entry - updated: 2026.07.06
How do you recognize linked list traversal in assembly?
Look for a loop that reads data at offset 0 of a node, then overwrites the node pointer from a larger fixed offset (the next field), and null-checks before repeating.
* The loop reads value at offset 0, then overwrites the node pointer from a larger fixed offset (mov 0x8(%rbx),%rbx = the next field), and null-checks before repeating. mov 0x8(%rbx),%rbx inside a loop is the giveaway. *
.L_loop:
# Do something with current node's value
mov (%rbx), %eax
# Follow next pointer (at offset 8)
mov 0x8(%rbx), %rbx
# Check if NULL
test %rbx, %rbx
jne .L_loop
The pattern:
- A register holds the current node pointer
- Data is read from offset 0 (or small offset) — the value field
- The pointer register is updated from a larger offset — the
nextpointer - Null check (
test %reg, %reg+je) terminates the loop
Node structure (typical):
offset 0: value (4 bytes int)
offset 4: node number or padding
offset 8: next pointer (8 bytes)
Total: 16 bytes per node
Tip: If you see mov 0x8(%rbx), %rbx inside a loop — that's following a linked list.
Go deeper:
Linked list (Wikipedia) — Defines nodes as data plus a next reference and shows the while(node != null) node := node.next traversal the assembly mirrors.
Record / struct layout (Wikipedia) — Each list node is a struct: explains the fixed offsets (value@0, next@8) the loop dereferences.