Fetch–execute cycle

Every instruction is fetched from RAM, decoded by the control unit, then executed. Watch the registers and buses light up one micro-step at a time.

Theory Beginner Architecture · CPU ~8 min
The idea

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.

TipThree buses link CPU and RAM: address (where — one way, CPU → RAM), data (what — both ways), and control (read/write).
ProgramAdd two numbers
add.asmAssembly
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.

Interactive

Run the simulation

CPU on the left, RAM on the right. Watch the address, data, and control buses light up between them.

Step 0 / 0
add.asmAssembly
CPU · buses · RAMdemo
Ready
Shortcuts: Space play/pause · → step · ← back · R reset
Remember

What each part does

Registers are tiny, named memory cells inside the CPU.

Address

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

Control bus · CU

The CU sends READ or WRITE on the control bus, and steers the fetch / decode / execute phases.

Data

Data bus · MDR · ACC

Values travel the data bus through MDR. Loads fill the accumulator; stores send ACC back into RAM.