We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
PUSH {r4,lr} ;// Preserve return address (r4 also pushed to maintain SP alignment)
Caller: ..... PUSH {r0-r3,r12,lr} ;// preserve r0-r3, r12 and return address BL Callee POP {r0-r3,r12,lr} ;// restore r0-r3, r12 and return address ...Callee: PUSH {r4-r11,lr} ;// preserve r4-r11 and return address ... POP {r4-r11,pc} ;// restore r4-r11 and return back to Caller
int Caller (int a) { return Callee(a + 1); }int Callee (int { return b + 2; }
Caller: PUSH {r4,lr} ;// Preserve return address (r4 also pushed to maintain SP alignment) ADD r0,r0,#1 ;// Operand "a" was passed in R0, and "Callee" expects "b" to arrive in R0. BL Callee ;// Call "Callee", expect result to be returned in R0. POP {r4,pc} ;// Return to whoever called "Caller" (also restore r4 to maintain SP alignment)Callee: ADD r0,r0,#3 ;// "b" arrives in R0, result should be returned in R0 BX lr ;// Haven't modified anything that needed preserving, so return to "Caller"