main: .... .... bl A // Call leaf function A .... .... Stop: /* =============================== Leaf function =============================== */ A: .... .... mov pc, lr |
|
Schematically:
main:
....
pass parameters here
bl A // Call leaf function A
....
....
Stop:
/* ===============================
Leaf function
=============================== */
A:
....
....
mov pc, lr
|
|
Schematically:
main:
....
pass parameters here
bl A // Call leaf function A
....
....
Stop:
/* ===============================
Leaf function
=============================== */
A:
....
....
store return value in register here
mov pc, lr
|
|
Schematically:
main:
....
pass parameters here
bl A // Call leaf function A
use the return value here
....
....
Stop:
/* ===============================
Leaf function
=============================== */
A:
....
....
store return value in register here
mov pc, lr
|
|
Example:
main: mov r0, #1111 // Pass 1111 as parameter 1 in r0 mov r1, #2222 // Pass 2222 as parameter 2 in r1 bl A // Call leaf function A // When A returns, you will see the return value in r0 = 9999 nop nop Stop: nop /* =============================== Leaf function =============================== */ A: // When run in EGTAPI - you will see r0 = 1111 and r1 = 2222 nop nop mov r0, #9999 // Pass return value in register r0 mov pc, lr |
How to run the program:
|