SH-4 Prolog (Windows Embedded CE 6.0)
1/5/2010
The SH-4 prolog contains four parts that are immediately contiguous with no intervening instructions. The following list shows the required parts.
A sequence of zero or more instructions that save the incoming argument values from R4 - R7 and FR4 - FR11 to the argument home locations.
This sequence typically uses the fmov instruction with R15 as the base address register. This sequence will not change the stack pointer, R15.
In addition, floating-point argument registers can be stored onto the stack using the fmov instruction with the register-indirect and register-indirect-pre-decrement addressing modes.
A sequence of one or more such fmov instructions may be preceded by a two-instruction address register setup sequence composed of a constant move to a general register, followed by an add of the sp to the register. For example:mov #36, r0 add sp, r0 fmov fr5, @r0 fmov fr4, @-r0
A sequence of zero or more instructions that push all permanent registers to be saved and the return address (PR), if it is to 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 to be 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.
The prolog also uses the fmov.s instruction to save floating-point registers, and may invoke double-precision and move-extension fmov instructions by first setting the SZ bit in the FPSCR.A sequence of one or more instructions that set up the frame pointer, if one is to be established.
To set up the frame pointer, the step 3 sequence first copies the contents of R15 to the frame pointer register, then adds or subtracts the amount of 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 later take the size of the decrement to R15 into account.
If the routine is not a leaf routine, the function must use a permanent register, typically R14, as the frame pointer.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 Virtual Unwinder considers the last instruction in this sequence the last instruction of the prolog.
If necessary, the temporary register R1 holds an offset too large to be represented in the immediate field of an add instruction.
See Also
Concepts
SH-4 Epilog
SH-4 Prolog and Epilog Examples