Quiz Entry - updated: 2026.07.07
What is the Program Counter (PC) and why is it essential?
A register holding the address of the next instruction to fetch — the CPU's "bookmark" in the program.
* The Program Counter bookmarks the address of the current instruction and advances to the next after each step. *
Every step of execution revolves around it: the CPU fetches whatever the PC points to, runs it, then updates the PC. That means all control flow — loops, branches, function calls and returns — is ultimately just the program changing the value in the PC.
How it works:
- CPU reads the address from PC (e.g.,
0x1000) - Fetches the instruction at that address from memory
- Decodes and executes the instruction
- Updates PC to point to the next instruction
PC updates:
- Sequential execution: PC += size of current instruction (1-15 bytes on x86)
- Jump/branch: PC = target address (for loops, if-statements, function calls)
- Function call: PC = function address (old PC saved for return)
- Return: PC = saved address (pop from stack)
Why it's essential:
- Without the PC, the CPU wouldn't know where to fetch the next instruction
- It's the CPU's "bookmark" in the program
- Control flow (if, while, for, function calls) is just manipulating the PC!
Other names: Instruction Pointer (IP) on x86, sometimes called "rip" (64-bit) or "eip" (32-bit).
Go deeper:
Program counter (Wikipedia) — how the PC/instruction-pointer holds the next-instruction address, auto-increments, and is rewritten by branches to control flow.