Introduction to ARM
A Call Chain
- Routine A branches with link (
BL) to routine B. This saves its return address, the address of the next instruction, into R14 and then jumps to the routine B’s first instruction. - Routine B is going to call another subroutine, routine C. Were it to
immediately call routine C using
BLthen its existing stored R14 would be overwritten. So it stores its R14 to the stack to preserve it. - It
BL’s to routine C. (R14 ← return address, PC ← Routine C). - Routine C does its work, then returns using
MOV pc,r14. Its return value is passed back in R0. R1 is corrupted. (R0..R3 are allowed to be corrupted in AAPCS). - We return to Routine B after the
BLinstruction. - It restores R14 from the stack.
- A return is effected and we end up at the instruction after the
original
BL.
Routine C does not call any subroutines; it is known as a leaf routine. Leaf routines can dispense with the overhead of storing their return address on the stack.


