Program counter
A program counter (PC) is a register that stores where a computer program is being executed by a processor. It is also commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR), the instruction counter, or just part of the instruction sequencer.
Usually, a PC stores the memory address of an instruction. Further, it usually is incremented after fetching an instruction, and therefore points to the next instruction to be executed. For a processor that increments before fetch, the PC points to the instruction being executed. In some processors, the PC points some distance beyond the current instruction. For instance, in the ARM7, the value of PC visible to the programmer reflects instruction prefetching and reads as the address of the current instruction plus 8 in ARM State, or plus 4 in Thumb State. For modern processors, the location of execution in the program is complicated by instruction-level parallelism and out-of-order execution.
By default, a processor fetches instructions sequentially from memory, but a control transfer instruction changes the sequence by writing a value in the PC. A branch allows the next instruction to be fetched from elsewhere in memory. A function call not only branches but saves the value of the PC. A return restores the value of the PC to resume execution with the instruction following the call by branching to the saved value. A transfer that is conditional on the truth of some condition lets the computer follow a different sequence under different conditions.