Computer architecture
Fetch–decode–execute cycle
Also called: instruction cycle · fetch decode execute · program counter · PC
Definition
A processor runs a program by repeatedly fetching the instruction at the program counter, decoding what it means, executing it and moving the program counter on.
Picture it
The program counter is a bookmark. Normally it advances by one instruction's size each time; a jump or branch writes a new address into it instead. Everything a computer does, from games to robot control, is this loop running millions of times a second.
The maths
loop: IR ← memory[PC]; PC ← PC + size; decode IR; execute
| Quantity | Unit | Symbol |
|---|---|---|
| information | byte (8 bits) | B |
Worked example
A processor with 4-byte instructions has PC = 0x100. It executes three ordinary instructions and then a branch to 0x200. What is the PC after each step?
- 0x100 → 0x104 → 0x108 → 0x10C
- The branch at 0x10C writes 0x200
Answer0x104, 0x108, 0x10C, then 0x200 (decimal 256, 260, 264, 268, then 512).
✓ The 2 numbers in this answer are recomputed from scratch by an automated test.
Common misconceptions
- Misconception: The program counter holds an address, not an instruction.
- Misconception: Fetch, decode and execute can overlap in a pipelined processor; the model still describes each instruction's journey.