| 185 | } |
| 186 | |
| 187 | int disassemble(uint64_t address, uint32_t insword, char* result) |
| 188 | { |
| 189 | int rc; |
| 190 | Instruction instr; |
| 191 | memset(&instr, 0, sizeof(instr)); |
| 192 | |
| 193 | rc = aarch64_decompose(insword, &instr, address); |
| 194 | if (verbose) |
| 195 | printf("aarch64_decompose() returned %d\n", rc); |
| 196 | if (rc) |
| 197 | return rc; |
| 198 | |
| 199 | if (verbose) |
| 200 | { |
| 201 | printf(" instr.insword: %08X\n", instr.insword); |
| 202 | printf(" instr.encoding: %d %s\n", instr.encoding, enc_to_str(instr.encoding)); |
| 203 | printf("instr.operation: %d %s\n", instr.operation, operation_to_str(instr.operation)); |
| 204 | printf(" instr.setflags: %d\n", instr.setflags); |
| 205 | for (int i = 0; i < MAX_OPERANDS && instr.operands[i].operandClass != NONE; i++) |
| 206 | { |
| 207 | printf("instr.operands[%d]\n", i); |
| 208 | |
| 209 | InstructionOperand operand = instr.operands[i]; |
| 210 | |
| 211 | /* class */ |
| 212 | printf("\t.class: %d (\"%s\")\n", operand.operandClass, oper_class_to_str(operand.operandClass)); |
| 213 | switch (operand.operandClass) |
| 214 | { |
| 215 | case CONDITION: |
| 216 | printf("\t\t%d %s\n", operand.cond, cond_to_str(operand.cond)); |
| 217 | break; |
| 218 | case FIMM32: |
| 219 | printf("\t\t%f\n", *(float*)&(operand.immediate)); |
| 220 | break; |
| 221 | case IMM32: |
| 222 | printf("\t.imm32: 0x%llX\n", operand.immediate & 0xFFFFFFFF); |
| 223 | break; |
| 224 | case IMM64: |
| 225 | printf("\t.imm64: 0x%llX\n", operand.immediate); |
| 226 | break; |
| 227 | case NAME: |
| 228 | printf("\t.name: %s\n", operand.name); |
| 229 | break; |
| 230 | default: |
| 231 | break; |
| 232 | } |
| 233 | /* lane */ |
| 234 | if (operand.laneUsed) |
| 235 | printf("\t.lane: %d\n", operand.lane); |
| 236 | /* shift */ |
| 237 | if (operand.shiftType != ShiftType_NONE) |
| 238 | { |
| 239 | printf("\t.shiftType: %d (%s)\n", operand.shiftType, shifttype_to_str(operand.shiftType)); |
| 240 | } |
| 241 | /* arrangement spec */ |
| 242 | printf("\t.arrSpec: %d %s\n", operand.arrSpec, arrspec_to_str(operand.arrSpec)); |
| 243 | } |
| 244 | } |
no test coverage detected