LOGBOOK

HELP

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.

A PC register holding 0x1000 points to a memory column of instructions at addresses 0x1000, 0x1004, 0x1008, 0x100C; after each execute the PC advances by 4 while branches overwrite it.

* 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:

  1. CPU reads the address from PC (e.g., 0x1000)
  2. Fetches the instruction at that address from memory
  3. Decodes and executes the instruction
  4. 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:

  • doc Program counter (Wikipedia) — how the PC/instruction-pointer holds the next-instruction address, auto-increments, and is rewritten by branches to control flow.

From Quiz: REVE1 / Overview of Computer Systems | Updated: Jul 07, 2026