SH-3 Stack Frame Layout
The following illustration shows the stack frame layout.
The following list gives more information about the stack frame layout.
- The Register Save Area holds the preserved values of any permanent registers used by the function. It also contains the function return address.
- The Locals and Temporaries area represents the stack space allocated for local variables and compiler-generated temporaries.
- If a routine establishes no frame pointer, R15 must remain unchanged between the end of prolog and the beginning of the epilog.
- The stack pointer and frame pointer addresses are aligned on 4-byte boundaries.
- If a routine has alloca() locals, the SH-3 Specification requires a separate frame pointer register to access incoming arguments and locals. A leaf routine may use any free integer register as the frame pointer. A non-leaf routine must use a permanent register. The routine must not modify the frame pointer register between the prolog and epilog.
- A routine that uses alloca() references everything a lower address than the alloca() area relative to R15, and never contains a defined value at the time of an alloca() call. Thus, the alloca() operation never has to copy this part of the stack frame, and no data relocation problems arise. The routine references everything at a higher address than the alloca() area relative to the frame pointer.
- To more efficiently access data in large stack frames, a routine may establish another frame pointer. A frame pointer helps mitigate problems with the limited size of the bit-field that specifies register-displacement-addressing offset. The frame pointer typically points to a fixed frame offset in the RSA or Local and Temporaries areas of the stack frame, but may point to other offsets within the frame.
By convention, a routine that establishes a separate frame pointer should use R14. - Non-leaf functions must allocate a four-word argument build area starting at the location pointed to by R15 in the stack frame, regardless of the number of arguments actually passed in calls from the function. A called function may use this area for any purpose.
- A leaf routine need not set up a stack frame for itself unless it needs to save permanent registers or allocate space for locals. If a leaf routine does require a stack frame, it need not allocate stack space for outgoing arguments. If you use asynchronously invoked functions, such as signal and interrupt handlers, remember that not all frames include unused argument space.
See Also
SH-3 Calling Sequence Specification | SH-3 Registers | SH-3 Parameter Passing | SH-3 Return Values | SH-3 Prolog and Epilog | SH-3 Assembler Macros | SH-3 pdata Format
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.