Program Counter

A program is a sequence of instructions stored in ROM. But how does the processor know which instruction to execute next? This is the job of the Program Counter (PC) — a special register that always holds the address of the next instruction to fetch.

The PC works like a finger following text on a page. After executing instruction at address N, the PC increments to N+1 (or N+2, or N+4, depending on instruction length) and points to the next instruction. The processor reads from ROM at the address the PC specifies, decodes the opcode, executes it, and the cycle repeats.

The PC is more than just a counter. Jump and branch instructions can overwrite it with an arbitrary address. When the processor executes JMP 42, it doesn't just "go to line 42" — it loads the value 42 directly into the Program Counter. On the next fetch cycle, the processor obediently reads from ROM address 42.

Practical example. Here's the PC in action for a simple program at ROM addresses 0-6: PC=0, fetch ADD instruction; PC increments to 1, execute ADD; PC=1, fetch STA instruction; PC increments to 2, execute STA; PC=2, fetch JMP 0; PC would normally increment to 3, but JMP 0 overwrites PC to 0. Next cycle: PC=0 again — the program loops forever. The PC is the pulse of the processor; wherever it points, execution follows.