What Happens in Each Stage of the Fetch-Execute Cycle?
Learn what happens during fetch, decode and execute, including how the PC, MAR, MDR and CIR help the CPU run each instruction in GCSE Computer Science.
The fetch-execute cycle is the repeated process the CPU uses to run a program: it fetches an instruction from memory, decodes what the instruction means, then executes it. The cycle repeats for the next instruction.
Fetch
The program counter (PC) holds the memory address of the next instruction. The CPU copies that address into the memory address register (MAR), which identifies the memory location to read. The instruction at that location is copied from memory into the memory data register (MDR), then into the current instruction register (CIR).
The PC is updated so it normally points to the following instruction. An address tells the CPU where to read; the instruction is the data it reads from that address.
Decode
The control unit examines the instruction in the CIR to work out what operation is required. It also identifies any data or memory address the operation needs. For example, the instruction might tell the CPU to add two values or store a value in memory.
Execute
The CPU carries out the decoded instruction. An addition, for example, is performed by the arithmetic logic unit (ALU), the part of the CPU that does calculations and logical operations. Other instructions might move data between registers and memory. A branch instruction can change the PC so the CPU fetches an instruction from a different address next time.
For example, suppose the PC contains address 404040, and that address holds an instruction to add two values. During fetch, the CPU reads that instruction into the CIR and updates the PC. During decode, it recognises an addition. During execute, the ALU adds the values. The CPU then begins another cycle.
Exam mistake to avoid: fetch, decode and execute are not three separate instructions. They are stages the CPU goes through for each instruction. Also, the PC stores an address, not the instruction itself.