A Command Number: Two Bits Pick the Operation
Before level 13 the game offers a short interactive intro: you build numbers out of two lamp-bits and turn a command number into selector bits yourself. This page tells the same story in text.
Experiment: two lamps and a number
Here are two lamps: the number 1 is the first lamp, the number 2 is the second. Toggle lamps and watch the sum: make 2, then make 3. Notice: 3 only appears when both are lit. Each lamp adds its own fixed number — its weight: both off — 0, both on — 3. Four combinations, one for each number from 0 to 3.
| Lamp 2 | Lamp 1 | Number |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 2 |
| 1 | 1 | 3 |
The rule: a command number = bits
You have just written a number with two bits: the first lamp is the low bit, the second is the high bit. 0=00, 1=01, 2=10, 3=11. One lamp — one selection bit. On this level the command number is called OpSelect: 0 = addition (ADD), 1 = AND, 2 = OR. Instead of "switch on lamp 2" the circuit says "bit 1 equals one" — and that picks OR.
Transfer: bits pick the operation
BusMUX is the same multiplexer from level 9, but 8-bit: it picks not two bits but two buses. The command number breaks down into selector bits: bit 0 of OpSelect picks between ADD and AND, bit 1 decides whether to replace the result with OR. OpSelect=2 is 10: the first lamp is off, the second is on — bit 0 is 0 (the first MUX passes one result of its pair), bit 1 is 1 (the second MUX substitutes OR).
Where it is used
Two bits cover 4 commands — exactly what is needed: ADD, AND, OR, and a spare. On the next level (the ALU, level 14) a third bit appears along with seven operations. Every instruction in a processor works the same way: a number from memory breaks down into bits, and each bit flips its own track switch — all the way up to choosing where the program jumps next.