SH-3 Prolog

The SH-3 prolog contains four parts that are immediately contiguous with no intervening instructions. The following list shows the four parts, listed in order of execution:

  1. A sequence of zero or more instructions to save the incoming argument values in R4, R5, R6, and R7 to the argument home locations. These instructions typically use the mov-to-register-displacement instruction with R15 as the base address register. These instructions or mov register-to-register instructions that save incoming argument values to permanent registers may appear just before the end of the prolog, after part 4. This sequence does not change the stack pointer, R15.
  2. A sequence of zero or more instructions that pushes all permanent registers that should be saved, and the PR if it should be saved, onto the stack, using the pre-decrement indirect register addressing mode with R15 as the address register. If a permanent register such as R14 is used as the frame pointer, it is pushed first. If the PR is to be saved, it is pushed last. The prolog uses mov.l instructions to save registers other than the return address, and the sts.l instruction to save the return address.
  3. A sequence of one or more instructions that set up the frame pointer, if one is to be established. The following list shows the ways a prolog may establish a frame pointer:
    • Copy R15 to the frame pointer register, and add or subtract the offset to the frame pointer address from the frame pointer register. If the frame pointer address is less than the current value in R15, the prolog subtracts the offset to the frame pointer address from R15, and copies R15 to the frame pointer register. If this method is used, the routine must take the size of the decrement to R15 into account in part 4.
    • If the routine is not a leaf routine, the function must use a permanent register, typically R14, as the frame pointer. Otherwise, a temporary register may be used.
  4. A sequence of zero or more instructions that allocate the remaining stack frame space for local variables, compiler-generated temporaries, and the argument build area by subtracting a 4-byte aligned offset from R15.

The VirtualUnwinder considers the last instruction in this sequence the last instruction of the prolog.

The mov immediate-to-register, mov register-to-register, add immediate-to-register, add register-to-register, and sub register-to-register instructions may be used in part 3 and part 4. The temporary register R1 is typically used to hold an offset too large to be represented in the immediate field of an add instruction.

See Also

SH-3 Calling Sequence Specification | SH-3 Prolog and Epilog | SH-3 Epilog | SH-3 Prolog and Epilog Examples

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.