Program as Data

The eighteenth intro leads to the main discovery of the part: a program is ordinary numbers in memory. The experiment uses ROM and two address lamps.

Experiment: a room of numbered cells

ROM memory is a room where every cell holds its own number. Two lamps set the address: address 0 shows 5, address 1 shows nine, address 2 shows seventy-seven. The cells are already filled: change the address and the numbers change on their own, no program run needed.

The rule: an instruction is a number in memory

The cells are just numbers, and any of them can turn out to be an instruction: when the processor reads them via the program counter, they act as instructions. The difference is not in the cells themselves but in where the processor reads them from. In this course's computer the memory is split (the Harvard architecture): ROM holds the instructions, RAM holds the data the program stores and fetches while it runs. The experiment's table:

AddressNumber in the cell
05
19
277
30

Transfer: both toggles are off

Both address lamps are off — address 0 is selected. The answer without clicking: 5, you saw it in the experiment. Address 0 is not emptiness, just the first cell; the address picks the cell, and the Data output shows its contents.

Where it is used

This is the intro to the final level of the part: you will build a whole computer. Its ROM is the same room of cells: the program counter walks the addresses one by one, like your two lamps, and the numbers in the cells become instructions: add, store, jump.

Take the intro in the game · Level 18 guide · All intros