Share via


ARM Prolog (Windows Embedded CE 6.0)

1/5/2010

The ARM prolog has three constituent parts. All parts are immediately contiguous, with no intervening instructions. When the prolog follows this guideline, the Virtual Unwinder can reverse-execute the prolog.

The following list shows the three required parts of an ARM prolog.

  1. A sequence of zero or one instructions that push the incoming argument values from R0, R1, R2, and R3 to the argument home locations, and updates R13 to the new stack top.
    This sequence saves all permanent registers in descending order at the top of the stack frame, following any saved argument registers.
  2. A sequence of one or more instructions that set up the frame pointer, if one is to be established.
    The prolog copies stack pointer R13 to R12 before the initial register saves and uses R12 to compute the value of the frame pointer, R11.
  3. 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 R13.
    If an offset is too wide to represent in the immediate field, the prolog uses the scratch register R12 to hold the offset. In this case, it sets the value in R12 with a different instruction.

Examples

The following examples show how to construct several ARM prologs.

  • ARM Prolog with frame in R11.

    MOV    r12, r13        ; Save stack on entry if needed.
    STMDB  r13!, {r0-r3}    ; As needed
    STMDB  r13!, {r4-r12, r14}  ; As needed
    SUB    r11, r12, #16    ; Sets frame past args
    <stack link if needed>
    
  • ARM Prolog with no frame.

    MOV    r12, r13
    STMDB  r13!, {r0-r3}        ; As needed
    STMDB  r13! {[r4-r12,]|[r13,]r14}  ; As needed
    <stack link if needed>
    <note: r12 is not used if the stack (r13) is the first register saved>
    

See Also

Concepts

SEH in RISC Environments
ARM Epilog

Other Resources

ARM Prolog and Epilog