Introduction
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.
- Simple interpreter. Get your own programming language up and running.
- Bytecode compiler. A step closer to the machine.
- x64 assembly & instruction encoding. Understand how the machine works.
- Translate bytecode to x64 code. Bridging the virtual machine to the real machine.
- Generate binary executables. Putting it all together.
Contents
Part I: Interpreter
- Introduction
- A Simple Calculator
- Interpreter: Variables and Scopes
- Interpreter: Control Flows and Functions
Part II: Bytecode Compiler
- How Computers Work
- The Virtual Machine and Bytecode
- Compiler: Variables and Expressions
- Compiler: Control Flows
- Compiler: Functions and Non-Local Variables
Part III: Machine Code
- A Crash Course on x64 Assembly
- The x64 Instruction Encoding
- From Virtual Machine to Real Machine
- Binary Executables
- Pointers and Memory
PDF/EPUB and Paperback Editions
The full book is available for purchase.