LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

How do you recognize a binary tree node and tree traversal in assembly?

A tree node holds a value plus two child pointers at fixed offsets (typically 0x8 = left, 0x10 = right); traversal compares the value, then recurses down one of the two child offsets.

Node layout: value at 0x0, left pointer at 0x8, right pointer at 0x10; code loads the value, compares against the target, then recurses through 0x8 (left) or 0x10 (right).

* Node = value@0 / left@8 / right@16; compare then recurse into one child offset. *

Typical node layout (24 bytes):

offset 0:   value (4 or 8 bytes)
offset 8:   left child pointer (8 bytes)
offset 16:  right child pointer (8 bytes)

Traversal pattern:

# Load node value
mov  (%rdi), %eax
# Compare with target
cmp  %esi, %eax
jle  .L_right_or_equal

# Go left
mov  0x8(%rdi), %rdi
call <tree_func>
...

.L_right_or_equal:
# Go right
mov  0x10(%rdi), %rdi
call <tree_func>

How to identify: Two possible recursive paths based on a comparison — one follows offset 0x8 (left child), the other follows offset 0x10 (right child).

Examine tree in GDB:

(gdb) x/3xg 0x604100

Shows: value, left pointer, right pointer.

Go deeper:

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