Preface
There is no shortage of assembly language books. The gap is in assembly language books that are free, modern, cover two architectures, treat security as a first-class topic, and assume you deserve a clear explanation of what's actually happening — not just a list of instruction mnemonics.
This book started from a simple observation: the best way to understand how computers work is to program them in assembly language. Not because assembly is "low level" — it is the real language of the machine, and everything else is built on top of it. Once you can read and write assembly fluently, you stop saying "I wonder what the compiler does here" and start saying "I know exactly what the compiler does here." You stop saying "I can't figure out why this is slow" and start saying "the L3 cache miss rate on this loop is 40%, and here's why." You stop saying "buffer overflow is some kind of memory thing" and start saying "the saved return address is at [rbp+8], and when the attacker controls that value, program execution goes wherever they want."
That shift in precision — from vague to exact — is what this book is trying to give you.
Why Another Assembly Textbook?
The dominant college textbook (Irvine's Assembly Language for x86 Processors) is Windows-focused, uses MASM syntax, and costs over $100. The beloved free alternative (Programming from the Ground Up by Bartlett) covers 32-bit x86 with AT&T syntax — solid but dated. Randall Hyde's Art of Assembly Language uses a custom assembler (HLA) that isn't what the industry uses. None of them cover ARM64 in any depth. None of them treat security as central material.
This book is different:
- NASM on Linux — the assembler the industry actually uses, on the platform where systems programming is taught
- Two architectures — x86-64 as the primary (your laptop, CTF challenges, compiler output) and ARM64 as the essential secondary (phones, Macs, Raspberry Pi, and increasingly servers)
- Security content throughout — buffer overflows, mitigations, and reverse engineering are not optional chapters bolted on at the end. They are the reason assembly matters for half the people reading this book.
- A real project — you will build a bootable operating system kernel, written in assembly and C, that you can run in QEMU and type commands into. Every concept in the book contributes to this project.
- Free — CC-BY-SA-4.0. Share it. Adapt it. Teach from it.
The Practitioner's Philosophy
Assembly is hard. We are not going to pretend it isn't. The x86-64 architecture is, as the historian of computing would say, an archaeological site: 45 years of backward compatibility decisions, from the 8086 (1978) through the 80286, 386, Pentium, and Pentium Pro to the Athlon 64, layered on top of each other like geological strata. Understanding why x86-64 has 16 general-purpose registers when ARM64 has 31, why writing to a 32-bit register zeros the upper 32 bits of the 64-bit register but writing to a 16-bit register does not, why there's a REP MOVSB instruction for copying memory but no ADD [mem], [mem] — these quirks all make sense when you know the history.
We will not shy away from that complexity. But we will always explain it.
The tone of this book is the tone of a senior systems engineer who has debugged kernel panics at 3am, who thinks in hex without effort, who has a dry sense of humor about the beautiful insanity of x86 — and who remembers vividly what it felt like to not understand any of this. Assembly programmers are not magicians. They are people who took the time to learn what happens below C. You can be one of them.
How to Use This Book
Chapter 1 begins with a motivating example: take a simple C program, compile it, and disassemble it. Look at what comes out. That disassembly is what this book teaches you to write and read fluently.
If you are working through the book as a course: follow the chapter order. Each chapter builds on the previous. The register trace tables are the most important exercises — do them before looking at the answers.
If you are here for security: the Fast Track learning path (described in How to Use This Book) takes you through the essential machine model (Chapters 1–5), the x86-64 instruction set (Chapters 8–11), ARM64 basics (Chapters 16–19), and directly to the security material (Chapters 34–37). You can always fill in the gaps later.
If you just want to understand what the compiler outputs: Chapter 21 (Understanding Compiler Output) is your core chapter. The chapters before it give you the vocabulary to read it.
If you are building an OS: Parts V and VI plus Chapter 38 form a complete systems programming curriculum. Chapter 28 (Bare Metal Programming) and Chapter 38 (Capstone: A Minimal OS Kernel) are where the MinOS project lives.
A Note on the Progressive Project
Throughout the book, callouts marked 📐 OS Kernel Project contribute to MinOS — a minimal operating system kernel that boots in QEMU, handles keyboard input, and provides a simple shell. By Chapter 38, you will have all the pieces to assemble it. We strongly recommend building it. There is no better proof that you understand the machine than booting an operating system you wrote yourself.
Acknowledgments
This book stands on the shoulders of the assembly programming community. The Intel and AMD software developer manuals are the authoritative reference for x86-64 and we have used them extensively. Agner Fog's optimization manuals and instruction tables have informed every performance discussion. The OSDev wiki and community have answered every "but how does the bootloader actually work?" question we could have asked. The NASM documentation is exemplary. Ghidra's existence as a free, professional-quality disassembler has democratized reverse engineering in a way that would not have been possible a decade ago.
The textbooks that came before — Irvine, Bartlett, Hyde, and especially Computer Systems: A Programmer's Perspective by Bryant and O'Hallaron — shaped our thinking about how assembly language should be taught, even where this book differs from their approaches.
The machine does exactly what you tell it — nothing more, nothing less.
That precision is now yours to use.