Fetch, then execute
The CPU never “sees” a whole program at once. It repeatedly: fetch the next instruction from memory, decode it, then execute it — using registers as staging posts for addresses and data.
This demo runs a tiny program that loads 10, adds 25, and stores 35 back into RAM.
LDA 5 # ACC ← RAM[5] ADD 6 # ACC ← ACC + RAM[6] STA 7 # RAM[7] ← ACC HLT # stop
Data at addresses 5 and 6: 10 and 25. Result lands in address 7.
Run the simulation
CPU on the left, RAM on the right. Watch the address, data, and control buses light up between them.
What each part does
Registers are tiny, named memory cells inside the CPU.
Address bus · MAR
PC or an operand is copied into MAR, which drives the address bus one way — CPU → RAM — so memory knows which cell to use.
Control bus · CU
The CU sends READ or WRITE on the control bus, and steers the fetch / decode / execute phases.
Data bus · MDR · ACC
Values travel the data bus through MDR. Loads fill the accumulator; stores send ACC back into RAM.