This note collects the commands presented in class to compile a C program to binary and then disassemble it. It also shows you how to compile C code to x86 assembly, and x86 assembly code to binary. For the adventurous, it even gives step-by-step instructions on how to edit a binary executable directly.
A simple program
Start the class VM, open your favorite editor and save this code to program.c:
#include <stdio.h>
#include <stdbool.h>
bool is_valid(int code) {
return code == 42;
Sep 12, 2020・Contributed by
I'll try to improve this guide over time. The goal is to collect the essential knowledge about x86-64 assembly and examples of very common patterns (if, while, for, procedure calls) in BombLab.
The registers
We have plenty of registers inside the CPU; they can store 8 bytes each and they are called:
%rax, %rbx, %rcx, %rdx (the "a, b, c, d")
%rsi, %rdi (source index, destination index)
%rsp, %rbp (stack pointer, base pointer)
%r8, %r9, .., %r15 (just numbers here)
Sep 12, 2020・Contributed by