The program counter (PC), commonly called the instruction pointer (IP) in Intel x86 and Itanium microprocessors, and sometimes called the instruction address register (IAR) or just part of the instruction sequencer, is a processor register that indicates where a computer is in its program sequence.
In most processors, PC is incremented after fetching an instruction, and holds the memory address of (“points to”) the next instruction that would be executed. (In a processor where the incrementation precedes the fetch, PC points to the current instruction being executed.)
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), subroutine calls, and returns. A transfer that is conditional on the truth of some assertion lets the computer follow a different sequence under different conditions.
A branch provides that the next instruction is fetched from somewhere else in memory. A subroutine call not only branches but saves the preceding contents of PC somewhere. A return retrieves the saved contents of PC and places it back in PC, resuming sequential execution with the instruction following the subroutine call.
Read more about Program Counter: Hardware Implementation, Consequences in Machine Architecture, Consequences in High-level Programming
Famous quotes containing the words program and/or counter:
“President Lowell of Harvard appealed to students to prepare themselves for such services as the Governor may call upon them to render. Dean Greenough organized an emergency committee, and Coach Fisher was reported by the press as having declared, To hell with football if men are needed.”
—For the State of Massachusetts, U.S. public relief program (1935-1943)
“Id take the bus downtown with my mother, and the big thing was to sit at the counter and get an orange drink and a tuna sandwich on toast. I thought I was living large!... When I was at the Ritz with the publisher a few months ago, I did think, Oh my God, Im in the Ritz tearoom. ... The person who was so happy to sit at the Woolworths counter is now sitting at the Ritz, listening to the harp, and wondering what tea to order.... [ellipsis in source] Am I awake?”
—Connie Porter (b. 1959)