From Source Code To Machine Code eBook·Paperback
⟵ prev Contents next ⟶

🔥 My other Book: Build Your Own Redis

From Source Code To Machine Code

Build Your Own Compiler From Scratch

James Smith


Build a compiler to learn how programming languages work. Use low-level assembly to learn how computers work.

Walks through a minimal yet complete compiler implementation. Compiles a static-typed language into x64 ELF executables.

  1. Simple interpreter. Get your own programming language up and running.
  2. Bytecode compiler. A step closer to the machine.
  3. x64 assembly & instruction encoding. Understand how the machine works.
  4. Translate bytecode to x64 code. Bridging the virtual machine to the real machine.
  5. Generate binary executables. Putting it all together.


Part I: Interpreter

  1. Introduction
  2. A Simple Calculator
  3. Interpreter: Variables and Scopes
  4. Interpreter: Control Flows and Functions

Part II: Bytecode Compiler

  1. How Computers Work
  2. The Virtual Machine and Bytecode
  3. Compiler: Variables and Expressions
  4. Compiler: Control Flows
  5. Compiler: Functions and Non-Local Variables

Part III: Machine Code

  1. A Crash Course on x64 Assembly
  2. The x64 Instruction Encoding
  3. From Virtual Machine to Real Machine
  4. Binary Executables
  5. Pointers and Memory

The book is available for purchase.

( Report an Error | Ask a Question) @

See also: offers “Build Your Own X” courses in many programming languages.
Including Redis, Git, SQLite, Docker, and more.
Check it out

⟵ prev Contents next ⟶