The Instruction Cycle

02 Mins

The processor doesn’t see loops, if-statements, or functions it just sees binary instructions, one at a time. The instruction cycle is the fundamental loop the CPU follows to process those instructions.

fetch-decode-execute


Instruction Cycle Architecture

instruction-cycle

This diagram illustrates how the CPU components interact during the instruction cycle.


The 3 Main Steps

Fetch

  • The Program Counter (PC) holds the address of the next instruction.
  • The CPU sends that address to memory via the address bus and fetches the instruction into the Instruction Register (IR) via the data bus.

Decode

  • The Control Unit decodes the binary instruction (e.g., ADD? JUMP?).
  • It figures out what needs to happen, like which registers to use or whether memory should be read or written.

Execute

The appropriate parts of the CPU are activated:

  • The ALU may perform a calculation.
  • A value may be loaded from memory or stored.
  • The Program Counter is updated to point to the next instruction or updated with a new address during control-flow operations like JUMP or CALL.

Note - This cycle repeats billions of times per second on a modern CPU.


Example of Instruction Cycle

Lets say CPU has to execute the following assembly instruction

ADD R1, R2, R3;

By know you already know the 3 steps Fetch, Decode and Execute instruction-cycle-overview

If you want to look deeper, below diagram explain it best.

instruction-cycle-example-in-depth

  • Fetch: PC sends the instruction’s address to memory; the binary code is loaded into IR.
  • Decode: Control Unit interprets it as ADD, with R2 and R3 as sources and R1 as destination.
  • Execute: ALU adds values from R2 and R3, stores the result in R1, and PC moves to the next instruction.

Program Counter and Flow Control

Normally, the Program Counter increments sequentially, moving to the next instruction. However, control-flow instructions like JUMP or CALL modify it directly. This enables loops, conditional execution, and function calls (the foundation of structured programming)


Timing and Clock Cycles

Each stage of the instruction cycle is tied to clock pulses:

  • Simple instructions may complete in 1–2 cycles.
  • Complex operations (like memory access or multiplication) may take more.
  • Modern CPUs use pipelining, overlapping stages so multiple instructions are in different phases simultaneously. This dramatically improves throughput.

Conclusion

The instruction cycle is the heartbeat of the CPU. Every program you run is broken down into these fetch-decode-execute steps, repeated at incredible speed. By mastering this cycle, you understand how high-level code translates into the raw operations that drive modern computing.