Custom Search

PC - Program Counter

The program counter (PC) is a processor register that indicates where a computer is in its program sequence.

In Intel x86 and Itanium microprocessors it is commonly called the instruction pointer (IP) or the instruction address register (IAR) or just part of the instruction sequencer.

In most processors, PC is incremented after fetching an instruction, and points to the memory address of the next instruction to be executed. But in a processor where the incrementation precedes the fetch, PC points to the current instruction being executed. In the MIPS Datapath stage 1 (Fetch) the increment of PC by +4 gives the next memory address.

Increment PC (that is, PC = PC + 4, to point to the next instruction: byte addressing so + 4)

Control transfer instructions

A transfer that is conditional on the truth of some assertion lets the computer follow a different sequence under different conditions. Instructions are usually fetched sequentially from memory, but control transfer instructions change the sequence by placing a new value in PC. These include:

      • branches (sometimes called jumps): a branch provides that the next instruction is fetched from somewhere else in memory.
      • subroutine calls: a subroutine call not only branches but saves the preceding contents of PC somewhere.and
      • returns: a return retrieves the saved contents of PC and places it back in PC, resuming sequential execution with the instruction following the subroutine call.