Computing Library › Digital Logic & Circuits
Digital Logic & Circuits

Program Counter

The program counter is the register that holds the address of the next instruction, advancing each cycle and redirected by branches.

What it does

The program counter, or PC, is a register in the CPU that holds the memory address of the next instruction to fetch. After each fetch it advances to point at the following instruction, so the processor moves through the program in order unless told otherwise.

Incrementing

Kronos motion — next scientists

In the normal case the PC increases by the size of one instruction each cycle. This is done by a dedicated adder or a counter: the current PC plus the instruction length becomes the next PC, loaded on the clock edge.

Branches and jumps

Control-flow instructions override the increment. A jump loads a new address into the PC; a conditional branch loads the target address only if a tested condition holds, otherwise the PC increments normally. A multiplexer selects between the incremented value and the branch target.

Calls and returns

A subroutine call saves the current PC so execution can resume after the call, then loads the subroutine's address. A return restores the saved PC. The saved value is kept in a register or on a stack in memory.

Role in the cycle

The PC drives the fetch step of the fetch-decode-execute cycle. Its steady advance and occasional redirection are what make a stored program run as a sequence with branches and loops.