main */
| 270 | |
| 271 | /* main */ |
| 272 | int main(int ac, char** av) |
| 273 | { |
| 274 | srand(0xCAFE); |
| 275 | |
| 276 | Instruction instr; |
| 277 | uint32_t insword; |
| 278 | char instxt[1024] = {'\0'}; |
| 279 | |
| 280 | double delta; |
| 281 | struct timespec t0, t1; |
| 282 | |
| 283 | if (ac <= 1) |
| 284 | { |
| 285 | printf("example usage:\n"); |
| 286 | printf("\t%s d503201f\n", av[0]); |
| 287 | return -1; |
| 288 | } |
| 289 | |
| 290 | if (!strcmp(av[1], "decode-speed")) |
| 291 | { |
| 292 | verbose = false; |
| 293 | |
| 294 | clock_gettime(CLOCK_MONOTONIC, &t0); |
| 295 | |
| 296 | for (int64_t num_decoded=0; true; num_decoded += 1) |
| 297 | { |
| 298 | insword = (rand() << 16) ^ rand(); |
| 299 | aarch64_decompose(insword, &instr, 0); |
| 300 | if ((num_decoded & 0xFFFFFF) == 0) |
| 301 | { |
| 302 | clock_gettime(CLOCK_MONOTONIC, &t1); |
| 303 | delta = subtract_timespecs(t1, t0); |
| 304 | printf("%lld instructions in %fs, or %.0f instructions/s\n", |
| 305 | num_decoded, delta, num_decoded/delta); |
| 306 | } |
| 307 | } |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | // There's no disassemble speed test yet because randomly generated instruction words often do |
| 312 | // not decode. |
| 313 | |
| 314 | if (!strcmp(av[1], "strain") || !strcmp(av[1], "strainer") || !strcmp(av[1], "stress") || |
| 315 | !strcmp(av[1], "stresser")) |
| 316 | { |
| 317 | verbose = 0; |
| 318 | for (insword = 0; insword != 0xFFFFFFFF; insword++) |
| 319 | { |
| 320 | disassemble(0, insword, instxt); |
| 321 | |
| 322 | if ((insword & 0xFFFFFF) == 0) |
| 323 | printf("%08X: %s\n", insword, instxt); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if (!strcmp(av[1], "random")) |
| 328 | { |
| 329 | bool silent = ac > 2 && !strcmp(av[2], "silent"); |
nothing calls this directly
no test coverage detected