← Back to the lesson

How a processor runs one instruction

Fetch it, work out what it means, do it. Slowed down billions of times so you can watch one go round.

Interactive 3D processor and memory running one instruction, ADD 6, through fetch, decode, execute and write back

This is the text version. With JavaScript on, it’s a 3D drawing you can play, slow down and turn.

Step by step

  1. Fetch. The program counter says the next instruction is at address 1. The processor asks memory for it, and the instruction, ADD 6, comes back along the wires into the instruction register. Here each step takes one tick of the clock.
  2. Decode. The decoder, part of the control unit, works out what ADD 6 means: get the number at address 6 and add it to the working number. It sends signals to the ALU and the register so they’re ready.
  3. Execute: add. The third tick. The second bill, 19, comes in from address 6 and the working number, 34, comes out of the register. The ALU, the part that does the math, adds them: 53.
  4. Execute: save. Still in the third tick, the answer, 53, goes into the register and the program counter moves on to address 2. Then the loop starts again. At two billion ticks a second and three ticks an instruction, that’s about 670 million instructions a second.

From the lesson

How does a processor work through a program, one instruction at a time?

One at a time in a loop: fetch, decode, execute, next. Grandma Ruth’s grocery bills took five instructions and fifteen steps. Her laptop does about two billion steps a second, so when the graph says 12%, it’s waiting most of the time, not struggling.

Lesson 6.2: Fetch, Decode, Execute

More 3D drawings

All How Computers Work lessons · See it in 3D