The fetch-execute cycle

The basic operation of a computer is called the ‘fetch-execute’ cycle. The CPU is designed to understand a set of instructions - the instruction set. It fetches the instructions from the main memory and executes them. This is done repeatedly from when the computer is booted up to when it is shut down.

  1. The CPU fetches the instructions one at a time from the main memory into the registers. One register is the program counter (pc). The pc holds the memory address of the next instruction to be fetched from main memory.
  2. The CPU decodes the instruction.
  3. The CPU executes the instruction.
  4. Repeat until there are no more instructions.

A single piece of program code might require several instructions. Look at this Python (3.x) code:

area = length * width

First, the computer needs to load in the value of the variable length into the immediate access store (registers). Next it needs to load in the value of the variable width. Then it needs to multiply the two numbers together, and finally it needs to store the result in the variable area.

Move on to Test