Procedure Calling Convention
Posted: Fri May 03, 2024 1:44 am
The ARM Architecture Procedure Call Standard (AAPCS) stipulates that, upon calling a procedure
1) registers r0 to r3, and r12, are "caller saved", ie. the called procedure is free to mutate them.
2) registers r4 to r11 are "callee saved", ie. the called procedure must save and restore these registers in case it mutates them.
Parameters are passed via r0 to r3, and the stack if needed.
The Astrobe compiler saves all register before calling a procedure, ie. all registers are "caller saved", and passes all parameters in registers.[1]
Just out of interest: is there a rule or convention, explicit or tacit, regarding this behaviour for Oberon programs?
[1] Exception handlers behave like the above standard regarding register saving and restoring, based on the exception handler implementation in the Cortex-M MCUs (stacking of r0 to r3 and r12).
1) registers r0 to r3, and r12, are "caller saved", ie. the called procedure is free to mutate them.
2) registers r4 to r11 are "callee saved", ie. the called procedure must save and restore these registers in case it mutates them.
Parameters are passed via r0 to r3, and the stack if needed.
The Astrobe compiler saves all register before calling a procedure, ie. all registers are "caller saved", and passes all parameters in registers.[1]
Just out of interest: is there a rule or convention, explicit or tacit, regarding this behaviour for Oberon programs?
[1] Exception handlers behave like the above standard regarding register saving and restoring, based on the exception handler implementation in the Cortex-M MCUs (stacking of r0 to r3 and r12).