Part 10 of 12
Programs on a tiny CPU
Write and trace full programs so the components become a real computing system.
The story before the details
The most rewarding proof that a computer works is not a diagram; it is a program that changes state correctly. A tiny instruction set can already load values, add them, store results, output them and branch. These operations are enough to demonstrate stateful algorithms and loops.
A trace table is your microscope. Each row records the instruction address, opcode, relevant registers, flags and memory changes. When something goes wrong, the table shows which state was unexpected. Without it, you may know that the final output is wrong but not why.
Fibonacci is a particularly revealing example. The next term equals the sum of the previous two, so the program must remember two values, calculate a new one, replace the pair and repeat. The circuit you have built is no longer a static arithmetic demonstration; it is a programmable sequence engine.
What you will discover
These six lessons are arranged so each one answers a question created by the previous one. Do not rush to the last lesson. If a concept feels opaque, use the checkpoint before continuing.
- 10.01Assembly from ideas↗How do human-readable instructions become bytes?
- 10.02The first program↗Can a few instructions produce a visible result?
- 10.03Loops and stopping↗Why does one instruction run many times?
- 10.04Fibonacci by repeated addition↗How does a simple CPU calculate a sequence?
- 10.05Reading a timing trace↗How do you debug a program without guessing?
- 10.06The software/hardware boundary↗What part is programmable?
Write and trace full programs so the components become a real computing system. You should be able to explain each concept using only an input, a rule, an output, and any state that must be retained.