"nand2tetris" (From Nand to Tetris) is a collection of projects that let student build a computer from scratch. It is a hands-on journey that starts with the most elementary logic gate, called Nand. and ends up, 12 projects later, with a general-purpose computer system capable of running Tetris. Specifically, the 12 projects are:
- Boolean Logic
- Boolean Arithmetic
- Memory
- Machine Language
- Computer Architecture
- Assembler
- Virtual Machine I: Processing
- Virtual Machine II: Control
- High-Level Language
- Compiler I: Syntax Analysis
- Compiler II: Code Generation
- Opearting System
Part I covers Project 1 to 6. In this part, we are going to implement the hardware architecture for our Hack computer. In particular, we are going to build:
- Logical gates: Project 1
- ALU and memory devices: Project 2 and 3
- Hack machine language: Project 4
- CPU and RAM: Project 5
- Hack assembler: Project 6
Part II covers Project 7 to 12. In this part, we are going to implement Jack, a simple, Java-like, object-based programming language. As with programming languages like Java and C#, the Jack compiler will be two-tiered:
- The Hack compiler will generate interim bytecode, designed to run on an abstraction virtual machine (VM).
- The bytecode will then be compiled further by a separate VM translator into the Hack machine language.
Pictorially:
Compiler VM Assembler
Source Code ---------> Bytecode ----> Assembly --------> Binary
The languaeg that we are going to implement, Jack, has the following syntax:
// First example in Programming 101
class Main {
function void main() {
do Output.printString("Hello World");
return;
}
}
In Part II, we are going to build:
- VM translator: Project 7-8
- BreakOut game written in Jack: Project 9
- Jack compiler: Project 10-11
- Operating system: Project 12