Sharing notes from my ongoing learning journey — what I build, break and understand along the way.
Instruction Cycle Explained: Fetch, Decode, Execute, Store in Simple Terms
Inside the CPU: The 4 Steps of the Instruction Cycle
As I continue learning how computers work at their core, one fundamental concept I’ve come across is the Instruction Cycle, also known as the Fetch–Decode–Execute–Store (FDES) cycle.
This cycle is the heartbeat of any CPU — it’s the repetitive process that allows a computer to read and carry out instructions, millions or even billions of times per second.
In this post, I’ll walk through each step in detail, break down how it works, and give you relatable analogies to make it stick.
What Is the Instruction Cycle?
The Instruction Cycle is the process by which a CPU retrieves a machine-level instruction from memory, understands it, performs the required operation, and saves the result.
It happens in 4 main steps:
- Fetch
- Decode
- Execute
- Store
This cycle happens for every single instruction a computer executes — whether it’s adding numbers, drawing pixels, reading a file, or running a program.
1. Fetch – Get the Instruction
The CPU begins by fetching the next instruction from main memory (RAM).
- It uses a special register called the Program Counter (PC) which keeps track of the address of the next instruction.
- The instruction at that memory address is copied into the Instruction Register (IR).
2. Decode – Understand What to Do
Once the instruction is in the Instruction Register, the CPU must decode it.
- The Control Unit reads the binary opcode and figures out:
- What operation to perform (e.g., ADD, LOAD, JUMP)
- What registers or memory locations are involved
3. Execute – Perform the Action
The CPU now executes the decoded instruction.
- If it’s an arithmetic instruction, the ALU (Arithmetic Logic Unit) performs the operation.
- If it’s a memory instruction, it may load or store data.
- If it’s a control instruction, it may change the Program Counter.
4. Store – Save the Result
Finally, if the instruction produces a result, the CPU stores it:
- Either in a register
- Or in RAM
- Or it may update the status flags (e.g., zero, carry)
And Then It Repeats…
After storing the result, the CPU goes back to fetch the next instruction — as directed by the Program Counter (which usually moves to the next address, unless a jump or branch occurs).
This loop repeats millions to billions of times per second depending on the CPU’s clock speed.
Real-World Example: Add Two Numbers
Let’s say a program wants to add 5 + 3
and store the result in memory.
Here’s what the instruction cycle would look like (simplified):
- Fetch:
Load instructionADD R1, R2, R3
from memory - Decode:
CPU sees this means: Add contents ofR2
andR3
, store result inR1
- Execute:
R2 = 5, R3 = 3 → ALU adds → result = 8 - Store:
Result (8) is stored in R1
Then the cycle starts over for the next instruction.
Where This Happens Physically
Component | Role in the Cycle |
---|---|
Program Counter | Tracks next instruction address |
Instruction Register | Holds current instruction |
Control Unit | Decodes instructions |
ALU | Performs arithmetic/logic |
Memory Bus | Transfers data from/to RAM |
Registers | Store temporary values |