The Fetch Stage
What You'll Learn
You'll learn how the CPU retrieves the next instruction from memory so it can be executed.
The Core Idea
The fetch stage is the first step of the instruction cycle where the CPU grabs the next instruction from memory. Think of it like a chef reading the next step in a recipe—before you can cook anything, you need to know what the recipe says to do next.
Here's what happens during the fetch stage:
-
The Program Counter (PC) points the way: The PC holds the memory address of the next instruction to execute. It's like a bookmark that tells the CPU exactly where to look.
-
Read from memory: The CPU sends the address stored in the PC to memory via the Memory Address Register (MAR). Memory responds by placing the instruction at that address into the Memory Data Register (MDR).
-
Load into the Instruction Register: The fetched instruction is copied from the MDR into the Instruction Register (IR), where it waits to be decoded and executed.
-
Update the Program Counter: The PC is incremented to point to the next instruction in sequence (usually PC = PC + instruction size). This prepares the CPU for the next fetch cycle.
Why This Matters
Without the fetch stage, the CPU would have no way to systematically retrieve instructions. The PC acts as the guide, the registers serve as temporary holding spots, and the fetch operation ensures instructions flow smoothly from memory into the CPU's processing pipeline.
Key Takeaway: The fetch stage uses the program counter to retrieve the next instruction from memory and load it into the instruction register, preparing it for decoding and execution.