This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question about Program counter

Note: This was originally posted on 1st October 2012 at http://forums.arm.com

[size=2]Hey[/size]

[size=2]Can someone please explain why instructions that modify the value of the PC (such as branches or [/size][size=2]mov pc, lr[/size][size=2]) requireadditional clock cycles to execute than those who don't operate on the PC. [/size]

[size=2]does branch link modify the value of PC or LR?[/size]

[size=2]
[/size]

[size=2]thanks [/size]

Parents
  • Note: This was originally posted on 1st October 2012 at http://forums.arm.com

    While branching, the program execution jumps to the sub-routine address and starts the execution from there. Hence, during branching the processor stores (PUSHes) the PC contents onto stack, i.e. it stores the address of the next instruction where it left the main code. This address is required during return form sub-routine so that the program execution continues from where it had branched.
    The program execution returns back to main program when it executes a RETurn instruction in the sub-routine program. When RETurn instruction is executed, the PC contents stored on the stack are POPed back onto PC and program execution begins. (This is the address of the main program from where the program execution had branched to sub-routine)


    Extra clock Cycles are required to PUSH the PC contents onto stack.
Reply
  • Note: This was originally posted on 1st October 2012 at http://forums.arm.com

    While branching, the program execution jumps to the sub-routine address and starts the execution from there. Hence, during branching the processor stores (PUSHes) the PC contents onto stack, i.e. it stores the address of the next instruction where it left the main code. This address is required during return form sub-routine so that the program execution continues from where it had branched.
    The program execution returns back to main program when it executes a RETurn instruction in the sub-routine program. When RETurn instruction is executed, the PC contents stored on the stack are POPed back onto PC and program execution begins. (This is the address of the main program from where the program execution had branched to sub-routine)


    Extra clock Cycles are required to PUSH the PC contents onto stack.
Children
No data