I try to figure out the structure of the stack frame for exception handlers (STM32F207 target, or M3 in general, I guess). The programming manual explains the "stacking", but is not specific regarding the order the listed items are put on the stack: R0-R3, return address, PSR, LR. Based on the code in Traps.mod, the return address is accessed at SP +36, with the local variable, hence it would be +32 without a local integer (hope it's OK to quote that much):
Code: Select all
PROCEDURE NMITrap;
VAR
trapAddr: INTEGER;
BEGIN
SYSTEM.GET(SYSTEM.SP + 36, trapAddr);
...
However, "stacking" puts only 7 x 4 bytes on the stack by my count. What do I miss? Is it an alignment issue? The manual mentions that the SP is aligned to a double-word address after the stacking if so configured.
Is it correct that the return address is at the top of the stack frame (which would be consistent with "normal" procedure calls, where the LR is saved there, if I am not mistaken).