| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include "factory.h" |
| 6 |
|
| 7 |
char *get_detail_tricore(csh *p_handle, cs_mode mode, cs_insn *ins) |
| 8 |
{ |
| 9 |
cs_tricore *tricore; |
| 10 |
int i; |
| 11 |
cs_regs regs_read, regs_write; |
| 12 |
uint8_t regs_read_count, regs_write_count; |
| 13 |
|
| 14 |
char *result; |
| 15 |
result = (char *)malloc(sizeof(char)); |
| 16 |
result[0] = '\0'; |
| 17 |
|
| 18 |
if (ins->detail == NULL) |
| 19 |
return result; |
| 20 |
|
| 21 |
csh handle = *p_handle; |
| 22 |
|
| 23 |
tricore = &(ins->detail->tricore); |
| 24 |
|
| 25 |
if (tricore->op_count) |
| 26 |
add_str(&result, "\top_count: %u\n", tricore->op_count); |
| 27 |
|
| 28 |
for (i = 0; i < tricore->op_count; i++) { |
| 29 |
cs_tricore_op *op = &(tricore->operands[i]); |
| 30 |
switch ((int)op->type) { |
| 31 |
default: |
| 32 |
break; |
| 33 |
case TRICORE_OP_REG: |
| 34 |
add_str(&result, "\t\toperands[%u].type: REG = %s\n", i, |
| 35 |
cs_reg_name(handle, op->reg)); |
| 36 |
break; |
| 37 |
case TRICORE_OP_IMM: |
| 38 |
add_str(&result, "\t\toperands[%u].type: IMM = 0x%x\n", |
| 39 |
i, op->imm); |
| 40 |
break; |
| 41 |
case TRICORE_OP_MEM: |
| 42 |
add_str(&result, "\t\toperands[%u].type: MEM\n", i); |
| 43 |
if (op->mem.base != TRICORE_REG_INVALID) |
| 44 |
add_str(&result, |
| 45 |
"\t\t\toperands[%u].mem.base: REG = %s\n", |
| 46 |
i, cs_reg_name(handle, op->mem.base)); |
| 47 |
if (op->mem.disp != 0) |
| 48 |
add_str(&result, |
| 49 |
"\t\t\toperands[%u].mem.disp: 0x%x\n", |
| 50 |
i, op->mem.disp); |
| 51 |
break; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
if (!cs_regs_access(handle, ins, regs_read, ®s_read_count, |
| 57 |
regs_write, ®s_write_count)) { |
| 58 |
if (regs_read_count) { |
| 59 |
add_str(&result, "\tRegisters read:"); |
| 60 |
for (i = 0; i < regs_read_count; i++) { |
| 61 |
add_str(&result, " %s", |
| 62 |
cs_reg_name(handle, |
| 63 |
regs_read[i])); |
| 64 |
} |
| 65 |
add_str(&result, "\n"); |
| 66 |
} |
| 67 |
|
| 68 |
if (regs_write_count) { |
| 69 |
add_str(&result, "\tRegisters modified:"); |
| 70 |
for (i = 0; i < regs_write_count; i++) { |
| 71 |
add_str(&result, " %s", |
| 72 |
cs_reg_name(handle, |
| 73 |
regs_write[i])); |
| 74 |
} |
| 75 |
add_str(&result, "\n"); |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
return result; |
| 81 |
} |