r4-r11 - protected
@ttfn thanks for your detailed reply. Actually what I am unable to understand is that we have two groups of registers r0-r3 and r4-r11. I know that r0-r3 can be used for passing parameters while the remaining cann't. I am passing 4 arguments to the function foo called by main as in your example. Inside function foo I am doing some calculations which involve r0-r6. after return I want to have the same values in all registers as they were before calling foo. Do I need to push r4-r6 on stack before calling foo and then pop them back after return to have the same register values or it will be done automatically as they are called preserved registers. I have seen in the stack window that r0-r3 are pushed to stack, when they are used as parameters.I hope you got my point.
Do I need to push r4-r6 on stack before calling foo and then pop them back after return to have
I have seen in the stack window that r0-r3 are pushed to stack, when they are used as parameters.
main ... BL foo ...foo ... BX lr