[arm-gnu] Why is R3 pushed/popped on function entry/exit (Cortex-M3)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[arm-gnu] Why is R3 pushed/popped on function entry/exit (Cortex-M3)?
- To: arm-gnu@xxxxxxxxxxxxxxxx
- Subject: [arm-gnu] Why is R3 pushed/popped on function entry/exit (Cortex-M3)?
- From: Andrew Sterian <steriana@xxxxxxxxx>
- Date: Wed, 19 May 2010 15:43:54 -0400
Can someone help me understand why R3 takes part in the PUSH/POP
instructions for this:
--------------<test.c>-----------------
extern int func(int i);
int test(int i)
{
return func(i)+5;
}
--------------<test.c>-----------------
Compiled with (2010q1 release G++ Lite):
arm-none-eabi-gcc -Wall -march=armv7-m -mcpu=cortex-m3 -mthumb
-mfix-cortex-m3-ldrd -Os -S test.c
Result:
--------------<test.s>-----------------
push {r3, lr}
bl func
adds r0, r0, #5
pop {r3, pc}
--------------<test.s>-----------------
My understanding from the ARM Procedure Call Standard is that only R4
upwards need to be saved in a function call. Why wouldn't it be enough
to just PUSH/POP the LR?
Thanks,
--
Andrew Sterian