Prolog-Epilog Example (Windows Embedded CE 6.0)

1/5/2010

The following code example allocates a stack frame that requires 64 KB of memory for an SH-4 microprocessor. The code segment for an ARM or MIPS microprocessor is similar, except for the names of instructions and registers used.

The prolog segment in this example saves the argument register to the incoming argument save areas. No separate frame pointer is required. The segment then saves the return address, saves the permanent register, and allocates the stack frame. It declares an exception handler.

The epilog segment removes the stack frame and recovers the return address.

EXCEPTION_HANDLER RoutineHandler
NESTED_ENTRY Function
// Step 1.
//
mov.l R4, @R15   // Save argument to incoming argument save area.
mov.l R8, @-R15
sts.l PR, @-R15
mov.l @(0x0000001C,pc),r1 // Load constant -65528.
add     r1,r15      // Allocate stack frame.
mov.l R5, R8      // Save argument to register.

PROLOG_END

// Routine body

mov.l @(0x0000000C,pc),r1 // Load constant 65528.
add     r1,r15      // Remove stack frame.
lds.l @R15+, PR      // Recover return address.
rts
mov.l @R15+, R8     // Restore R8.

ENTRY_END Function

See Also

Concepts

SEH in RISC Environments