Master the fundamental concepts of x86 assembly (intel syntax) through this focused micro-challenge.
glibc syscall stubs, OpenSSL AES-NI kernels, and ffmpeg SIMD paths are assembly called from C. The linker only cares that both sides agree on symbol names and the System V AMD64 ABI: args in rdi/rsi/..., return in rax, 16-byte stack alignment at the call site.
cLoading…
nasmLoading…
extern; NASM exports globaledi/esi for 32-bit int args in the cdecl/System V mix you see in starter codegcc main.c add.o -o prog (no underscore prefix on Linux x86-64)For this exercise, you will write the assembly adder and call it from C. This task asks you to verify the return in rax, because a one-register mistake here is indistinguishable from "C is broken" until you disassemble the call site.
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 an assembly function that can be called from C following the System V AMD64 ABI calling convention.
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