How a Computer Works · Computer science

A tiny CPU

A tiny CPU is an interactive experiment in How a Computer Works, a free simulation from StudyFi Lab that runs right in your browser.

Program and data share the same RAM. The CPU repeats three steps: fetch — copy the byte at the address in the program counter PC into the instruction register IR and increase PC; decode — the control unit works out which instruction it is; execute — carry it out, e.g. A ← A + B. The top 4 bits of a byte are the opcode, the lower 4 bits an address or a number. JZ jumps only when the flag Z = 1 (the last result was zero).

Try this: Run the “Multiply” program, then change cell 14 from 4 to 5 and check that the output ends at 15.

Frequently asked questions

What does the “A tiny CPU” experiment show?

Program and data share the same RAM. The CPU repeats three steps: fetch — copy the byte at the address in the program counter PC into the instruction register IR and increase PC; decode — the control unit works out which instruction it is; execute — carry it out, e.g. A ← A + B. The top 4 bits of a byte are the opcode, the lower 4 bits an address or a number. JZ jumps only when the flag Z = 1 (the last result was zero).

How do I try “A tiny CPU”?

Run the “Multiply” program, then change cell 14 from 4 to 5 and check that the output ends at 15.

Studying for a test?

Upload your notes and StudyFi turns them into flashcards, tests and podcasts.

Try StudyFi free