The Stage Is Set
In Reading 1, you saw how a program travels from secondary storage into RAM before it can run. Once that transfer is complete, the CPU takes over. Secondary storage steps aside. From this point on, everything happens between RAM and the CPU.
The program's instructions are sitting in RAM, waiting in sequence. The CPU's job is to work through them — one at a time, in order — by repeating a simple three-step loop:
- Fetch — retrieve the next instruction from RAM
- Decode — figure out what that instruction means
- Execute — carry it out
This loop is called the Fetch-Decode-Execute (FDE) cycle. It is the heartbeat of every digital device — laptops, phones, tablets, classroom Chromebooks. Modern CPUs run through this cycle billions of times per second.
In this reading, the goal is not to memorize every component inside a CPU. The goal is to understand what is moving at each stage: where data comes from, where it goes, and why each step is necessary.
The Key Players
Before walking through the cycle, it helps to know who does what. The CPU contains several components that each play a specific role in moving instructions and data around.
The Program Counter (PC)
The Program Counter is a small register that holds one thing: the memory address of the next instruction. Think of it as a bookmark. At any moment, the PC is pointing at the next line of the program waiting to be fetched. After each fetch, the PC automatically advances to point at the following instruction.
The Instruction Register (IR)
The Instruction Register is where a fetched instruction lands after it is pulled from RAM. It holds the instruction while the CPU figures out what it means and carries it out. Once the cycle moves on to the next instruction, the IR is overwritten with whatever comes next.
The Control Unit (CU)
The Control Unit reads whatever is in the IR and interprets it. It is the part of the CPU that asks, "what are we supposed to do here, and what needs to move where?" The CU does not do calculations itself — it directs the other components to do their jobs.
General-Purpose Registers
Registers are tiny, extremely fast storage locations inside the CPU. They are not RAM — they are even closer to the action. Before the CPU can operate on a value, that value usually needs to be loaded from RAM into a register. Think of registers as the CPU's scratch pad: small, fast, and temporary.
The Arithmetic Logic Unit (ALU)
The ALU is the part of the CPU that performs calculations: addition, subtraction, comparison, and basic logical operations. The ALU does not decide what to calculate — it simply performs whatever operation the Control Unit has set it up to do, using the values currently sitting in registers.
The key insight: The CPU cannot operate on data that is still sitting in RAM. Values must be copied into registers first. This is why the movement of data — from RAM into registers and back — is the central story of the FDE cycle.
Step 1 — Fetch
The cycle begins with the CPU looking at the Program Counter. Whatever address the PC holds, the CPU reaches into RAM at that address and retrieves the instruction stored there.
That instruction is copied into the Instruction Register. At the same time, the PC is updated — it now points to the next instruction in RAM, ready for the following cycle.
Notice what moved: an instruction traveled from RAM → Instruction Register. The program counter advanced. Nothing has been calculated yet. Nothing has changed in the program's data. The CPU simply knows what it is supposed to do next.
Analogy: Imagine you are cooking from a recipe. The Program Counter is your finger keeping your place. Fetching is reading that line and keeping it in your head while you work. The recipe itself (in RAM) has not changed — you just retrieved one line from it.
Step 2 — Decode
With an instruction now sitting in the IR, the Control Unit goes to work. It examines the instruction and answers two questions:
- What operation is being requested? (load a value, add two numbers, store a result, jump to a different instruction, etc.)
- What data is involved? (which memory addresses or registers does this instruction refer to?)
The CU does not execute the instruction yet — it prepares everything. It figures out which components need to be involved and what data will need to move.
Back to the recipe analogy: decoding is understanding the line you just read. You realize it says "fold in the egg whites" — you know what that means, you know which bowl to reach for, and you are ready to act. You have not done it yet. You are prepared.
Step 3 — Execute
Now the actual work happens. Depending on what the instruction calls for, execution might involve any of the following kinds of data movement:
Loading data from RAM into a register
A value stored at a RAM address is copied into one of the CPU's registers, making it
available for computation. The value in RAM does not disappear — it is copied.
Data moves: RAM → Register
Performing a calculation
The values currently in two registers are sent to the ALU, which performs the requested
operation (addition, subtraction, comparison, etc.) and places the result into a register.
Data moves: Register → ALU → Register
Storing a result back to RAM
A value in a register is written back to a specific address in RAM. This is how computed results
become part of the program's data, available for later instructions to use.
Data moves: Register → RAM
Changing the Program Counter (branching)
Some instructions do not move data at all — they change which instruction comes next by updating the PC to a different address. This is how programs make decisions and loop back on
themselves.
Data moves: (new address) → Program Counter
When execution is complete, the cycle starts over. The CPU looks at the PC, fetches the next instruction, and the loop continues — billions of times per second.
Common Instructions You Will Encounter
Real CPUs understand hundreds of different instructions, but a small set covers the vast majority of what programs actually do. The table below introduces the instructions used in this course. Each one triggers a specific pattern of data movement during the Execute stage.
| Instruction | What It Does | Data Movement |
|---|---|---|
LOAD Rx, Addr |
Copies a value from a RAM address into a register | RAM → Register |
STORE Rx, Addr |
Copies a value from a register into a RAM address | Register → RAM |
MOVE Rx, Ry |
Copies a value from one register into another | Register → Register |
ADD Rx, Ry, Rz |
Adds the values in two registers, puts the result in a third | Registers → ALU → Register |
SUB Rx, Ry, Rz |
Subtracts one register value from another, puts the result in a third | Registers → ALU → Register |
MULT Rx, Ry, Rz |
Multiplies the values in two registers, puts the result in a third | Registers → ALU → Register |
DIV Rx, Ry, Rz |
Divides one register value by another, puts the result in a third | Registers → ALU → Register |
This is a simplified instruction set. Real CPUs use hundreds of instructions with precise rules about data types and addressing modes. This set captures the essential patterns — moving data in, computing, moving data out — without the complexity of a real architecture. Everything you need for this course is in the table above.
The Cycle as a Whole
Stepping back, the FDE cycle is simply a disciplined system for moving information from one place to another in a carefully controlled order. Instructions flow from RAM into the CPU. Data flows from RAM into registers, through the ALU, and back to RAM. The Program Counter keeps everything moving in sequence.
Top row: data flow. Bottom row: instruction flow. Both originate in RAM.
Notice that all roads lead back to RAM. Instructions come from RAM. Data comes from RAM. Results go back to RAM. The CPU's registers and ALU are powerful but tiny — they hold only what is needed for the current operation. RAM is where the full program and its data live between operations.
Why This Matters
Understanding the FDE cycle gives you a concrete mental model for what a computer is actually doing when it runs any program — whether that program is displaying a webpage, playing music, checking spelling, or running a simulation.
At the hardware level, all of that complexity reduces to the same thing: fetch an instruction from RAM, decode it, move some data, repeat. The sophistication comes from doing this billions of times per second, not from any single step being complicated.
In the next reading, you will trace the FDE cycle through a short, concrete example — following specific values as they move from RAM into registers, through the ALU, and back again. That trace will make the abstract cycle feel tangible and followable.
Connecting this to our metaphor
Fetch: The Teacher looks at the Magnet (Program Counter) on the board to see which step they are on, then reads that specific line from the Photocopy (RAM).
Decode: The Teacher (Control Unit) thinks: "Okay, this line says we need to add two numbers."
Execute: The Teacher asks a Student (ALU) to do the math at the board.