LOGBOOK

HELP

Quiz Entry - updated: 2026.07.06

How do you recognize struct field access in assembly?

Look for fixed constant offsets off one base pointer (0(%rax), 4(%rax), 12(%rax)) — each offset is a field's position within the struct.

Fixed constant offsets off one base pointer: int a@0, int b@4, long c@8 (movq), int i@16, with alignment padding; mixed sizes off one base signal a struct, not an array.

* Fixed constant offsets off one base pointer (0, 4, 8, 16), often with mixed access sizes (movl for int, movq for long) and alignment padding — the signature of struct field access versus a scaled array index. *

# Access struct field at offset 12
movl 12(%rax), %edx

# Access struct field at offset 0 (first field)
movl (%rax), %edx

Example struct:

struct rec {
    int a;       // offset 0
    int b;       // offset 4
    long c;      // offset 8 (aligned)
    int i;       // offset 16
};

How to identify structs vs arrays:

  • Struct: Different constant offsets, potentially different instruction sizes (movl for int at offset 0, movq for long at offset 8)
  • Array: Scaled index with uniform element size

Tip: If you see multiple accesses to the same base register with different fixed offsets (0(%rax), 4(%rax), 12(%rax)), it's a struct. Map the offsets to figure out field sizes and padding.

Go deeper:

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