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.
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.asmFill.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.
| Week | Watch | Do |
|---|---|---|
| Week 16 | 4.1; 4.2 | What a machine language is. Write a two-line program on paper and read it out loud. |
| Week 17 | 4.3; 4.4 | The 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 18 | 4.5 | The screen and the keyboard are memory too. Draw the screen’s memory map on graph paper. |
| Week 19 | 4.6 | Hack programming, part 1: registers, memory, and stopping a program properly. |
| Week 20 | 4.7 | Hack programming, part 2: branches, variables and loops. |
| Week 21 | 4.8 | Hack programming, part 3: pointers, and drawing on the screen. |
| Week 22 | 4.9 | Mult.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 24 | 4.10 | A 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.
- 4.1 Machine Languages: Overview 12:00
- 4.2 Machine Languages: Elements 16:58
- 4.3 The Hack Computer and Machine Language 15:48
- 4.4 Hack Language Specification 10:18
- 4.5 Input/Output 26:32
- 4.6 Hack Programming, Part 1 24:50
- 4.7 Hack Programming, Part 2 21:16
- 4.8 Hack Programming, Part 3 32:16
- 4.9 Project 4 Overview 19:04
- 4.10 Perspectives 7:38
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.