KS3 · Computer Science

The fetch–decode–execute cycle

Every game, video and message on your computer comes down to one tiny loop: get an instruction, work out what it means, do it. Then again. Let's slow it down.

Computer Science · Inside the CPU

Follow the program counter

Three instructions sit one after another in main memory: address 0 holds LOAD from 7, address 1 holds ADD 5, address 2 holds STORE to 7. Address 7 holds the data value 20. This is a simple model, so the names inside a real CPU may differ.

Before you press Next: the program counter holds 0. What will it hold straight after the first instruction has been fetched?

Phase: Fetch — instruction 1

Program counter

0

Instruction fetched

LOAD from 7

Decoded as

—

ALU

—

Register

—

Address 7

20

Output

 

Step 1: The program counter says 0. That 0 isn't an instruction and it isn't a score — it's an ADDRESS. So the CPU goes to address 0 in main memory and fetches whatever is stored there: LOAD from 7.

1 / 13

Press Next one step at a time. Keep your eye on the program counter — when exactly does it change?

Step 1 of 13: The program counter says 0. That 0 isn't an instruction and it isn't a score — it's an ADDRESS. So the CPU goes to address 0 in main memory and fetches whatever is stored there: LOAD from 7..

Check your thinking

What is the program counter actually holding?

A program starts at address 0 and runs in order. The CPU has just fetched the instruction at address 4, and the program counter now shows 5.

Be honest — which is closest to what you think that 5 means?
How sure are you?

Who does what?

Match each job to the part of the CPU that does it

Pick a job, then choose the part of the CPU that does it.

Still to sort

Control unit (0)

Works out what to do and directs the cycle.

Where the line is: The control unit works out what needs doing; the ALU does the actual sums and comparisons.

ALU (0)

Arithmetic logic unit: the arithmetic and logic.

Where the line is: The ALU gets to work at execute, once the control unit has decoded the instruction.

Registers (0)

Very small, very fast storage inside the CPU.

Where the line is: Registers are inside the CPU. The program itself is stored outside the CPU, in main memory.

Clock (0)

Sets the pace of the cycle.

Where the line is: The clock keeps the timing; it doesn't decode anything, work anything out or count instructions.

7 of 7 still to sort.

Rebuild it, then break it

Why does the cycle need every stage?

2 stages are missing. Use the rest of the loop to work out which goes where.

  1. Stage 1: Reading the program counter

    The CPU looks at the address held in the program counter.

  2. Stage 2: Fetching the instruction

    The instruction stored at that address in main memory is brought into the CPU.

  3. Stage 5: Executing

    The instruction is carried out — the ALU calculates or compares, or data moves between memory and the CPU.

…and stage 5 leads back to stage 1.

Predict, then check

Two CPUs are identical in every way except their clock speed. CPU A runs at 1.5 GHz. CPU B runs at 3 GHz. Same program on both.

Which CPU gets through more instructions each second?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Get it, work out what it means, do it — then go round again.

What you need to know

  • A program's instructions, and the data it works on, are both stored in main memory (RAM).
  • Every memory location has an address — a number that says where it is, a bit like a house number.
  • Have a goAddress 7 holds the number 20. Which of those two numbers is the address, and which is the data?

    7 is the address (where); 20 is the data (what's stored there).

    The address only says where to look — the value sitting there can change, as when a 20 becomes a 25, while the address stays 7.

  • The CPU runs a program by repeating the fetch–decode–execute cycle, one instruction after another, many times every second.
  • Fetch: the CPU uses the address in the program counter to get the next instruction from main memory.
  • Straight after the fetch, the program counter goes up so it points to the next instruction.
  • Have a goEach instruction takes one address. The program counter shows 41 and the CPU fetches. Your friend bets you a biscuit it still shows 41. Take the bet?

    Take it — straight after the fetch it shows 42.

    41 is used first to find the instruction, then the counter goes up to point at the next one. 41 is only right before the fetch.

  • Decode: the control unit works out what the instruction means and what the CPU needs to do.
  • Execute: the CPU carries it out — the ALU calculates or compares, or data moves between memory and the CPU. Then it's back to fetch.
  • Have a goAn instruction says 'compare 8 and 3'. At which stage does the comparing happen, and which part of the CPU does it?

    At execute, by the ALU.

    Decode only works out that a comparison is needed; actually comparing the numbers is the ALU's job once the instruction is executed.

  • The control unit directs the whole cycle. Registers, like the program counter, are tiny, very fast stores inside the CPU.
  • The clock sets the pace. Clock speed, measured in hertz, is how many clock cycles the CPU can carry out each second.
  • Higher clock speed means more instructions processed each second.

The big picture

Instructions and data sit in main memory, each at its own address. The CPU runs a program by going round one loop: fetch the instruction at the program counter's address (the counter then goes up), decode it in the control unit, execute it — the ALU calculates or compares, or data moves. Then back to fetch. Registers are tiny, fast stores inside the CPU; the clock sets the pace, and clock speed in hertz is clock cycles per second. A higher clock speed means more instructions can be processed each second.

Key points

1The program counter holds an address — where the next instruction is. It doesn't hold the instruction, and it doesn't count how many instructions have run.
2The program counter goes up straight after each fetch, so it points to the next instruction.
3The control unit directs the cycle and decodes instructions. The ALU (arithmetic logic unit) does arithmetic and logic, such as adding and comparing.
4Registers are very small, very fast storage places inside the CPU. The program counter is one of them.
5Execute doesn't always mean a sum: an instruction can simply move data between memory and the CPU.
6Clock speed is clock cycles per second, in hertz. A higher clock speed means more instructions can be processed each second.
7Fetch–decode–execute is how the CPU runs stored instructions: fetch, decode, execute, then round again.

Worked example

Problem

The program counter holds 12. The instruction stored at address 12 tells the CPU to compare two numbers to find out which is bigger. Each instruction in this program takes up one address. Describe what happens at each stage of one fetch–decode–execute cycle, and say what the program counter holds at the end.

⚠ Watch out

Treating the program counter as the instruction itself — or as a count of instructions run. It holds an address. The other big one: thinking a lower clock speed number means a faster CPU. Clock speed is cycles per second, so a bigger number means more cycles each second.

🧠

Memory hook

Fetch it, decode it, do it — then go again. And the program counter is a bookmark: it marks WHERE to read next, not what's written there.

✓

Check yourself

Cover the page and talk it through out loud: one full trip round the cycle for ADD 5 — what the program counter, the control unit and the ALU each do.

Flashcards

(14)
What is stored in main memory while a program runs?
The program's instructions AND the data it uses — each at its own memory location.
What is a memory address?
A number that identifies one location in main memory — it says where something is stored.
What does the program counter hold?
The address of the next instruction to fetch. Not the instruction itself, and not a count of instructions run.
When does the program counter go up?
Straight after an instruction is fetched, so it points to the next one.
What happens at the fetch stage?
The CPU gets the next instruction from main memory, using the address held in the program counter.
What happens at the decode stage, and which part does it?
The control unit works out what the instruction means and what the CPU needs to do.
What happens at the execute stage?
The instruction is carried out — for example the ALU calculates or compares, or data moves between memory and the CPU.
What happens straight after execute?
The cycle starts again with the next fetch.
What does ALU stand for, and what does it do?
Arithmetic logic unit. It does arithmetic and logic operations, such as adding and comparing.
What two jobs does the control unit do in the cycle?
It directs the cycle, and it decodes instructions.
What are registers?
Very small, very fast storage places inside the CPU. The program counter is one.
What does the clock do?
It sets the pace of the cycle.
What is clock speed, and what is it measured in?
The number of clock cycles the CPU can carry out each second, measured in hertz — 3 GHz means 3 billion clock cycles a second.
What does a higher clock speed mean?
The CPU carries out more clock cycles each second, so more instructions can be processed each second.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 27 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.

Helpful guides for parents and students