Program it
Memory (RAM): 16 lines
Display so far · target
Your breadboard computerstep 0 · tick 0
Why did it do that?
What am I building?
Tap a card at the bottom (or drag it), then tap a memory line. Use − / + or the little menu to set its number. Press Run to put the clock on AUTO, or Step for one clock tick. The speed knob on the clock sets how fast AUTO ticks; Instant runs to the end at once.
What is a program?
A program is a list of instructions in memory. An instruction is one small order, like "add" or "show". The CPU does them in order, top to bottom, unless an instruction tells it to jump somewhere else.
What is an address?
The memory has 16 lines, numbered 0 to 15. A line's number is its address, like a house number. LDA 14 means "go to the line with address 14 and copy its number". The 4 address wires A3 A2 A1 A0 carry it from the MAR to the RAM.
Why does every line show 8 binary digits?
Because that is all memory really holds: 8 bits per line. An instruction is just a number. The first 4 cells (lit orange) say which instruction, the last 4 (lit blue) say which address or number. Your control unit from chapter 6 reads those first 4 bits.
What do the blue control lights mean?
Each blue light is one control line, in the same order as on Ben Eater's computer: HLT MI RI RO IO II AI AO EO SU BI OI CE CO J FI. For every step T0 to T4 the control unit turns some of them on. An Out line puts a number on the bus at once; an In line copies the bus on the next clock tick. T0 and T1 always fetch the next instruction; T2 to T4 do it.
How does Ben type a program in?
He flips the PROG/RUN switch to PROG. Now the RAM address comes from 4 DIP switches instead of the MAR. He sets the 8 data switches to the instruction's bits and presses WRITE, one line at a time. Then he flips back to RUN, resets and starts the clock. Tap 🎛 Enter with DIP switches to try it.
What are A, B, PC and IR?
A is the register where the CPU keeps the number it is working on. B holds the second number for adding or subtracting. PC (program counter) remembers which line runs next. IR (instruction register) holds the instruction being done right now.
What are the C and Z lights?
They are flags: two little memory bits the CPU sets after every ADD or SUB (the FI line). Z (zero) lights when the answer is 0. C (carry) lights when an ADD is too big for 8 bits (over 255). After a SUB, C lights when no borrow was needed, so A was at least as big as the number taken away. Jump cards can look at these lights.
Can I break anything?
No. Try anything. If your program goes wrong, the checker explains what happened in plain words, and Hint gives you clues one at a time.
What happens on an empty line?
An empty line holds 0000 0000. Opcode 0 means "do nothing" (it is called NOP, no operation), so the CPU just moves to the next line. After line 15 the program counter wraps back to 0, because it only has 4 bits.
Can the CPU tell my numbers from my instructions?
No! A number like 20 is 0001 0100, which also reads as LDA 4. If the CPU walks into your numbers, it runs them as instructions. That is why programs end with HLT before the data lines.