Master the fundamental concepts of x86 assembly (intel syntax) through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksOptimized builds drop variables, reorder code, and inline everything. Kernel engineers and exploit analysts then live in GDB stepping machine instructions. The same muscle memory transfers to LLDB on macOS and rr for deterministic replay.
bashLoading…
maincallAfter cmp, watch ZF (zero), SF (sign), CF (unsigned borrow), OF (signed overflow). The next jcc reads those bits.
For this exercise, you will compile a small loop with -g and step it in GDB, printing register snapshots. This task asks you to narrate what each instruction did, because production segfaults with stripped binaries only yield to this workflow.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases.
Simulate a GDB session over a counter loop and a call/ret trace.
Input line 1 is N, the initial RCX; line 2 is a sequence of debugger events, one character each: 'c' steps over a call (push the return address), 'r' steps over a ret (pop). The program under debug is:
cLoading…
loop: dec rcx ; BP1 is set here, at the label cmp rcx, 0 jg loop
Compute how many times BP1 fires, the final RCX, and the final ZF from the last cmp. Then trace the call/ret events: report the maximum stack depth, the final depth, or a SEGFAULT when a ret pops an empty stack (with the 1-based event number).
Requirements: