- codeword = 0;
- codeword |= ((uint64_t)tmp[0]) << 56;
- codeword |= ((uint64_t)tmp[1]) << 48;
- codeword |= ((uint64_t)tmp[2]) << 40;
- codeword |= ((uint64_t)tmp[3]) << 32;
- codeword |= ((uint64_t)tmp[4]) << 24;
- codeword |= ((uint64_t)tmp[5]) << 16;
- codeword |= ((uint64_t)tmp[6]) << 8;
- codeword |= ((uint64_t)tmp[7]);
-
- code[pos].opcode = (codeword >> 4) & 0xFFF;
- code[pos].operands[0] = (codeword & 0xF) << 8;
- code[pos].operands[0] |= (codeword >> 56) & 0xFF;
- code[pos].operands[1] = (codeword >> 44) & 0xFFF;
- code[pos].operands[2] = (codeword >> 32) & 0xFFF;
+ switch (cmdargs.informat) {
+ case FMT_B43:
+ case FMT_RAW_BE32:
+ codeword = 0;
+ codeword |= ((uint64_t)tmp[0]) << 56;
+ codeword |= ((uint64_t)tmp[1]) << 48;
+ codeword |= ((uint64_t)tmp[2]) << 40;
+ codeword |= ((uint64_t)tmp[3]) << 32;
+ codeword |= ((uint64_t)tmp[4]) << 24;
+ codeword |= ((uint64_t)tmp[5]) << 16;
+ codeword |= ((uint64_t)tmp[6]) << 8;
+ codeword |= ((uint64_t)tmp[7]);
+ codeword = ((codeword & (uint64_t)0xFFFFFFFF00000000ULL) >> 32) |
+ ((codeword & (uint64_t)0x00000000FFFFFFFFULL) << 32);
+ break;
+ case FMT_RAW_LE32:
+ codeword = 0;
+ codeword |= ((uint64_t)tmp[7]) << 56;
+ codeword |= ((uint64_t)tmp[6]) << 48;
+ codeword |= ((uint64_t)tmp[5]) << 40;
+ codeword |= ((uint64_t)tmp[4]) << 32;
+ codeword |= ((uint64_t)tmp[3]) << 24;
+ codeword |= ((uint64_t)tmp[2]) << 16;
+ codeword |= ((uint64_t)tmp[1]) << 8;
+ codeword |= ((uint64_t)tmp[0]);
+ break;
+ }
+
+ switch (cmdargs.arch) {
+ case 5:
+ if (codeword >> 48) {
+ fprintf(stderr, "Instruction format error at 0x%X (upper not clear). "
+ "Wrong input format or architecture?\n", (unsigned int)pos);
+ goto err_free_code;
+ }
+ code[pos].opcode = (codeword >> 36) & 0xFFF;
+ code[pos].operands[2] = codeword & 0xFFF;
+ code[pos].operands[1] = (codeword >> 12) & 0xFFF;
+ code[pos].operands[0] = (codeword >> 24) & 0xFFF;
+ break;
+ case 15:
+ if (codeword >> 51) {
+ fprintf(stderr, "Instruction format error at 0x%X (upper not clear). "
+ "Wrong input format or architecture?\n", (unsigned int)pos);
+ goto err_free_code;
+ }
+ code[pos].opcode = (codeword >> 39) & 0xFFF;
+ code[pos].operands[2] = codeword & 0x1FFF;
+ code[pos].operands[1] = (codeword >> 13) & 0x1FFF;
+ code[pos].operands[0] = (codeword >> 26) & 0x1FFF;
+ break;
+ default:
+ fprintf(stderr, "Internal error: read_input unknown arch %u\n",
+ cmdargs.arch);
+ goto err_free_code;
+ }