Program counter

From Wikipedia, the free encyclopedia

The program counter, or shorter PC (also called the instruction pointer, part of the instruction sequencer in some computers) is a register in a computer processor which indicates where the computer is in its instruction sequence. Depending on the details of the particular machine, it holds either the address of the instruction being executed, or the address of the next instruction to be executed. The program counter is automatically incremented for each instruction cycle so that instructions are normally retrieved sequentially from memory. Certain instructions, such as branches and subroutine calls and returns, interrupt the sequence by placing a new value in the program counter.

In most processors, the instruction pointer is incremented immediately after fetching a program instruction; this means that the target address of a branch instruction is obtained by adding the branch instruction's operand to the address of the next instruction (byte or word, depending on the computer type) after the branch instruction. The address of the next instruction to be executed is always found in the instruction pointer.

The basic model (non von Neumann) of Reconfigurable Computing systems, however, uses data counters instead of a program counter.

Program Counters always point to the NEXT instruction or address to be executed. There are rare processors/occasions where it points to the current address being executed. The program counter was developed as a means for the programmer to keep track of where the processors next execution is, making it easier to debug programs. Some programmers reference to program counter as the data counter. Both terms are correct, however, the term program counter is more accurate because it points to the next address (Memory Location) to be executed where data is going to be altered or stored.

Some assembly language programmers use the "NOP" or "NOOP" meaning No Operation as a reference for an important address that the program counter points to. This is an old programming technique but is still used today by some programmers.

[edit] See Also