| 1 | /* Capstone Disassembler Engine */cxx . . $ `<file>/tests/test_m680x.c`/ |
| 2 | /* M680X Backend by Wolfgang Schwotzer <[email protected]> 2017 */ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | |
| 7 | #include <capstone/platform.h>cxx . . $ `<file>/include/capstone/platform.h`/ |
| 8 | #include <capstone/capstone.h>cxx . . $ `<file>/include/capstone/capstone.h`/ |
| 9 | |
| 10 | #define WITH_DETAILScxx . . $ `tests/test_m680x.c:10:9`! |
| 11 | |
| 12 | struct platformcxx . . $ platform# { |
| 13 | cs_archcxx . . $ cs_arch# archcxx . . $ platform#arch.; |
| 14 | cs_modecxx . . $ cs_mode# modecxx . . $ platform#mode.; |
| 15 | unsigned char *codecxx . . $ platform#code.; |
| 16 | size_t sizecxx . . $ platform#size.; |
| 17 | const char *commentcxx . . $ platform#comment.; |
| 18 | }; |
| 19 | |
| 20 | static void print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).(const char *comment, unsigned char *str, size_t len) |
| 21 | { |
| 22 | unsigned char *c; |
| 23 | |
| 24 | printfcxx . . $ printf(581fddd72a8db8fc).("%s", comment); |
| 25 | |
| 26 | for (c = str; c < str + len; c++) |
| 27 | printfcxx . . $ printf(581fddd72a8db8fc).("0x%02x ", *c & 0xff); |
| 28 | |
| 29 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 30 | } |
| 31 | |
| 32 | static void print_string_hex_shortcxx . . $ print_string_hex_short(6165b45f45ef689c).(unsigned char *str, size_t len) |
| 33 | { |
| 34 | unsigned char *c; |
| 35 | |
| 36 | for (c = str; c < str + len; c++) |
| 37 | printfcxx . . $ printf(581fddd72a8db8fc).("%02x", *c & 0xff); |
| 38 | } |
| 39 | |
| 40 | static const char *s_accesscxx . . $ s_access.[] = { |
| 41 | "UNCHANGED", "READ", "WRITE", "READ | WRITE", |
| 42 | }; |
| 43 | |
| 44 | static void print_read_write_regscxx . . $ print_read_write_regs(429ed0f42458107e).(cshcxx . . $ csh# handle, cs_detailcxx . . $ cs_detail# *detail) |
| 45 | { |
| 46 | int i; |
| 47 | |
| 48 | if (detail->regs_read_countcxx . . $ cs_detail#regs_read_count. > 0) { |
| 49 | printfcxx . . $ printf(581fddd72a8db8fc).("\tRegisters read:"); |
| 50 | |
| 51 | for (i = 0; i < detail->regs_read_countcxx . . $ cs_detail#regs_read_count.; ++i) |
| 52 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", |
| 53 | cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, detail->regs_readcxx . . $ cs_detail#regs_read.[i])); |
| 54 | |
| 55 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 56 | } |
| 57 | |
| 58 | if (detail->regs_write_countcxx . . $ cs_detail#regs_write_count. > 0) { |
| 59 | printfcxx . . $ printf(581fddd72a8db8fc).("\tRegisters modified:"); |
| 60 | |
| 61 | for (i = 0; i < detail->regs_write_countcxx . . $ cs_detail#regs_write_count.; ++i) |
| 62 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s", |
| 63 | cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, detail->regs_writecxx . . $ cs_detail#regs_write.[i])); |
| 64 | |
| 65 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | static void print_insn_detailcxx . . $ print_insn_detail(2888c3e5b0984e8d).(cshcxx . . $ csh# handle, cs_insncxx . . $ cs_insn# *insn) |
| 70 | { |
| 71 | cs_detailcxx . . $ cs_detail# *detail = insn->detailcxx . . $ cs_insn#detail.; |
| 72 | cs_m680xcxx . . $ cs_m680x# *m680x = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 73 | int i; |
| 74 | |
| 75 | // detail can be NULL on "data" instruction if SKIPDATA option is turned ON |
| 76 | if (detail == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 77 | return; |
| 78 | |
| 79 | m680x = &detail->m680xcxx . . $ cs_detail#$anonymous_type_0#m680x.; |
| 80 | |
| 81 | if (m680x->op_countcxx . . $ cs_m680x#op_count.) |
| 82 | printfcxx . . $ printf(581fddd72a8db8fc).("\top_count: %u\n", m680x->op_countcxx . . $ cs_m680x#op_count.); |
| 83 | |
| 84 | for (i = 0; i < m680x->op_countcxx . . $ cs_m680x#op_count.; i++) { |
| 85 | cs_m680x_opcxx . . $ cs_m680x_op# *op = &(m680x->operandscxx . . $ cs_m680x#operands.[i]); |
| 86 | const char *comment; |
| 87 | |
| 88 | switch ((int)op->typecxx . . $ cs_m680x_op#type.) { |
| 89 | default: |
| 90 | break; |
| 91 | |
| 92 | case M680X_OP_REGISTERcxx . . $ M680X_OP_REGISTER.: |
| 93 | comment = ""; |
| 94 | |
| 95 | if ((i == 0 && (m680x->flagscxx . . $ cs_m680x#flags. & |
| 96 | M680X_FIRST_OP_IN_MNEMcxx . . $ `include/capstone/m680x.h:159:9`!)) || |
| 97 | ((i == 1 && (m680x->flagscxx . . $ cs_m680x#flags. & |
| 98 | M680X_SECOND_OP_IN_MNEMcxx . . $ `include/capstone/m680x.h:162:9`!)))) |
| 99 | comment = " (in mnemonic)"; |
| 100 | |
| 101 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: REGISTER = %s%s\n", i, |
| 102 | cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->regcxx . . $ cs_m680x_op#$anonymous_type_0#reg.), comment); |
| 103 | break; |
| 104 | |
| 105 | case M680X_OP_CONSTANTcxx . . $ M680X_OP_CONSTANT.: |
| 106 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: CONSTANT = %u\n", i, |
| 107 | op->const_valcxx . . $ cs_m680x_op#$anonymous_type_0#const_val.); |
| 108 | break; |
| 109 | |
| 110 | case M680X_OP_IMMEDIATEcxx . . $ M680X_OP_IMMEDIATE.: |
| 111 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: IMMEDIATE = #%d\n", i, |
| 112 | op->immcxx . . $ cs_m680x_op#$anonymous_type_0#imm.); |
| 113 | break; |
| 114 | |
| 115 | case M680X_OP_DIRECTcxx . . $ M680X_OP_DIRECT.: |
| 116 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: DIRECT = 0x%02x\n", i, |
| 117 | op->direct_addrcxx . . $ cs_m680x_op#$anonymous_type_0#direct_addr.); |
| 118 | break; |
| 119 | |
| 120 | case M680X_OP_EXTENDEDcxx . . $ M680X_OP_EXTENDED.: |
| 121 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: EXTENDED %s = 0x%04x\n", |
| 122 | i, op->extcxx . . $ cs_m680x_op#$anonymous_type_0#ext..indirectcxx . . $ m680x_op_ext#indirect. ? "INDIRECT" : "", |
| 123 | op->extcxx . . $ cs_m680x_op#$anonymous_type_0#ext..addresscxx . . $ m680x_op_ext#address.); |
| 124 | break; |
| 125 | |
| 126 | case M680X_OP_RELATIVEcxx . . $ M680X_OP_RELATIVE.: |
| 127 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: RELATIVE = 0x%04x\n", i, |
| 128 | op->relcxx . . $ cs_m680x_op#$anonymous_type_0#rel..addresscxx . . $ m680x_op_rel#address.); |
| 129 | break; |
| 130 | |
| 131 | case M680X_OP_INDEXEDcxx . . $ M680X_OP_INDEXED.: |
| 132 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: INDEXED%s\n", i, |
| 133 | (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..flagscxx . . $ m680x_op_idx#flags. & M680X_IDX_INDIRECTcxx . . $ `include/capstone/m680x.h:76:9`!) ? |
| 134 | " INDIRECT" : ""); |
| 135 | |
| 136 | if (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..base_regcxx . . $ m680x_op_idx#base_reg. != M680X_REG_INVALIDcxx . . $ M680X_REG_INVALID.) |
| 137 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\tbase register: %s\n", |
| 138 | cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..base_regcxx . . $ m680x_op_idx#base_reg.)); |
| 139 | |
| 140 | if (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_regcxx . . $ m680x_op_idx#offset_reg. != M680X_REG_INVALIDcxx . . $ M680X_REG_INVALID.) |
| 141 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toffset register: %s\n", |
| 142 | cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_regcxx . . $ m680x_op_idx#offset_reg.)); |
| 143 | |
| 144 | if ((op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_bitscxx . . $ m680x_op_idx#offset_bits. != 0) && |
| 145 | (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_regcxx . . $ m680x_op_idx#offset_reg. == M680X_REG_INVALIDcxx . . $ M680X_REG_INVALID.) && |
| 146 | !op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..inc_deccxx . . $ m680x_op_idx#inc_dec.) { |
| 147 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toffset: %d\n", op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offsetcxx . . $ m680x_op_idx#offset.); |
| 148 | |
| 149 | if (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..base_regcxx . . $ m680x_op_idx#base_reg. == M680X_REG_PCcxx . . $ M680X_REG_PC.) |
| 150 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toffset address: 0x%x\n", |
| 151 | op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_addrcxx . . $ m680x_op_idx#offset_addr.); |
| 152 | |
| 153 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toffset bits: %u\n", |
| 154 | op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..offset_bitscxx . . $ m680x_op_idx#offset_bits.); |
| 155 | } |
| 156 | |
| 157 | if (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..inc_deccxx . . $ m680x_op_idx#inc_dec.) { |
| 158 | const char *post_pre = op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..flagscxx . . $ m680x_op_idx#flags. & |
| 159 | M680X_IDX_POST_INC_DECcxx . . $ `include/capstone/m680x.h:78:9`! ? "post" : "pre"; |
| 160 | const char *inc_dec = (op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..inc_deccxx . . $ m680x_op_idx#inc_dec. > 0) ? |
| 161 | "increment" : "decrement"; |
| 162 | |
| 163 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\t%s %s: %d\n", post_pre, inc_dec, |
| 164 | abscxx . . $ abs(7864480464b09eea).(op->idxcxx . . $ cs_m680x_op#$anonymous_type_0#idx..inc_deccxx . . $ m680x_op_idx#inc_dec.)); |
| 165 | } |
| 166 | |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | if (op->sizecxx . . $ cs_m680x_op#size. != 0) |
| 171 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\tsize: %u\n", op->sizecxx . . $ cs_m680x_op#size.); |
| 172 | |
| 173 | if (op->accesscxx . . $ cs_m680x_op#access. != CS_AC_INVALIDcxx . . $ CS_AC_INVALID.) |
| 174 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\taccess: %s\n", s_accesscxx . . $ s_access.[op->accesscxx . . $ cs_m680x_op#access.]); |
| 175 | |
| 176 | } |
| 177 | |
| 178 | print_read_write_regscxx . . $ print_read_write_regs(429ed0f42458107e).(handle, detail); |
| 179 | |
| 180 | if (detail->groups_countcxx . . $ cs_detail#groups_count.) { |
| 181 | printfcxx . . $ printf(581fddd72a8db8fc).("\tgroups_count: %u\n", detail->groups_countcxx . . $ cs_detail#groups_count.); |
| 182 | } |
| 183 | |
| 184 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 185 | } |
| 186 | |
| 187 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! consistency_checkscxx . . $ consistency_checks(916943d3f68c3cf5).() |
| 188 | { |
| 189 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 190 | } |
| 191 | |
| 192 | static void testcxx . . $ test(d878ad36e69247c7).() |
| 193 | { |
| 194 | #define M6800_CODEcxx . . $ `tests/test_m680x.c:194:9`! \ |
| 195 | "\x01\x09\x36\x64\x7f\x74\x10\x00\x90\x10\xA4\x10\xb6\x10\x00\x39" |
| 196 | |
| 197 | #define M6801_CODEcxx . . $ `tests/test_m680x.c:197:9`! \ |
| 198 | "\x04\x05\x3c\x3d\x38\x93\x10\xec\x10\xed\x10\x39" |
| 199 | |
| 200 | #define M6805_CODEcxx . . $ `tests/test_m680x.c:200:9`! \ |
| 201 | "\x04\x7f\x00\x17\x22\x28\x00\x2e\x00\x40\x42\x5a\x70\x8e\x97\x9c" \ |
| 202 | "\xa0\x15\xad\x00\xc3\x10\x00\xda\x12\x34\xe5\x7f\xfe" |
| 203 | |
| 204 | #define M6808_CODEcxx . . $ `tests/test_m680x.c:204:9`! \ |
| 205 | "\x31\x22\x00\x35\x22\x45\x10\x00\x4b\x00\x51\x10\x52\x5e\x22\x62" \ |
| 206 | "\x65\x12\x34\x72\x84\x85\x86\x87\x8a\x8b\x8c\x94\x95\xa7\x10\xaf\x10" \ |
| 207 | "\x9e\x60\x7f\x9e\x6b\x7f\x00\x9e\xd6\x10\x00\x9e\xe6\x7f" |
| 208 | |
| 209 | #define HCS08_CODEcxx . . $ `tests/test_m680x.c:209:9`! \ |
| 210 | "\x32\x10\x00\x9e\xae\x9e\xce\x7f\x9e\xbe\x10\x00\x9e\xfe\x7f" \ |
| 211 | "\x3e\x10\x00\x9e\xf3\x7f\x96\x10\x00\x9e\xff\x7f\x82" |
| 212 | |
| 213 | #define M6811_CODEcxx . . $ `tests/test_m680x.c:213:9`! \ |
| 214 | "\x02\x03\x12\x7f\x10\x00\x13\x99\x08\x00\x14\x7f\x02\x15\x7f\x01" \ |
| 215 | "\x1e\x7f\x20\x00\x8f\xcf" \ |
| 216 | "\x18\x08\x18\x30\x18\x3c\x18\x67\x18\x8c\x10\x00\x18\x8f" \ |
| 217 | "\x18\xce\x10\x00\x18\xff\x10\x00" \ |
| 218 | "\x1a\xa3\x7f\x1a\xac\x1a\xee\x7f\x1a\xef\x7f\xcd\xac\x7f" |
| 219 | |
| 220 | #define CPU12_CODEcxx . . $ `tests/test_m680x.c:220:9`! \ |
| 221 | "\x00\x04\x01\x00\x0c\x00\x80\x0e\x00\x80\x00\x11\x1e\x10\x00\x80\x00" \ |
| 222 | "\x3b\x4a\x10\x00\x04\x4b\x01\x04\x4f\x7f\x80\x00\x8f\x10\x00\xb7\x52" \ |
| 223 | "\xb7\xb1\xa6\x67\xa6\xfe\xa6\xf7\x18\x02\xe2\x30\x39\xe2\x10\x00" \ |
| 224 | "\x18\x0c\x30\x39\x10\x00\x18\x11\x18\x12\x10\x00\x18\x19\x00\x18\x1e\x00" \ |
| 225 | "\x18\x3e\x18\x3f\x00" |
| 226 | |
| 227 | #define HD6301_CODEcxx . . $ `tests/test_m680x.c:227:9`! \ |
| 228 | "\x6b\x10\x00\x71\x10\x00\x72\x10\x10\x39" |
| 229 | |
| 230 | #define M6809_CODEcxx . . $ `tests/test_m680x.c:230:9`! \ |
| 231 | "\x06\x10\x19\x1a\x55\x1e\x01\x23\xe9\x31\x06\x34\x55\xa6\x81" \ |
| 232 | "\xa7\x89\x7f\xff\xa6\x9d\x10\x00\xa7\x91\xa6\x9f\x10\x00" \ |
| 233 | "\x11\xac\x99\x10\x00\x39" \ |
| 234 | \ |
| 235 | "\xA6\x07\xA6\x27\xA6\x47\xA6\x67\xA6\x0F\xA6\x10" \ |
| 236 | "\xA6\x80\xA6\x81\xA6\x82\xA6\x83\xA6\x84\xA6\x85\xA6\x86" \ |
| 237 | "\xA6\x88\x7F\xA6\x88\x80\xA6\x89\x7F\xFF\xA6\x89\x80\x00" \ |
| 238 | "\xA6\x8B\xA6\x8C\x10\xA6\x8D\x10\x00" \ |
| 239 | \ |
| 240 | "\xA6\x91\xA6\x93\xA6\x94\xA6\x95\xA6\x96" \ |
| 241 | "\xA6\x98\x7F\xA6\x98\x80\xA6\x99\x7F\xFF\xA6\x99\x80\x00" \ |
| 242 | "\xA6\x9B\xA6\x9C\x10\xA6\x9D\x10\x00\xA6\x9F\x10\x00" |
| 243 | |
| 244 | #define HD6309_CODEcxx . . $ `tests/test_m680x.c:244:9`! \ |
| 245 | "\x01\x10\x10\x62\x10\x10\x7b\x10\x10\x00\xcd\x49\x96\x02\xd2" \ |
| 246 | "\x10\x30\x23\x10\x38\x10\x3b\x10\x53\x10\x5d" \ |
| 247 | "\x11\x30\x43\x10\x11\x37\x25\x10\x11\x38\x12\x11\x39\x23\x11\x3b\x34" \ |
| 248 | "\x11\x8e\x10\x00\x11\xaf\x10\x11\xab\x10\x11\xf6\x80\x00" |
| 249 | |
| 250 | struct platformcxx . . $ platform# platforms[] = { |
| 251 | { |
| 252 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 253 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6301cxx . . $ CS_MODE_M680X_6301.), |
| 254 | (unsigned char *)HD6301_CODEcxx . . $ `tests/test_m680x.c:227:9`!, |
| 255 | sizeof(HD6301_CODEcxx . . $ `tests/test_m680x.c:227:9`!) - 1, |
| 256 | "M680X_HD6301", |
| 257 | }, |
| 258 | { |
| 259 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 260 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6309cxx . . $ CS_MODE_M680X_6309.), |
| 261 | (unsigned char *)HD6309_CODEcxx . . $ `tests/test_m680x.c:244:9`!, |
| 262 | sizeof(HD6309_CODEcxx . . $ `tests/test_m680x.c:244:9`!) - 1, |
| 263 | "M680X_HD6309", |
| 264 | }, |
| 265 | { |
| 266 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 267 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6800cxx . . $ CS_MODE_M680X_6800.), |
| 268 | (unsigned char *)M6800_CODEcxx . . $ `tests/test_m680x.c:194:9`!, |
| 269 | sizeof(M6800_CODEcxx . . $ `tests/test_m680x.c:194:9`!) - 1, |
| 270 | "M680X_M6800", |
| 271 | }, |
| 272 | { |
| 273 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 274 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6801cxx . . $ CS_MODE_M680X_6801.), |
| 275 | (unsigned char *)M6801_CODEcxx . . $ `tests/test_m680x.c:197:9`!, |
| 276 | sizeof(M6801_CODEcxx . . $ `tests/test_m680x.c:197:9`!) - 1, |
| 277 | "M680X_M6801", |
| 278 | }, |
| 279 | { |
| 280 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 281 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6805cxx . . $ CS_MODE_M680X_6805.), |
| 282 | (unsigned char *)M6805_CODEcxx . . $ `tests/test_m680x.c:200:9`!, |
| 283 | sizeof(M6805_CODEcxx . . $ `tests/test_m680x.c:200:9`!) - 1, |
| 284 | "M680X_M68HC05", |
| 285 | }, |
| 286 | { |
| 287 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 288 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6808cxx . . $ CS_MODE_M680X_6808.), |
| 289 | (unsigned char *)M6808_CODEcxx . . $ `tests/test_m680x.c:204:9`!, |
| 290 | sizeof(M6808_CODEcxx . . $ `tests/test_m680x.c:204:9`!) - 1, |
| 291 | "M680X_M68HC08", |
| 292 | }, |
| 293 | { |
| 294 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 295 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6809cxx . . $ CS_MODE_M680X_6809.), |
| 296 | (unsigned char *)M6809_CODEcxx . . $ `tests/test_m680x.c:230:9`!, |
| 297 | sizeof(M6809_CODEcxx . . $ `tests/test_m680x.c:230:9`!) - 1, |
| 298 | "M680X_M6809", |
| 299 | }, |
| 300 | { |
| 301 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 302 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_6811cxx . . $ CS_MODE_M680X_6811.), |
| 303 | (unsigned char *)M6811_CODEcxx . . $ `tests/test_m680x.c:213:9`!, |
| 304 | sizeof(M6811_CODEcxx . . $ `tests/test_m680x.c:213:9`!) - 1, |
| 305 | "M680X_M68HC11", |
| 306 | }, |
| 307 | { |
| 308 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 309 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_CPU12cxx . . $ CS_MODE_M680X_CPU12.), |
| 310 | (unsigned char *)CPU12_CODEcxx . . $ `tests/test_m680x.c:220:9`!, |
| 311 | sizeof(CPU12_CODEcxx . . $ `tests/test_m680x.c:220:9`!) - 1, |
| 312 | "M680X_CPU12", |
| 313 | }, |
| 314 | { |
| 315 | CS_ARCH_M680Xcxx . . $ CS_ARCH_M680X., |
| 316 | (cs_modecxx . . $ cs_mode#)(CS_MODE_M680X_HCS08cxx . . $ CS_MODE_M680X_HCS08.), |
| 317 | (unsigned char *)HCS08_CODEcxx . . $ `tests/test_m680x.c:209:9`!, |
| 318 | sizeof(HCS08_CODEcxx . . $ `tests/test_m680x.c:209:9`!) - 1, |
| 319 | "M680X_HCS08", |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | uint64_tcxx . . $ uint64_t# address = 0x1000; |
| 324 | cshcxx . . $ csh# handle; |
| 325 | cs_insncxx . . $ cs_insn# *insn; |
| 326 | int i; |
| 327 | size_t count; |
| 328 | const char *nine_spaces = " "; |
| 329 | |
| 330 | if (!consistency_checkscxx . . $ consistency_checks(916943d3f68c3cf5).()) |
| 331 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 332 | |
| 333 | for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) { |
| 334 | cs_errcxx . . $ cs_err# err = cs_opencxx . . $ cs_open(b2cb849d8ee082cd).(platforms[i].archcxx . . $ platform#arch., platforms[i].modecxx . . $ platform#mode., |
| 335 | &handle); |
| 336 | |
| 337 | if (err) { |
| 338 | printfcxx . . $ printf(581fddd72a8db8fc).("Failed on cs_open() with error returned: %u\n", |
| 339 | err); |
| 340 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 341 | } |
| 342 | |
| 343 | #ifdef WITH_DETAILScxx . . $ `tests/test_m680x.c:10:9`! |
| 344 | cs_optioncxx . . $ cs_option(a321a010700ba3d2).(handle, CS_OPT_DETAILcxx . . $ CS_OPT_DETAIL., CS_OPT_ONcxx . . $ CS_OPT_ON.); |
| 345 | #endif |
| 346 | |
| 347 | count = cs_disasmcxx . . $ cs_disasm(d552efbd9b22be5).(handle, platforms[i].codecxx . . $ platform#code., platforms[i].sizecxx . . $ platform#size., |
| 348 | address, 0, &insn); |
| 349 | |
| 350 | if (count) { |
| 351 | size_t j; |
| 352 | |
| 353 | printfcxx . . $ printf(581fddd72a8db8fc).("********************\n"); |
| 354 | printfcxx . . $ printf(581fddd72a8db8fc).("Platform: %s\n", platforms[i].commentcxx . . $ platform#comment.); |
| 355 | print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).("Code: ", platforms[i].codecxx . . $ platform#code., |
| 356 | platforms[i].sizecxx . . $ platform#size.); |
| 357 | printfcxx . . $ printf(581fddd72a8db8fc).("Disasm:\n"); |
| 358 | |
| 359 | for (j = 0; j < count; j++) { |
| 360 | int slen; |
| 361 | printfcxx . . $ printf(581fddd72a8db8fc).("0x%04x: ", (uint16_tcxx . . $ uint16_t#)insn[j].addresscxx . . $ cs_insn#address.); |
| 362 | print_string_hex_shortcxx . . $ print_string_hex_short(6165b45f45ef689c).(insn[j].bytescxx . . $ cs_insn#bytes., |
| 363 | insn[j].sizecxx . . $ cs_insn#size.); |
| 364 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s", 1 + ((5 - insn[j].sizecxx . . $ cs_insn#size.) * 2), |
| 365 | nine_spaces); |
| 366 | printfcxx . . $ printf(581fddd72a8db8fc).("%s", insn[j].mnemoniccxx . . $ cs_insn#mnemonic.); |
| 367 | slen = (int)strlencxx . . $ strlen(751346f8406fd082).(insn[j].mnemoniccxx . . $ cs_insn#mnemonic.); |
| 368 | printfcxx . . $ printf(581fddd72a8db8fc).("%.*s", 1 + (5 - slen), nine_spaces); |
| 369 | printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", insn[j].op_strcxx . . $ cs_insn#op_str.); |
| 370 | #ifdef WITH_DETAILScxx . . $ `tests/test_m680x.c:10:9`! |
| 371 | print_insn_detailcxx . . $ print_insn_detail(2888c3e5b0984e8d).(handle, &insn[j]); |
| 372 | #endif |
| 373 | } |
| 374 | |
| 375 | // free memory allocated by cs_disasm() |
| 376 | cs_freecxx . . $ cs_free(d0ae7023b33cf0c8).(insn, count); |
| 377 | } |
| 378 | else { |
| 379 | printfcxx . . $ printf(581fddd72a8db8fc).("********************\n"); |
| 380 | printfcxx . . $ printf(581fddd72a8db8fc).("Platform: %s\n", platforms[i].commentcxx . . $ platform#comment.); |
| 381 | print_string_hexcxx . . $ print_string_hex(24a4beb24605093f).("Code:", platforms[i].codecxx . . $ platform#code., |
| 382 | platforms[i].sizecxx . . $ platform#size.); |
| 383 | printfcxx . . $ printf(581fddd72a8db8fc).("ERROR: Failed to disasm given code!\n"); |
| 384 | abortcxx . . $ abort(8df32a62017fbbf6).(); |
| 385 | } |
| 386 | |
| 387 | cs_closecxx . . $ cs_close(b9ab39fbab147149).(&handle); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | int maincxx . . $ main(d1b40a211a1a4e4c).() |
| 392 | { |
| 393 | testcxx . . $ test(d878ad36e69247c7).(); |
| 394 | |
| 395 | return 0; |
| 396 | } |