1 2 #define ENABLE_FRAME_POINTER 1 3 4 #undef TRUE 5 //#define TRUE 1 6 #undef FALSE 7 //#define FALSE 0 8 9 //#include "kxarmunw.h" 10 11 #ifdef _MSC_VER 12 13 /* Globals */ 14 GBLS __FuncStartLabel 15 GBLS __FuncEpilog1StartLabel 16 GBLS __FuncEpilog2StartLabel 17 GBLS __FuncEpilog3StartLabel 18 GBLS __FuncEpilog4StartLabel 19 GBLS __FuncXDataLabel 20 GBLS __FuncXDataPrologLabel 21 GBLS __FuncXDataEpilog1Label 22 GBLS __FuncXDataEpilog2Label 23 GBLS __FuncXDataEpilog3Label 24 GBLS __FuncXDataEpilog4Label 25 GBLS __FuncXDataEndLabel 26 GBLS __FuncEndLabel 27 GBLS __FuncArea 28 GBLS __FuncExceptionHandler 29 30 MACRO 31 __DeriveFunctionLabels $FuncName 32 __FuncStartLabel SETS "|$FuncName|" 33 __FuncEndLabel SETS "|$FuncName._end|" 34 __FuncEpilog1StartLabel SETS "|$FuncName._epilog1_start|" 35 __FuncEpilog2StartLabel SETS "|$FuncName._epilog2_start|" 36 __FuncEpilog3StartLabel SETS "|$FuncName._epilog3_start|" 37 __FuncEpilog4StartLabel SETS "|$FuncName._epilog4_start|" 38 __FuncXDataLabel SETS "|$FuncName._xdata|" 39 __FuncXDataPrologLabel SETS "|$FuncName._xdata_prolog|" 40 __FuncXDataEpilog1Label SETS "|$FuncName._xdata_epilog1|" 41 __FuncXDataEpilog2Label SETS "|$FuncName._xdata_epilog2|" 42 __FuncXDataEpilog3Label SETS "|$FuncName._xdata_epilog3|" 43 __FuncXDataEpilog4Label SETS "|$FuncName._xdata_epilog4|" 44 __FuncXDataEndLabel SETS "|$FuncName._xdata_end|" 45 MEND 46 47 MACRO 48 __ExportName $FuncName 49 LCLS Name 50 Name SETS "|$FuncName|" 51 ALIGN 4 52 EXPORT $Name 53 $Name 54 MEND 55 56 MACRO 57 __ExportProc $FuncName 58 LCLS Name 59 Name SETS "|$FuncName|" 60 ALIGN 4 61 EXPORT $Name 62 $Name PROC 63 MEND 64 65 MACRO 66 TEXTAREA 67 #if defined(_CONTROL_FLOW_GUARD) 68 AREA |.text|,ALIGN=4,CODE,READONLY 69 #else 70 AREA |.text|,ALIGN=2,CODE,READONLY 71 #endif 72 MEND 73 74 MACRO 75 DATAAREA 76 AREA |.data|,DATA 77 MEND 78 79 MACRO 80 RODATAAREA 81 AREA |.rdata|,DATA,READONLY 82 MEND 83 84 MACRO 85 NESTED_ENTRY $FuncName, $AreaName, $ExceptHandler 86 __DeriveFunctionLabels $FuncName 87 __FuncArea SETS "|.text|" 88 IF "$AreaName" != "" 89 __FuncArea SETS "$AreaName" 90 ENDIF 91 __FuncExceptionHandler SETS "" 92 IF "$ExceptHandler" != "" 93 __FuncExceptionHandler SETS "|$ExceptHandler|" 94 ENDIF 95 AREA $__FuncArea,CODE,READONLY 96 __ExportProc $FuncName 97 ROUT 98 // __ResetUnwindState 99 MEND 100 101 // FIXME: this does not exist in native 102 MACRO 103 PROLOG_END 104 /* Ignore for now */ 105 MEND 106 107 MACRO 108 NESTED_END $FuncName 109 $__FuncEndLabel 110 LTORG 111 ENDP 112 //AREA |.pdata|,ALIGN=2,READONLY 113 //DCD $__FuncStartLabel 114 //RELOC 2 115 //DCD $__FuncXDataLabel 116 //RELOC 2 117 //__EmitUnwindXData 118 //AREA $__FuncArea,CODE,READONLY 119 __FuncStartLabel SETS "" 120 __FuncEndLabel SETS "" 121 MEND 122 123 MACRO 124 LEAF_ENTRY $FuncName, $AreaName 125 NESTED_ENTRY $FuncName, $AreaName 126 MEND 127 128 MACRO 129 LEAF_END $FuncName 130 NESTED_END $FuncName 131 MEND 132 133 MACRO 134 LEAF_ENTRY_NO_PDATA $FuncName, $AreaName 135 __DeriveFunctionLabels $FuncName 136 __FuncArea SETS "|.text|" 137 IF "$AreaName" != "" 138 __FuncArea SETS "$AreaName" 139 ENDIF 140 AREA $__FuncArea,CODE,READONLY 141 __ExportProc $FuncName 142 ROUT 143 MEND 144 145 MACRO 146 LEAF_END_NO_PDATA $FuncName 147 $__FuncEndLabel 148 LTORG 149 ENDP 150 __FuncStartLabel SETS "" 151 __FuncEndLabel SETS "" 152 MEND 153 154 MACRO 155 ALTERNATE_ENTRY $FuncName 156 __ExportName $FuncName 157 ROUT 158 MEND 159 160 161 #define CR 13 162 #define LF 10 163 #define NUL 0 164 165 #define ASCII dcb 166 167 MACRO 168 UNIMPLEMENTED $Name 169 MEND 170 171 #else 172 173 /* Compatibility define */ 174 #define EQU .equ 175 176 .macro IMPORT Name 177 /* Ignore */ 178 .endm 179 180 .macro EXPORT Name 181 .global &Name 182 .endm 183 184 .macro TEXTAREA 185 .section .text, "rx" 186 #if defined(_CONTROL_FLOW_GUARD) 187 .align 4 188 #else 189 .align 2 190 #endif 191 .endm 192 193 .macro DATAAREA 194 .section .data, "rw" 195 .endm 196 197 .macro RODATAAREA 198 .section .rdata, "rw" 199 .endm 200 201 .macro NESTED_ENTRY Name 202 FuncName .equ &Name 203 PrologName .equ &Name&_Prolog 204 FuncEndName .equ &Name&_end 205 .global &FuncName 206 .align 2 207 .func &FuncName 208 &FuncName: 209 .endm 210 211 // FIXME: should go to kxarmunw.h 212 .macro PROLOG_END 213 \PrologName: 214 .endm 215 216 .macro NESTED_END Name 217 &FuncEndName: 218 .endfunc 219 .endm 220 221 .macro LEAF_ENTRY $FuncName, $AreaName 222 NESTED_ENTRY $FuncName, $AreaName 223 .endm 224 225 .macro LEAF_END $FuncName 226 NESTED_END $FuncName 227 .endm 228 229 230 /* Some "intrinsics", see http://codemachine.com/article_armasm.html */ 231 232 .macro __debugbreak 233 DCD 0xDEFE 234 .endm 235 236 .macro __assertfail 237 DCD 0xDEFC 238 .endm 239 240 .macro __fastfail 241 DCD 0xDEFB 242 .endm 243 244 .macro __rdpmccntr64 245 DCD 0xDEFA 246 .endm 247 248 .macro __debugservice 249 DCD 0xDEFD 250 .endm 251 252 .macro __brkdiv0 253 DCD 0xDEF9 254 .endm 255 256 257 #endif 258 259 260