| 164 | } |
| 165 | |
| 166 | static void test() |
| 167 | { |
| 168 | #define SH4A_CODE \ |
| 169 | "\xc\x31\x10\x20\x22\x21\x36\x64\x46\x25\x12\x12\x1c\x2\x8\xc1\x5\xc7\xc" \ |
| 170 | "\x71\x1f\x2\x22\xcf\x6\x89\x23\x0\x2b\x41\xb\x0\xe\x40\x32\x0\xa\xf1\x9\x0" |
| 171 | |
| 172 | #define SH2A_CODE \ |
| 173 | "\x32\x11\x92\x0\x32\x49\x31\x0" |
| 174 | |
| 175 | struct platform platforms[] = { |
| 176 | { |
| 177 | CS_ARCH_SH, |
| 178 | (cs_mode)(CS_MODE_SH4A | CS_MODE_SHFPU), |
| 179 | (unsigned char *)SH4A_CODE, |
| 180 | sizeof(SH4A_CODE) - 1, |
| 181 | "SH_SH4A", |
| 182 | }, |
| 183 | { |
| 184 | CS_ARCH_SH, |
| 185 | (cs_mode)(CS_MODE_SH2A | CS_MODE_SHFPU | CS_MODE_BIG_ENDIAN), |
| 186 | (unsigned char *)SH2A_CODE, |
| 187 | sizeof(SH2A_CODE) - 1, |
| 188 | "SH_SH2A", |
| 189 | }, |
| 190 | }; |
| 191 | |
| 192 | uint64_t address = 0x80000000; |
| 193 | csh handle; |
| 194 | cs_insn *insn; |
| 195 | int i; |
| 196 | size_t count; |
| 197 | const char *nine_spaces = " "; |
| 198 | |
| 199 | if (!consistency_checks()) |
| 200 | abort(); |
| 201 | |
| 202 | for (i = 0; i < sizeof(platforms) / sizeof(platforms[0]); i++) { |
| 203 | cs_err err = cs_open(platforms[i].arch, platforms[i].mode, |
| 204 | &handle); |
| 205 | |
| 206 | if (err) { |
| 207 | printf("Failed on cs_open() with error returned: %u\n", |
| 208 | err); |
| 209 | abort(); |
| 210 | } |
| 211 | |
| 212 | #ifdef WITH_DETAILS |
| 213 | cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON); |
| 214 | #endif |
| 215 | |
| 216 | count = cs_disasm(handle, platforms[i].code, platforms[i].size, |
| 217 | address, 0, &insn); |
| 218 | |
| 219 | if (count) { |
| 220 | size_t j; |
| 221 | |
| 222 | printf("********************\n"); |
| 223 | printf("Platform: %s\n", platforms[i].comment); |
no test coverage detected
searching dependent graphs…