Study Guide

The Fetch-Decode-Execute Cycle

How the CPU obeys a program one instruction at a time: fetch the instruction, decode it, execute it, and what each register, unit and bus does at every stage, followed through a tiny invented program.

Lesson 3.2 Computer Systems

For: Cambridge IGCSE Computer Science learners

Stage: Think

The cook’s routine, again

Back in the made-up school kitchen from the last lesson: the cook takes one recipe card from the folder, works out what it says, does it, and moves on to the next card. The cook does this for every card until the lunch is made.

Think it through

Name the three things the cook does with each card, in order. And what must the cook change on the notepad before going back for the next card?

Show what happens

The cook takes the card, works out what it asks for, then does it. Before the next card, the notepad’s “next card number” goes up by one.

The CPU follows every program with the same routine, which is called the fetch-decode-execute cycle:

  • Fetch: copy the next instruction from memory into the CPU.
  • Decode: work out what the instruction asks for.
  • Execute: carry the instruction out.

Then the cycle starts again for the next instruction. A CPU repeats it many millions of times each second.

Stage: Discover

Fetch: getting the instruction

To follow the cycle, we need a program. The one below is invented for this lesson, with simple word-like instructions so that it can be read. A real program is a long list of binary patterns, and real CPUs use different instructions. It adds the numbers stored at addresses 20 and 21 and puts the answer in address 22.

AddressWhat is stored thereWhat it means
1LOAD 20Copy the contents of address 20 into the ACC
2ADD 21Add the contents of address 21 to the value in the ACC
3STORE 22Copy the value in the ACC into address 22
209Data
215Data
22(empty)Data

The program counter (PC) holds 1, the address of the first instruction. The ACC holds 0.

Think it through

Before the CPU can obey LOAD 20, it has to bring it from memory into the CPU. Using the registers and buses from the last lesson, which would you expect to be involved, and in what order?

Show a model answer

One possible order: the address in the PC goes to the MAR, and along the address bus to memory; memory finds the instruction and sends it along the data bus to the MDR; the instruction is copied to the CIR; and the PC is increased. The steps below follow exactly this order.

Fetching LOAD 20 from address 1

Each step names the part that acts. The fetch stage always has the same steps, whatever the instruction is.

  1. Program counter (PC)

    Step 1 of 6: The PC holds the address of the next instruction

    It holds 1, the address of the instruction LOAD 20.

  2. PC to MAR, then the address bus

    Step 2 of 6: The address is copied to the MAR

    The address 1 is copied from the PC to the MAR. From there it travels along the address bus to memory.

  3. Control unit and the control bus

    Step 3 of 6: A read signal is sent

    The control unit sends a “read” signal along the control bus, so memory knows to look up address 1 and send back what is stored there.

  4. Memory, the data bus and the MDR

    Step 4 of 6: The instruction arrives in the MDR

    The contents of address 1, the instruction LOAD 20, travel along the data bus and wait in the MDR.

  5. MDR to CIR

    Step 5 of 6: The instruction is copied to the CIR

    LOAD 20 is copied from the MDR to the CIR, ready to be decoded and executed.

  6. Program counter (PC)

    Step 6 of 6: The PC is increased by one

    The PC goes up from 1 to 2, so that it now holds the address of the next instruction.

    Technical detail: Some books put this step second, straight after the address is copied to the MAR. The result is the same, because the address is already safely in the MAR.

The instruction does not go from memory straight to the CIR. Everything that arrives from memory, instruction or data, comes through the MDR first. The MDR is a waiting place; the CIR is where the instruction is kept while it is obeyed.

Check your understanding

At the start of a fetch, the PC holds 2. What happens first?
Show the answer

Answer: C. The address 2 is copied from the PC to the MAR.

The fetch starts by copying the address in the PC to the MAR.

Stage: Discover

Decode: working out what it means

The CIR now holds LOAD 20. In memory, and in the CIR, the instruction is a pattern of bits, not words.

Think it through

The CIR holds the bits for LOAD 20. Before the computer can carry it out, what does the CPU need to work out, and which part of the CPU do you think does that?

Show what happens

It must work out what the instruction asks for: the operation (copy a value into the ACC) and the address it refers to (20). The part that directs the others is the control unit.

In the decode stage, the control unit works out what the instruction in the CIR asks for. An instruction has two parts: what to do (here, LOAD) and what to do it with (here, address 20). Once the control unit knows, it can send the signals that make the other parts carry the instruction out.

Check your understanding

Which statement describes what happens during decode?
Show the answer

Answer: D. The control unit works out what the instruction in the CIR asks for.

Decode: the control unit interprets the instruction held in the CIR.

Stage: Discover

Execute: carrying out LOAD 20

LOAD 20 means “copy the contents of address 20 into the ACC”. The value is in memory, so it must be fetched, like the instruction was.

Think it through

Which two registers do you expect the value from address 20 to pass through on its way to the ACC, and which register must first hold the address 20?

Show a model answer

The address 20 must be put in the MAR first. The value then arrives in the MDR, and is copied from there to the ACC.

Executing LOAD 20

The same buses are used as in the fetch, but this time what is fetched is data, not an instruction.

  1. Control unit

    Step 1 of 4: The address in the instruction goes to the MAR

    The control unit copies the address 20, which is part of the instruction in the CIR, into the MAR.

  2. Address bus and control bus

    Step 2 of 4: Memory is asked to read

    The address 20 travels along the address bus and a “read” signal along the control bus.

  3. Data bus and the MDR

    Step 3 of 4: The value arrives in the MDR

    The contents of address 20, which is 9, travel along the data bus and wait in the MDR.

  4. MDR to ACC

    Step 4 of 4: The value is copied to the ACC

    The control unit copies 9 from the MDR into the ACC. The ACC now holds 9, and LOAD 20 has been executed.

Stage: Predict

Execute: ADD and STORE

The PC now holds 2, so the cycle begins again and fetches ADD 21 in just the same way as before. Decoding finds that the instruction means “add the contents of address 21 to the value in the ACC”. The ACC already holds 9.

Think it through

Executing ADD 21 means adding the contents of address 21, which is 5, to the 9 in the ACC. Which part of the CPU does the addition, and where do you expect the answer to end up?

Show what happens

The ALU does the adding, and the answer ends up in the ACC.

ADD 21 is executed like LOAD, with one difference. The address 21 goes to the MAR and the value 5 arrives in the MDR. This time, instead of being copied to the ACC, it is passed to the ALU, which adds it to the 9 already in the ACC. The result, 14, is put back in the ACC.

STORE 22 works in the opposite direction. The address 22 goes to the MAR, and the value in the ACC is copied to the MDR. The control unit sends a “write” signal along the control bus, and the value travels from the MDR along the data bus into memory address 22.

Check your understanding

During STORE 22, which of these travels along the data bus?
Show the answer

Answer: B. The value being stored, 14, from the CPU to memory.

STORE sends the ACC’s value along the data bus into memory.

Stage: Experiment

Tracing the whole program

Now put the three instructions together. A trace table records what the registers hold after each stage. First, see how one row is worked out by reasoning.

At the start, the PC holds 1, the ACC holds 0, and the MAR, MDR and CIR hold nothing yet.

  1. Copy the PC to the MAR. The address of the next instruction is 1, so the MAR holds 1.
  2. Read from memory into the MDR. Address 1 holds LOAD 20, so the MDR holds LOAD 20.
  3. Copy the MDR to the CIR. The CIR holds LOAD 20, because the instruction must be kept while it is decoded and executed.
  4. Increase the PC. The PC goes from 1 to 2, so that the next fetch will find ADD 21.
  5. Leave alone what has not been used. The ACC is still 0: nothing has been executed yet.

Each row of the table is worked out by asking, for every register, whether it was used in this stage, and if it was, what went into it.

Complete the trace table for the program. The first two rows are done for you.
AfterPCMARMDRCIRACC
Start1emptyemptyempty0
Fetching LOAD 2021LOAD 20LOAD 200
Executing LOAD 202LOAD 20
Fetching ADD 219
Executing ADD 213ADD 21
Fetching STORE 22
Executing STORE 224STORE 2214

    Show the completed table
    AfterPCMARMDRCIRACC
    Start1emptyemptyempty0
    Fetching LOAD 2021LOAD 20LOAD 200
    Executing LOAD 202209LOAD 209
    Fetching ADD 2132ADD 21ADD 219
    Executing ADD 213215ADD 2114
    Fetching STORE 2243STORE 22STORE 2214
    Executing STORE 2242214STORE 2214

    Stage: Experiment

    Which bus carries it?

    Every transfer in the cycle uses one of the three buses. Use what the last steps showed.

    Which bus carries each of these? Type address, data or control.
    What is travellingBus
    The address 2, from the MAR towards memory
    The instruction ADD 21, from memory to the MDR
    A “read” signal from the control unit
    The value 14, from the CPU to memory in a STORE
    The address 22, for the STORE
    A “write” signal from the control unit

      Show the completed table
      What is travellingBus
      The address 2, from the MAR towards memoryaddress
      The instruction ADD 21, from memory to the MDRdata
      A “read” signal from the control unitcontrol
      The value 14, from the CPU to memory in a STOREdata
      The address 22, for the STOREaddress
      A “write” signal from the control unitcontrol

      Stage: Apply

      Using the cycle in new situations

      Apply it

      A fetch begins with the PC holding 40. What do the PC and the MAR hold when the fetch has finished?
      Show the answer

      Answer: A. PC: 41. MAR: 40.

      The PC points at the next instruction by the end of every fetch.

      Apply it

      Rae writes: “During a fetch, the MAR holds the instruction as it arrives from memory.” What is wrong with this?
      Show the answer

      Answer: B. The MAR holds the address sent to memory; the instruction arrives in the MDR.

      The MAR holds an address; the MDR holds what arrives.

      Apply it

      A different instruction, SUBTRACT 30, takes the value stored at address 30 away from the value in the ACC. Which path does the value from address 30 follow before the subtraction?
      Show the answer

      Answer: D. Memory, then the data bus, then the MDR, then the ALU.

      Values arrive from memory by the data bus into the MDR, and are passed on from there.

      Stage: Consolidate

      Show what you know

      Think it through

      In your own words, explain why the PC has to be increased during every fetch. What would happen if it were not?

      Show a model answer

      Because the PC holds the address of the next instruction. If it were not increased, the next fetch would find the same address and fetch the same instruction again, so the program would repeat one instruction and never reach the next one. (A jump instruction, which a later course covers, works by putting a different address in the PC on purpose.)

      Check your understanding

      Which list shows the correct order of the cycle’s stages for one instruction?
      Show the answer

      Answer: C. Fetch, then decode, then execute.

      Fetch, decode, execute: and then again.

      • The CPU repeats the fetch-decode-execute cycle for every instruction.
      • Fetch: the address in the PC is copied to the MAR and sent along the address bus; the control unit sends a read signal along the control bus; the instruction comes back along the data bus into the MDR, and is copied to the CIR; the PC is increased by one.
      • Decode: the control unit works out what the instruction in the CIR asks for.
      • Execute: the control unit directs the other parts. Data from memory arrives through the MAR and MDR; the ALU does any calculation, and results are held in the ACC.
      • The address bus carries addresses, the data bus carries data and instructions, and the control bus carries control signals.

      Sources and scope

      • What this lesson is. The second lesson of the Computer Systems module, written for this site. It teaches the fetch-decode-execute cycle as set out in Cambridge IGCSE Computer Science (0478) point 3.1.2(b) (2026 to 2028, version 6), building on Lesson 1. Its curriculum links are provisional and imply no endorsement by any examination board. It has not been approved by the site owner.
      • Original material. The school kitchen, and the three-instruction program with its addresses and values, are fictional and were written for this lesson. The names LOAD, ADD and STORE are used for readability; they are not the instructions of any real CPU.
      • Simplified on purpose. Real instructions are binary patterns; real CPUs differ in how they order the steps, and may overlap the stages of different instructions to save time. The PC is shown being increased at the end of the fetch, as many textbooks do. Jumps, interrupts and more registers are left to later courses.