Syntax and meaning (= effect) of the branch-and-link instruction:
bl label Effect: (1) Save the return address (= location) into the Link Register (LR) (2) Branch to memory location marked by the label "label" |
Situation before the execution of the bl label instruction:
Syntax and meaning (= effect) of the branch-and-link instruction:
bl label Effect: (1) Save the return address (= location) into the Link Register (LR) (2) Branch to memory location marked by the label "label" |
Situation after the execution of the bl label instruction:
Initial state: the CPU fetches the bl 4000 (= label) instruction at address 44:
Note: the return address = 48 because each ARM instruction is 4 bytes long.
The CPU sends the READ command on the system bus:
The memory returns the bl 4000 instruction to the CPU:
The bl 4000 instruction is stored in the Instruction Register:
The Program Counter is incremented:
Notice that the Program Counter contains the return address !!!
State of the CPU when it executes the bl 4000 instruction:
The bl instruction simulataneously updates: LR = PC and PC = 4000:
Result of executing bl 4000 (= label):
|
Illsutrating the effects of the bl instruction:
main:
mov r0, #1111
mov r1, #1111
bl myMethod
mov r2, #2222
mov r3, #2222
myMethod:
mov r8, #4444
mov r9, #4444
|
DEMO: /home/cs255001/demo/asm/8-sub/bl.s
(Next slide give you hints on what to look out for)
Illsutrating the effects of the bl instruction:
main:
mov r0, #1111
mov r1, #1111
bl myMethod
mov r2, #2222
mov r3, #2222
myMethod:
mov r8, #4444
mov r9, #4444
|
When the CPU executes bl myMethod, look for:
|