Skip to content
Search

Program counter

lastmod 2018-03-13created 2018-03-131 edits

The program counter (PC) is one of the registers inside a microprocessor (central processing unit). It holds the address of the next instruction to be executed, specifying the location of the machine code to run. For this reason it is also called the instruction pointer. In Intel's x86-family CPUs it is called the IP (Instruction Pointer).

The program counter increments automatically with each instruction cycle so that instructions in memory can be executed sequentially. However, certain instructions such as branches or subroutine calls/returns put the location value of new machine code into the program counter, rather than the location of the code immediately following.

Most processors increment the instruction pointer right after fetching an instruction. In some cases, the address that is the target of a branch instruction is specified by that branch instruction's operand. If the instruction's operand is an absolute address, setting the operand value into the program counter jumps to that address.[1] Depending on the type of instruction, the operand may be specified relative to the current location; in that case the operand value is added to the current program counter value. In other words, depending on the instruction, the address of the next instruction to execute may be specified in the instruction's operand.

Favorite site