You are not logged in

Log in into our community

Log in so you acess some hidden content

* Fields are required.

Register into our community!

Sign up now for some good content

* Fields are required.

Lost something?

Enter your username or email to reset your password.

* Fields are required.

Program Counter

Posted on : Sun , 09 2014 by : virusi

Theory on program counter :


The program counter (PC), commonly called the instruction pointer (IP) and sometimes called the instruction address register is a processor register that indicates where a computer is in its program sequence. In most processors, the 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, the PC points to the current instruction being executed.). For RISC computers updating the PC register is as simple as adding the machine word length (in bytes) to the PC. In a CISC machine, however, the length of the current instruction needs to be calculated, and that length value needs to be added to the PC.

Instructions are usually fetched sequentially from memory, but control transfer instructions change the sequence by placing a new value in the 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 the PC somewhere. A return retrieves the saved contents of the PC and places it back in the PC, resuming sequential execution with the instruction following the subroutine call. The number of bits (the width of the PC) relates to the processor architecture. For instance, a “32-bit” CPU may use 32 bits to be able to address
\left \large 2^{32}
units of memory. If the PC is a binary counter, it may increment when a pulse is applied to its COUNT UP input, or the CPU may compute some other value and load it into the PC by a pulse to its LOAD input.

LPC1768 PRACTICAL EXAMPLE :


CoreRegister
Fig. 1 Core Register

From the Fig.1 you can see that the Program Counter is contained in the Core Register. The Program Counter(PC) is register R15. On reset, the processor loads the PC with the value of the reset vector, which is at address 0x00000004.

The Program Status Register(PSR) combines:

– Application Program Status Register(APSR).

– Interrupt Program Status Register(IPSR).

– Execution Program Status Register(EPSR).

For an extended explanation of each bit in the Program Counter Register you can consult the datasheet of the LPC1768 microcontroller at section Section 34.3.1.3.4.

Last updated on Sun , 09 2014
SHARE THIS PAGE :

This page is waiting for your comment.

Share and Leave a comment.

You must be logged in to post a comment.

Back to Top