RTEMS Logo

RTEMS 4.6.4 On-Line Library


Calling Conventions Call and Return Mechanism

PREV UP NEXT Bookshelf RTEMS PowerPC Applications Supplement

2.3: Call and Return Mechanism

The PowerPC architecture supports a simple yet effective call and return mechanism. A subroutine is invoked via the "branch and link" (bl) and "brank and link absolute" (bla) instructions. This instructions place the return address in the Link Register (LR). The callee returns to the caller by executing a "branch unconditional to the link register" (blr) instruction. Thus the callee returns to the caller via a jump to the return address which is stored in the LR.

The previous contents of the LR are not automatically saved by either the bl or bla. It is the responsibility of the callee to save the contents of the LR before invoking another subroutine. If the callee invokes another subroutine, it must restore the LR before executing the blr instruction to return to the caller.

It is important to note that the PowerPC subroutine call and return mechanism does not automatically save and restore any registers.

The LR may be accessed as special purpose register 8 (SPR8) using the "move from special register" (mfspr) and "move to special register" (mtspr) instructions.


PREV UP NEXT Bookshelf RTEMS PowerPC Applications Supplement

Copyright © 1988-2004 OAR Corporation