A comprehensive, progressive guide to learning x86-64 assembly language from fundamentals to advanced topics, featuring theory, practical examples, exercises, and a quick reference guide.
This tutorial provides a complete learning system for assembly language with multiple learning modalities:
- Theory – Detailed explanations of CPU architecture, registers, memory, and instruction sets
- Working Examples – 5 complete, compilable programs with C test harnesses
- Practice Exercises – 23 tiered exercises from beginner to advanced with solutions
- Quick Reference – Cheat sheet for common instructions, patterns, and tools
Start Here: Read 00_TABLE_OF_CONTENTS.md for the full learning pathway and structure.
- New to assembly? Start with 01_Introduction.md
- Want examples immediately? See 20_Assembly_Examples.md or 22_Example_Programs.md
- Learning a specific topic? Refer to 00_TABLE_OF_CONTENTS.md for the file index
- Need a quick lookup? Use 24_Quick_Reference.md
- Introduction, CPU architecture, registers, number systems, memory, data types, addressing modes
- Instruction format, arithmetic, logical, comparison/jumps, and move instructions
- Loops, functions/procedures, and calling conventions (System V & Microsoft x64)
- Interrupts & system calls, advanced techniques (SIMD, optimization), debugging
- Common patterns and 9 detailed example programs
- 23 exercises by difficulty, 5 complete working programs with test harnesses, detailed solutions, quick reference
To compile and run the examples, you'll need:
- NASM (Netwide Assembler) – Assemble .asm files
- GCC – Compile C test harnesses and link with assembly
- GDB (optional) – Debug assembly code
- Linux/Unix or WSL for Windows
sudo apt-get install nasm gcc gdbAll example programs in 22_Example_Programs.md include complete source code and compilation instructions. Typical workflow:
nasm -felf64 example.asm -o example.o
gcc example.o test_example.c -o test_example
./test_exampleSee the example files for specific compilation commands for each program.
Follow these steps for optimal learning:
- Learn theory – Study Part 1-4 files (01-07) for fundamentals
- Study instructions – Read Part 4-5 files (08-12) to understand instruction sets
- Understand control flow – Review Part 6 files (13-15) for practical code structure
- Learn with examples – Study Part 6-7 examples alongside theoretical content
- Practice – Work through exercises in 21_Exercises.md
- Check solutions – Review 23_Solutions.md for detailed explanations
- Experiment – Modify examples, create your own functions, test edge cases
| File | Topic | Focus |
|---|---|---|
| 00 | TABLE OF CONTENTS | Navigation & learning pathway |
| 01 | Introduction | Overview & tools |
| 02 | CPU Architecture | Fetch-execute, cache, privilege levels |
| 03 | Registers | All register types & usage |
| 04 | Number Systems | Binary, hex, conversion |
| 05 | Memory Model | Stack, heap, segments |
| 06 | Data Types | Byte through quadword |
| 07 | Addressing Modes | All 7 modes with examples |
| 08 | Instruction Basics | Format & encoding |
| 09 | Arithmetic Instructions | ADD, SUB, MUL, DIV |
| 10 | Logical Instructions | AND, OR, XOR, NOT, shifts |
| 11 | Comparison & Jumps | CMP, TEST, conditional/unconditional |
| 12 | Move Instructions | MOV, LEA, MOVSX/MOVZX, CMOV |
| 13 | Loops | LOOP, manual loops, optimization |
| 14 | Functions & Procedures | Stack frames, CALL/RET, recursion |
| 15 | Calling Conventions | System V vs Microsoft x64 |
| 16 | Interrupts & Syscalls | SYSCALL, Linux system calls |
| 17 | Advanced Techniques | SIMD, optimization, prefetch |
| 18 | Debugging | GDB, tools, strategies |
| 19 | Common Patterns | Useful code snippets |
| 20 | Assembly Examples | 9 complete programs |
| 21 | Exercises | 23 practice problems by difficulty |
| 22 | Example Programs | 5 working programs with test harnesses |
| 23 | Solutions | Detailed solutions with execution traces |
| 24 | Quick Reference | Instruction tables, patterns, tools |
- NASM Manual – https://www.nasm.us/
- System V AMD64 ABI – UNIX System V ABI x86-64 calling convention reference
- GDB Documentation – https://www.gnu.org/software/gdb/
- Type along – Don't just read; type out the code examples
- Modify & test – Change the examples and observe the results
- Use GDB – Debug your code to understand execution flow
- Check disassembly – Use
objdump -dto see compiled machine code - Do the exercises – Practice is essential for learning
This tutorial focuses on:
- x86-64 architecture (64-bit Intel/AMD processors)
- NASM assembler syntax (widely available, readable)
- System V AMD64 ABI (Linux/Unix standard calling convention)
- Practical, working code (all examples are compilable and testable)
- Progressive difficulty (theory → examples → exercises → reference)
- Open 00_TABLE_OF_CONTENTS.md to see the complete structure
- Start with 01_Introduction.md or jump to a topic of interest
- Compile and run examples from 22_Example_Programs.md
- Work through the exercises in 21_Exercises.md
- Use 24_Quick_Reference.md as your coding reference
Happy learning! Assembly language is challenging but rewarding. Take your time with fundamentals, practice with examples, and don't be afraid to experiment.