Specialty Digest

Global English editionLearners’ Study Dashboard — in development
The Knowledge Library for All

Online Courses / University Track / Computing Foundations

Module 7 · Lesson 3 · Core

Running instructions: fetch, decode, execute

Trace a short program on an invented toy machine, step by step, using the fetch, decode and execute cycle.

  • 50 minutes
  • Serves O7
  • Assumes M7.L2

Phase 1: Prepare

Step 1 Warm-up recall

From M7.L2: 3,000 MB equals how many GB (decimal)?

Private: nothing you type here is sent or stored.

Step 2 Learning goal

By the end of this lesson you can:

  • describe the fetch, decode, execute cycle (Foundation);
  • trace a toy-machine program (Core);
  • write a short program for a calculation (Core).

Phase 2: Teach

Step 3 A familiar example

A recipe is followed one line at a time. The cook reads a line, understands it and does it, then reads the next. A processor does exactly this, billions of times a second on modern machines.

Step 4 Clear explanation

A program is a list of instructions stored in memory. The processor repeats a cycle for each one.

Fetchnext instructionDecodewhat to doExecutedo it, then repeat
The fetch, decode and execute cycle repeats for every instruction.

To see this at work, use an invented toy machine. It has one working register, the accumulator, and four instructions.

Instruction (invented toy machine)Effect
LOAD nPut the number n into the accumulator (the working register)
ADD nAdd n to the accumulator
SUB nSubtract n from the accumulator
STORE aCopy the accumulator into memory address a

Trace the program LOAD 5, ADD 3, STORE 0, LOAD 2, ADD 9.

StepInstructionAccumulator afterMemory after
1LOAD 55empty
2ADD 38empty
3STORE 08address 0 holds 8
4LOAD 22address 0 holds 8
5ADD 911address 0 holds 8

Each row is one pass of the cycle. After step 3 the value 8 has been copied to memory address 0 and stays there; the accumulator is then overwritten. Real processors have many more instructions and registers, and they use binary codes, but they follow the same pattern. This is why a program that is correct in a high-level programming language is translated into many such small steps. The entry on Alan Turing describes the early theory behind this idea of a machine that follows stored instructions.

Step 5 Worked example (4 marks)

Trace LOAD 10, SUB 4, ADD 7, STORE 2 on the toy machine.

  1. LOAD 10: accumulator is 10. (1 mark)
  2. SUB 4: accumulator is 6. (1 mark)
  3. ADD 7: accumulator is 13. (1 mark)
  4. STORE 2: address 2 holds 13. (1 mark)

Phase 3: Practise

Step 6 Learner practice (instant-marked)

1. The cycle for each instruction is:

2. On the toy machine, LOAD 6 then ADD 4 leaves the accumulator at:

3. STORE 3 does what?

4. LOAD 9, SUB 2, STORE 0 leaves address 0 holding:

Phase 4: Close

Step 7 Recap

  • The processor fetches, decodes and executes in a loop.
  • The accumulator holds the working value.
  • STORE copies it to memory.

Step 8 Exit ticket (ungraded)

Trace LOAD 3, ADD 4, STORE 1, LOAD 1 and give the accumulator.

Private: nothing you type here is sent or stored.

Step 9 Go further (Extension)

Read the entry on Alan Turing and note what a stored program is.

Common mistakes

MistakeWhy it fails
Forgetting that LOAD replaces the accumulatorLOAD overwrites the old value.
Thinking STORE empties the accumulatorIt copies; the accumulator is unchanged.
Skipping a step in the traceWrite one row per instruction.

Limits. The toy machine is invented and far simpler than a real processor.