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


    ...why instructions that modify the value of the PC (such as branches or mov pc, lr) require additional clock cycles to execute than those who don't operate on the PC.

    Fetching instructions from memory takes time; this is normally hidden by pipelining the fetch underneath normal instruction execution, but [on simpler processors at least] relies on assuming that the program counter will only increment sequentially. If a branch (or other PC modifying instruction) is executed, then this assumption will be incorrect, and the processor will have to go and restart fetching instructions from memory at the new PC address - thus causing these instructions to take more time than other data processing.


    does branch link modify the value of PC or LR?

    Branch with link updates both the LR to point to the instruction after the BL instruction, and the PC to the target of the BL.

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


    ...why instructions that modify the value of the PC (such as branches or mov pc, lr) require additional clock cycles to execute than those who don't operate on the PC.

    Fetching instructions from memory takes time; this is normally hidden by pipelining the fetch underneath normal instruction execution, but [on simpler processors at least] relies on assuming that the program counter will only increment sequentially. If a branch (or other PC modifying instruction) is executed, then this assumption will be incorrect, and the processor will have to go and restart fetching instructions from memory at the new PC address - thus causing these instructions to take more time than other data processing.


    does branch link modify the value of PC or LR?

    Branch with link updates both the LR to point to the instruction after the BL instruction, and the PC to the target of the BL.

    hth
    s.
Children
No data