次の方法で共有


Renesas SH-4 Stack Frame Layout (Windows Embedded CE 6.0)

1/5/2010

The Renesas SuperH SH-4 stack frame layout uses four designated areas to hold register areas used by functions and space for variables.

  • The Register Save Area (RSA) holds the preserved values of any permanent registers used by the function. It also contains the function's return address.
  • The Locals and Temporaries area represents the stack space allocated for local variables and compiler-generated temporaries.
  • An alloca() locals area is dynamically allocated during function execution by the use of the alloca() intrinsic function. Compiler-generated code may also dynamically allocate space to manage the construction of outgoing arguments.
  • The Outgoing Arguments area must be large enough to hold all the arguments passed when calling another function, including all arguments passed in registers. This area may be dynamically allocated or extended prior to a call if the rules for alloca() are observed.

SH-4 Frame and Stack Pointers

The following list gives more information about stack and frame pointers:

  • The stack pointer and frame pointer addresses are aligned on 4-byte boundaries.
  • If a routine has alloca() locals, or dynamically allocates stack frame space for any other reason, a separate frame pointer register accesses 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.
  • By convention, a routine that establishes a separate frame pointer should use R14. However, a routine may establish another frame pointer to more efficiently access data in large stack frames. If a routine establishes no frame pointer, R15 must remain unchanged between the end of prolog and the beginning of the epilog.

See Also

Concepts

Renesas SH-4 Registers

Other Resources

Renesas SH-4 Calling Sequence Specification
Renesas SH-4 Prolog and Epilog