public static void print_ins_detail(Capstone.CsInsn ins) { System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr); Arm64.OpInfo operands = (Arm64.OpInfo) ins.operands; if (operands.op.length != 0) { System.out.printf("\top_count: %d\n", operands.op.length); for (int c = 0; c < operands.op.length; c++) { Arm64.Operand i = (Arm64.Operand) operands.op[c]; String imm = hex(i.value.imm); if (i.type == ARM64_OP_REG) System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg)); if (i.type == ARM64_OP_REG_MRS) System.out.printf("\t\toperands[%d].type: REG_MRS = 0x%x\n", c, i.value.reg); if (i.type == ARM64_OP_REG_MSR) System.out.printf("\t\toperands[%d].type: REG_MSR = 0x%x\n", c, i.value.reg); if (i.type == ARM64_OP_PSTATE) System.out.printf("\t\toperands[%d].type: PSTATE = 0x%x\n", c, i.value.imm); if (i.type == ARM64_OP_BARRIER) System.out.printf("\t\toperands[%d].type: BARRIER = 0x%x\n", c, i.value.imm); if (i.type == ARM64_OP_IMM) System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm); if (i.type == ARM64_OP_CIMM) System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm); if (i.type == ARM64_OP_FP) System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp); if (i.type == ARM64_OP_MEM) { System.out.printf("\t\toperands[%d].type: MEM\n", c); String base = ins.regName(i.value.mem.base); String index = ins.regName(i.value.mem.index); if (base != null) System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base); if (index != null) System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index); if (i.value.mem.disp != 0) System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, i.value.mem.disp); } if (i.shift.type != ARM64_SFT_INVALID && i.shift.value > 0) System.out.printf("\t\t\tShift: type = %d, value = %d\n", i.shift.type, i.shift.value); if (i.ext != ARM64_EXT_INVALID) System.out.printf("\t\t\tExt: %d\n", i.ext); if (i.vas != ARM64_VAS_INVALID) System.out.printf("\t\t\tVector Arrangement Specifier: 0x%x\n", i.vas); if (i.vess != ARM64_VESS_INVALID) System.out.printf("\t\t\tVector Element Size Specifier: %d\n", i.vess); if (i.vector_index != -1) System.out.printf("\t\t\tVector Index: %d\n", i.vector_index); } } if (operands.writeback) System.out.println("\tWrite-back: True"); if (operands.updateFlags) System.out.println("\tUpdate-flags: True"); if (operands.cc != ARM64_CC_AL && operands.cc != ARM64_CC_INVALID) System.out.printf("\tCode-condition: %d\n", operands.cc); }
public static void print_ins_detail(Capstone.CsInsn ins) { System.out.printf("0x%x:\t%s\t%s\n", ins.address, ins.mnemonic, ins.opStr); Arm.OpInfo operands = (Arm.OpInfo) ins.operands; if (operands.op.length != 0) { System.out.printf("\top_count: %d\n", operands.op.length); for (int c = 0; c < operands.op.length; c++) { Arm.Operand i = (Arm.Operand) operands.op[c]; String imm = hex(i.value.imm); if (i.type == ARM_OP_SYSREG) System.out.printf("\t\toperands[%d].type: SYSREG = %d\n", c, i.value.reg); if (i.type == ARM_OP_REG) System.out.printf("\t\toperands[%d].type: REG = %s\n", c, ins.regName(i.value.reg)); if (i.type == ARM_OP_IMM) System.out.printf("\t\toperands[%d].type: IMM = 0x%x\n", c, i.value.imm); if (i.type == ARM_OP_PIMM) System.out.printf("\t\toperands[%d].type: P-IMM = %d\n", c, i.value.imm); if (i.type == ARM_OP_CIMM) System.out.printf("\t\toperands[%d].type: C-IMM = %d\n", c, i.value.imm); if (i.type == ARM_OP_SETEND) System.out.printf( "\t\toperands[%d].type: SETEND = %s\n", c, i.value.setend == ARM_SETEND_BE ? "be" : "le"); if (i.type == ARM_OP_FP) System.out.printf("\t\toperands[%d].type: FP = %f\n", c, i.value.fp); if (i.type == ARM_OP_MEM) { System.out.printf("\t\toperands[%d].type: MEM\n", c); String base = ins.regName(i.value.mem.base); String index = ins.regName(i.value.mem.index); if (base != null) System.out.printf("\t\t\toperands[%d].mem.base: REG = %s\n", c, base); if (index != null) System.out.printf("\t\t\toperands[%d].mem.index: REG = %s\n", c, index); if (i.value.mem.scale != 1) System.out.printf("\t\t\toperands[%d].mem.scale: %d\n", c, (i.value.mem.scale)); if (i.value.mem.disp != 0) System.out.printf("\t\t\toperands[%d].mem.disp: 0x%x\n", c, (i.value.mem.disp)); if (i.value.mem.lshift != 0) System.out.printf("\t\t\toperands[%d].mem.lshift: 0x%x\n", c, (i.value.mem.lshift)); } if (i.vector_index > 0) System.out.printf("\t\t\toperands[%d].vector_index = %d\n", c, (i.vector_index)); if (i.shift.type != ARM_SFT_INVALID && i.shift.value > 0) System.out.printf("\t\t\tShift: %d = %d\n", i.shift.type, i.shift.value); if (i.subtracted) System.out.printf("\t\t\toperands[%d].subtracted = True\n", c); } } if (operands.writeback) System.out.println("\tWrite-back: True"); if (operands.updateFlags) System.out.println("\tUpdate-flags: True"); if (operands.cc != ARM_CC_AL && operands.cc != ARM_CC_INVALID) System.out.printf("\tCode condition: %d\n", operands.cc); if (operands.cpsMode > 0) System.out.printf("\tCPSI-mode: %d\n", operands.cpsMode); if (operands.cpsFlag > 0) System.out.printf("\tCPSI-flag: %d\n", operands.cpsFlag); if (operands.vectorData > 0) System.out.printf("\tVector-data: %d\n", operands.vectorData); if (operands.vectorSize > 0) System.out.printf("\tVector-size: %d\n", operands.vectorSize); if (operands.usermode) System.out.printf("\tUser-mode: True\n"); }