THUMB Prolog (Windows CE 5.0)

Send Feedback

A THUMB prolog has the following specific parts. All parts are immediately contiguous with no intervening instructions.

  • A sequence of zero or one instructions that push the incoming argument values in R0, R1, R2, and R3 to the argument home locations, and updates R13 to the new stack top.

    If the function does not use high registers such as R8, R9, R10, and R11, a sequence of instructions pushes R4-R7 or the link register R14 to the stack.

    The function does not push the link register if the routine is a leaf with no high registers saved.

  • 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 an aligned offset from R13.

  • A single instruction that sets the frame pointer if one is to be established.

    Immediately after it links the stack, the function copies the value of the stack pointer in R13 to R7.

Example

The following examples show a variety of THUMB prologs.

  • THUMB Prolog with no frame.

    PUSH    {r0-r3}    ; As needed
    PUSH    {r4-r7, LR}  ; As needed
    SUB    SP, SP, #4  ; Stack link (as needed)
    
  • THUMB Prolog with frame in R7.

    PUSH    {r0-r3}      ; As needed
    PUSH    {r4-r7, LR}    ; As needed
    SUB    SP, SP, #4    ; Stack link (as needed)
    MOV    r7, SP      ; Set frame
    
  • THUMB Prolog with interworking return.

    PUSH    {r4-r7, LR}
    
  • THUMB Prolog saving high registers.

    PUSH    {r0-r3}      ; Save r0-r3 as needed
    PUSH    {LR}
    BL    __savegpr_9    ; Routine for saving {r4-r11}
    SUB    SP, SP, #4    ; Stack link (as needed)
    
  • THUMB Prolog with a large stack frame.

    PUSH    {r7}  
    LDR    r7, [PC, #20]
    NEG    r7, r7
    ADD    SP, r7
    

See Also

SEH in RISC Environments | THUMB Epilog

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.