|
public static void main(String[] args) { A( ); } public static void A( ) { ... B( ); // Calls B( ) ... } public static void B( ) { ... // Does not call any method/function ... } |
Although B( ) is a leaf method, we can use the non-leaf method implementation:
main: mov r0, #4 mov r1, #4 bl A mov r2, #4 mov r3, #4 Stop: A: push {lr} // Save return address mov r0, #44 mov r1, #44 bl B // Overwrites lr, it's OK, we saved it !!! mov r2, #44 mov r3, #44 pop {pc} // A returns to main !!! B: push {lr} // Save return address mov r0, #4444 mov r1, #4444 pop {pc} // B returns to A !!! |
How to run the program:
|