Skip to content
KinPilot™Learn & Explore
Menu

Grades 6–8 · Computing

How does a CPU carry out an instruction?

A processor runs a program by carrying out instructions encoded as bits. An instruction might tell it to add two values, copy a value or choose a different next instruction. The processor does not understand the meaning of a story or game as a person does. Its circuits respond to these precise encodings.

D44 visual explanationA toy CPU fetches the instruction at word address 40, decodes add, executes with A=7 and B=3, and writes 10 into register R. The next sequential instruction has toy word address 41. The highlighted conceptual stage is write back. Actual encodings, byte addresses, branches, pipeline timing and cache behavior are omitted.A CPU follows encoded instructionsOne invented instruction • A = 7 and B = 31 Fetch at address 40ADD R ← A, B2 DecodeSelect the operation3 ExecuteALU: 7 + 3 = 104 Write backRegister R receives 10Next: address 41Instruction bits select work; data bits supply values.Conceptual stages • real CPUs can overlap instructions

In the diagramA CPU follows encoded instructionsOne invented instruction • A = 7 and B = 31 Fetch at address 40ADD R ← A, B2 DecodeSelect the operation3 ExecuteALU: 7 + 3 = 104 Write backRegister R receives 10Next: address 41Instruction bits select work; data bits supply values.Conceptual stages • real CPUs can overlap instructions

Follow one instruction from stored encoding to a register result; the four boxes show conceptual jobs rather than measured clock cycles.

An instruction address identifies where to fetch the next instruction. Control circuitry decodes the fetched bits, selecting the operation and the places that supply data. Small, fast storage locations called registers hold values close to the working circuits. An arithmetic logic unit, or ALU, performs operations such as addition.

In the invented example, registers A and B contain 7 and 3. An ADD instruction selects those inputs, produces 10 and writes that result into register R. SUBTRACT instead produces 4; COPY places the value 3 into R. The same starting data can therefore lead to different results because the instruction selects different work.

The processor then continues with another instruction. The drawing numbers consecutive toy instruction locations 40 and 41; actual machines use their own address rules. Modern processors can overlap many instructions, but fetching, decoding, executing and recording results remain useful jobs to distinguish.

About this explanation

Starting knowledge: Understand stored numbers, arithmetic operations and that bits can encode instructions.

Sources

  • Arm — What is a Central Processing Unit?
  • Arm — ARM Cortex-R Series Programmer’s Guide: Registers
← Grades 6–8 topics