Macros for ARM Porting (Compact 2013)

3/26/2014

Windows Embedded Compact 2013 provides a complete set of macros that you can use to help port your code. The PROLOG and EPILOG macros generate unwind code that enable an exception to be caught if an exception occurs in your function. The unwind code describes the operation of the prologue and epilogue such that the effects of a function’s prologue can be undone in preparation for backing up to the caller’s stack frame. Using the PROLOG and EPILOG macros ensures that the proper unwind code is generated for your function. These macros are located in the header files described in the following table.

%_WINCEROOT\Public\Common\Sdk\Inc\Kxarm.h
%_WINCEROOT\Public\Common\Sdk\Inc\Kxarmunw.h

Note that you should include only Kxarm.h as it, in turn, includes Kxarmunw.h.

Macro

Description

Example

EPILOG_NOP

Indicates that the instructions in the EPILOG area have nothing to do with exception handling unwinding and have no .pdata or .xdata information.

EPILOG_NOP bne Mylabel

EPILOG_POP

Restores the registers that were saved by using PROLOG_PUSH. Use in function epilogue code.

EPILOG_POP {r4, r5}

EPILOG_RETURN

Provides a BXLR-style return. Use at the end of function epilogue code.

EPILOG_RETURN

EPILOG_STACK_FREE

Deallocates space on the stack reserved by PROLOG_STACK_ALLOC. Use in function epilogue code.

EPILOG_STACK_FREE 16

EPILOG_VPOP

Restores floating-point registers that were saved by using PROLOG_VPUSH. Use in function epilogue code.

EPILOG_VPOP {d15}

LEAF_ENTRY

Declares the beginning of a leaf function. A leaf function does not call other functions.

LEAF_ENTRY

LEAF_END

Declares the end of a leaf function. A leaf function does not call other functions.

LEAF_END

NESTED_ENTRY

Declares the start of a nested function. Nested functions call other functions and have prologue, epilogue, and unwind code.

NESTED_ENTRY

NESTED_END

Declares the end of a nested function. Generates .pdata and .xdata records for all of the PROLOG_xxx and EPILOG_xxx macros used in the function.

NESTED_END

PROLOG_NOP

Indicates that the instructions in the PROLOG area have nothing to do with exception handling unwinding and have no .pdata or .xdata information.

PROLOG_NOP sub lr, lr, #4

PROLOG_PUSH

Saves one or more integers on the stack. Use in function prologue code.

PROLOG_PUSH {r4,r5}

PROLOG_STACK_ALLOC

Allocates space on the stack. Use in function prologue code.

PROLOG_STACK_ALLOC 16

PROLOG_VPUSH

Saves a floating-point register on the stack. Use in function prologue code.

PROLOG_VPUSH {d15}

RODATAAREA

Declares that the following code or data should be put into the .rdata segment. Use to include data or code in the .text (code) section, but without the LSB set. This inclusion is important for Thumb2 code that is stored in the .text section.

It is useful to put address tables in the .text section so that the linker will not treat the content of those tables as function pointers and turn on the LSB as a result. Because tables declare memory ranges, they do not require the LSB set.

The .rodata and .text sections are merged at build time

RODATAAREA

STARTUPTEXT

Declares the area that follows will be put in the .text (code) segment. This macro is typically used for first entry point functions; for example, the first call into the boot loader or OAL.

STARTUPTEXT

TEXTAREA

Declares the area that follows will be put in the .text (code) segment.

TEXTAREA

See Also

Concepts

Port an ARM BSP to Compact 2013