LOGBOOK

HELP

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.

Loop reads a node's value at offset 0, overwrites the pointer from the next field at offset 8 (mov 0x8(%rbx),%rbx), and null-checks (test %rbx,%rbx; jne) before repeating until NULL.

* 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:

  1. A register holds the current node pointer
  2. Data is read from offset 0 (or small offset) — the value field
  3. The pointer register is updated from a larger offset — the next pointer
  4. 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:

  • doc Linked list (Wikipedia) — Defines nodes as data plus a next reference and shows the while(node != null) node := node.next traversal the assembly mirrors.
  • doc Record / struct layout (Wikipedia) — Each list node is a struct: explains the fixed offsets (value@0, next@8) the loop dereferences.

From Quiz: REVE1 / Assembly Patterns & GDB | Updated: Jul 06, 2026