Partager via


MIPS Epilog (Windows Embedded CE 6.0)

1/5/2010

While each procedure has only one prolog, a procedure may contain any number of epilogs if the procedure uses multiple exit points. Each epilog is required to have certain specific parts. All parts are contiguous with no intervening instructions.

The following steps shows how to restore the registers saved by the called function for a MIPS ISA. For MIPS IV, replace the lw instruction with ld.

Note that MIPS16 epilogs employ slightly different guidelines to restore the registers saved by the called function.

  1. Issue a restore for each register saved in the prologue

    lw $31, framesize+frameoffset($29)      ; restore return addresslw reg, framesize+frameoffset-N($29)    ; restore integer register
    ldc1 reg, framesize+frameoffset-N($29)  ; restore float register
    

    Where N is four and incremented by four for each subsequent lower number register saved.

  2. Return from the procedure.

    j $31
    
  3. End the routine.

    .end routine_name
    

    The minimum proper epilog for a leaf routine includes the return jump and the .end. Additionally, for a nonleaf routine, loading register $31 is required.

    jr scratch
    

See Also

Reference

MIPS Assembler Macros

Other Resources

MIPS Prolog and Epilog