The Benedict Year › The workshop

Project 4 · Weeks 16–24

The machine’s language

Before building the processor, you learn to speak to it: programs written in the machine’s own language, run on an emulator of the computer you are about to build.

Beside Unit 6 · The Person and Unit 7 · Being and Unit 8 · God

In the course: Project 4, Machine Language · slides and project notes at nand2tetris.org

The kind of answer

Understood, and said by analogy. A program means something to the one who wrote it and nothing to the machine. The machine “reads” and “remembers” only by analogy, as the units on the person and on being explain. Taught: the instructions come to it from outside, with their rank and order fixed.

On paper first

The computer’s screen is a grid of pixels stored in memory, sixteen pixels to a word. On graph paper, colour in the first word of the top row: which sixteen pixels is it?

What you build

In the CPU Emulator. The files for Project 4 are in the IDE’s own projects folder, so there is nothing to download.

  • Mult.asm
  • Fill.asm
  • a program of your own

Each one is done when its test passes in the IDE. A pass cannot be argued with, and neither can a fail.

Week by week

About an afternoon a week. If a week runs long, let it: the strand keeps its own order, not the calendar’s.

WeekWatchDo
Week 164.1; 4.2What a machine language is. Write a two-line program on paper and read it out loud.
Week 174.3; 4.4The Hack computer and its two kinds of instruction. Load a program in the CPU Emulator and step through it one instruction at a time.
Week 184.5The screen and the keyboard are memory too. Draw the screen’s memory map on graph paper.
Week 194.6Hack programming, part 1: registers, memory, and stopping a program properly.
Week 204.7Hack programming, part 2: branches, variables and loops.
Week 214.8Hack programming, part 3: pointers, and drawing on the screen.
Week 224.9Mult.asm: multiply two numbers with a machine that cannot multiply.
Week 23—Fill.asm: black the screen while a key is held down, white it when the key is let go.
Week 244.10A program of your own: draw your initial on the screen. Keep it; you will run it again on the computer you build.

The lectures

10 lectures, about 187 minutes in all, by Nisan and Schocken. Watch with your parent, one or two at a sitting.

For the parent

This is the hardest jump in Part I, because it is the first real programming. Mult is done by adding over and over in a loop. If your child is stuck on Fill, have them write it in plain words first (“wait for a key; if pressed, paint every word black…”), then turn each line into instructions.

Public domain I have dedicated this page to the public domain under CC0 1.0. Copy it, change it, translate it, print it and share it, for any purpose, without asking. Quotations from other writers keep their own terms.