Html/Javascript widget

Monday 29 August 2016

Program counter

The program counter (PC), or the instruction pointer (IP) in Intel x86 microprocessors, and on occasion called the instruction address register (IAR), is a processor register that indicates where a computer is in its program sequence. Its role is similar to that of a GPS in that it points the direction the computer is at in its program sequence. Actually, it's not the whole computer's direction, only the instruction being executed in the processor. A register is a kind of memory that stays closest to the processor and is directly accessed by it for quick access. Not the most powerful for storage means, but the fastest ofthem all, even faster than cache memory, RAM and secondary memory ( memory used for storing personal files like an HDD, flash memory etc.

In most architectures, the program counter is incremented after fetching an instruction. It means that it's called counter it's actually made of an accumulation function. It's also worth remembering that a typical processor works instructions in the same fetch, execute, decode, execute cycle and the very first step prompts the program counter to start incrementing. After being being incremented it holds the memory address of the next instruction to be executed. The act of holding a memory address is known as pointing to the next instruction. Instructions are under normal circumstances fetched following a predictable order. This pattern can be altered if the control transfer instruction inserts a new value in the PC. It's like if you're the teacher calling the roll and a new value in the program counter causes you to skip over some students' names. In the processor, what may cause these skips are branches (sees to it that the next instruction is fetched from somewhere else in the memory), subroutine calls (saves the contents of the PC elsewhere) and returns (retrieves the saved contents (thanks for the subroutine calls) and puts it back in the PC, resuming normal operation).

No comments:

Post a Comment