SH-4 Prolog and Epilog

The prolog contains the code that sets up the stack frame for a routine. The epilog contains the code that removes the routine's frame and then returns to the calling function.

The SH-3 prolog is a code segment that sets up the stack frame for a routine. The epilog removes the routine frame and returns from the routine.

To reconstruct the context that existed on entry to a routine, Structured Exception Handling (SEH) uses process called virtual unwinding to emulate a small subset of the instructions in prolog and epilog code. Starting with a context record and an instruction address, the unwinding process interprets instructions in the prolog or epilog to reconstruct the context, as it existed before the function call. The subset of prolog and epilog code that the Virtual Unwinder emulates includes:

  • Adding or subtracting a value from a register
  • Loading or storing a register on the stack frame
  • Loading integer constants into registers
  • Moving between integer registers
  • Copying the PR register to an integer register.

For sample prolog and epilog code, see SH-4 Prolog and Epilog Examples.

On the SH-4, the SZ, FR, and PR bits of the FPSCR must be zero on entering and exiting the prolog and epilog. The FR and PR bits may not be changed within the prolog or epilog. The SZ bit can be toggled within the prolog or epilog using the fschg instruction. With the SZ bit set, the prolog can use the fmov instruction to copy a double-precision register to or from the stack. The fmov instruction can also be used to copy floating-point registers to and from the extended floating-point bank.

See Also

SH-4 Calling Sequence Specification | SH-4 Registers | SH-4 Stack Frame Layout | SH-4 Parameter Passing | SH-4 Return Values | SH-4 pdata Format | SH-4 Assembler Macros | SH-4 Prolog | SH-4 Epilog | SH-4 Prolog and Epilog Examples

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.