Master the fundamental concepts of x86 assembly (intel syntax) through this focused micro-challenge.
Matching C to assembly is the daily work of performance and security engineers. gcc -S emits what Clang would execute; objdump -d -S interleaves source when debug symbols exist. The gap between -O0 and -O3 is the gap between naive loops and vectorized kernels.
bashLoading…
Typical lowering patterns:
int x = 5; → mov DWORD PTR [rbp-4], 5if (a > b) return a; → cmp + conditional mov + retfor (i = 0; i < n; i++) → counter in a register or stack slot, jl backFor this exercise, you will write add, max, and sum_array in C, compile to .s, and annotate the emitted instructions. This task asks you to label which C line produced each block, because "the compiler is slow" tickets become fixable once you can read the hot loop it actually emitted.
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.
Write simple C functions, compile to assembly, and match patterns.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github