Register Convention

1) r0-r3 are scratch registers, so functions don't need to save their context.
2) r0-r3 are used to store parameters. first parameter in r0, second parameter in r1…
3) when there is no parameter, arm assembler usually do not push r0-r3 into stack, because they are scratch registers.
4) when there are parameters, r0-r3 may probably be pushed into stack for latter usage.

<Ex>
PUSH {r0-r12,lr} ;r0 & r3 are parameter 1 to parameter 4
……
……
ADD sp,sp,#0x10 ;stack pointer += 16 => discard r0-r3 in the stack
POP {r4-r12,pc} ;pop r4-r12; lr to pc => return from procedure

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License