CS core subjects

Stage 1 · Lesson 4 of 7

The fetch, decode, execute cycle

How a computer runs a program

A runs a program by repeating one loop: , also called the instruction cycle. First it fetches the next instruction from memory. The address of that instruction sits in a special register called the program counter.

Then it decodes the instruction, working out what it means. Then it executes it, and moves on to the next one unless a jump says to go somewhere else. Instructions are very simple: load a value from memory into a register, add two registers, compare two values, jump.

Your if statements, loops and function calls all compile down to these few kinds of steps. Reading a little , the readable form of these instructions, from a compiler makes this concrete. This matters for the next topics.

How fast memory responds decides how fast this loop runs. The decides which program the loop is running.

Common trapthinking a single line of code is a single instruction.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

Keep handy

  • A topic map of the whole CS curriculum to check your coverage against, stage by stage

  • Short explanations from researchers when one idea, such as floating point, will not click

Also worth your time

Mark this stage as not done?