| 1 | /* Capstone Disassembler Engine */cxx . . $ `<file>/cstool/cstool_tms320c64x.c`/ |
| 2 | /* By Fotis Loukos <[email protected]>, 2017 */ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <capstone/capstone.h>cxx . . $ `<file>/include/capstone/capstone.h`/ |
| 6 | #include "cstool.h"cxx . . $ `<file>/cstool/cstool.h`/ |
| 7 | |
| 8 | void print_insn_detail_tms320c64xcxx . . $ print_insn_detail_tms320c64x(2888c3e5b0984e8d).(cshcxx . . $ csh# handle, cs_insncxx . . $ cs_insn# *ins) |
| 9 | { |
| 10 | cs_tms320c64xcxx . . $ cs_tms320c64x# *tms320c64x; |
| 11 | int i; |
| 12 | |
| 13 | // detail can be NULL on "data" instruction if SKIPDATA option is turned ON |
| 14 | if (ins->detailcxx . . $ cs_insn#detail. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 15 | return; |
| 16 | |
| 17 | tms320c64x = &(ins->detailcxx . . $ cs_insn#detail.->tms320c64xcxx . . $ cs_detail#$anonymous_type_0#tms320c64x.); |
| 18 | if (tms320c64x->op_countcxx . . $ cs_tms320c64x#op_count.) |
| 19 | printfcxx . . $ printf(581fddd72a8db8fc).("\top_count: %u\n", tms320c64x->op_countcxx . . $ cs_tms320c64x#op_count.); |
| 20 | |
| 21 | for (i = 0; i < tms320c64x->op_countcxx . . $ cs_tms320c64x#op_count.; i++) { |
| 22 | cs_tms320c64x_opcxx . . $ cs_tms320c64x_op# *op = &(tms320c64x->operandscxx . . $ cs_tms320c64x#operands.[i]); |
| 23 | switch((int)op->typecxx . . $ cs_tms320c64x_op#type.) { |
| 24 | default: |
| 25 | break; |
| 26 | case TMS320C64X_OP_REGcxx . . $ TMS320C64X_OP_REG.: |
| 27 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: REG = %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->regcxx . . $ cs_tms320c64x_op#$anonymous_type_0#reg.)); |
| 28 | break; |
| 29 | case TMS320C64X_OP_IMMcxx . . $ TMS320C64X_OP_IMM.: |
| 30 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: IMM = 0x%x\n", i, op->immcxx . . $ cs_tms320c64x_op#$anonymous_type_0#imm.); |
| 31 | break; |
| 32 | case TMS320C64X_OP_MEMcxx . . $ TMS320C64X_OP_MEM.: |
| 33 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: MEM\n", i); |
| 34 | if (op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..basecxx . . $ tms320c64x_op_mem#base. != TMS320C64X_REG_INVALIDcxx . . $ TMS320C64X_REG_INVALID.) |
| 35 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.base: REG = %s\n", |
| 36 | i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..basecxx . . $ tms320c64x_op_mem#base.)); |
| 37 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disptype: ", i); |
| 38 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..disptypecxx . . $ tms320c64x_op_mem#disptype. == TMS320C64X_MEM_DISP_INVALIDcxx . . $ TMS320C64X_MEM_DISP_INVALID.) { |
| 39 | printfcxx . . $ printf(581fddd72a8db8fc).("Invalid\n"); |
| 40 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disp: %u\n", i, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..dispcxx . . $ tms320c64x_op_mem#disp.); |
| 41 | } |
| 42 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..disptypecxx . . $ tms320c64x_op_mem#disptype. == TMS320C64X_MEM_DISP_CONSTANTcxx . . $ TMS320C64X_MEM_DISP_CONSTANT.) { |
| 43 | printfcxx . . $ printf(581fddd72a8db8fc).("Constant\n"); |
| 44 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disp: %u\n", i, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..dispcxx . . $ tms320c64x_op_mem#disp.); |
| 45 | } |
| 46 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..disptypecxx . . $ tms320c64x_op_mem#disptype. == TMS320C64X_MEM_DISP_REGISTERcxx . . $ TMS320C64X_MEM_DISP_REGISTER.) { |
| 47 | printfcxx . . $ printf(581fddd72a8db8fc).("Register\n"); |
| 48 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.disp: %s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..dispcxx . . $ tms320c64x_op_mem#disp.)); |
| 49 | } |
| 50 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.unit: %u\n", i, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..unitcxx . . $ tms320c64x_op_mem#unit.); |
| 51 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.direction: ", i); |
| 52 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..directioncxx . . $ tms320c64x_op_mem#direction. == TMS320C64X_MEM_DIR_INVALIDcxx . . $ TMS320C64X_MEM_DIR_INVALID.) |
| 53 | printfcxx . . $ printf(581fddd72a8db8fc).("Invalid\n"); |
| 54 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..directioncxx . . $ tms320c64x_op_mem#direction. == TMS320C64X_MEM_DIR_FWcxx . . $ TMS320C64X_MEM_DIR_FW.) |
| 55 | printfcxx . . $ printf(581fddd72a8db8fc).("Forward\n"); |
| 56 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..directioncxx . . $ tms320c64x_op_mem#direction. == TMS320C64X_MEM_DIR_BWcxx . . $ TMS320C64X_MEM_DIR_BW.) |
| 57 | printfcxx . . $ printf(581fddd72a8db8fc).("Backward\n"); |
| 58 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.modify: ", i); |
| 59 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..modifycxx . . $ tms320c64x_op_mem#modify. == TMS320C64X_MEM_MOD_INVALIDcxx . . $ TMS320C64X_MEM_MOD_INVALID.) |
| 60 | printfcxx . . $ printf(581fddd72a8db8fc).("Invalid\n"); |
| 61 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..modifycxx . . $ tms320c64x_op_mem#modify. == TMS320C64X_MEM_MOD_NOcxx . . $ TMS320C64X_MEM_MOD_NO.) |
| 62 | printfcxx . . $ printf(581fddd72a8db8fc).("No\n"); |
| 63 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..modifycxx . . $ tms320c64x_op_mem#modify. == TMS320C64X_MEM_MOD_PREcxx . . $ TMS320C64X_MEM_MOD_PRE.) |
| 64 | printfcxx . . $ printf(581fddd72a8db8fc).("Pre\n"); |
| 65 | if(op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..modifycxx . . $ tms320c64x_op_mem#modify. == TMS320C64X_MEM_MOD_POSTcxx . . $ TMS320C64X_MEM_MOD_POST.) |
| 66 | printfcxx . . $ printf(581fddd72a8db8fc).("Post\n"); |
| 67 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\t\toperands[%u].mem.scaled: %u\n", i, op->memcxx . . $ cs_tms320c64x_op#$anonymous_type_0#mem..scaledcxx . . $ tms320c64x_op_mem#scaled.); |
| 68 | |
| 69 | break; |
| 70 | case TMS320C64X_OP_REGPAIRcxx . . $ TMS320C64X_OP_REGPAIR.: |
| 71 | printfcxx . . $ printf(581fddd72a8db8fc).("\t\toperands[%u].type: REGPAIR = %s:%s\n", i, cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->regcxx . . $ cs_tms320c64x_op#$anonymous_type_0#reg. + 1), cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, op->regcxx . . $ cs_tms320c64x_op#$anonymous_type_0#reg.)); |
| 72 | break; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | printfcxx . . $ printf(581fddd72a8db8fc).("\tFunctional unit: "); |
| 77 | switch(tms320c64x->funitcxx . . $ cs_tms320c64x#funit..unitcxx . . $ cs_tms320c64x#$anonymous_type_2#unit.) { |
| 78 | case TMS320C64X_FUNIT_Dcxx . . $ TMS320C64X_FUNIT_D.: |
| 79 | printfcxx . . $ printf(581fddd72a8db8fc).("D%u\n", tms320c64x->funitcxx . . $ cs_tms320c64x#funit..sidecxx . . $ cs_tms320c64x#$anonymous_type_2#side.); |
| 80 | break; |
| 81 | case TMS320C64X_FUNIT_Lcxx . . $ TMS320C64X_FUNIT_L.: |
| 82 | printfcxx . . $ printf(581fddd72a8db8fc).("L%u\n", tms320c64x->funitcxx . . $ cs_tms320c64x#funit..sidecxx . . $ cs_tms320c64x#$anonymous_type_2#side.); |
| 83 | break; |
| 84 | case TMS320C64X_FUNIT_Mcxx . . $ TMS320C64X_FUNIT_M.: |
| 85 | printfcxx . . $ printf(581fddd72a8db8fc).("M%u\n", tms320c64x->funitcxx . . $ cs_tms320c64x#funit..sidecxx . . $ cs_tms320c64x#$anonymous_type_2#side.); |
| 86 | break; |
| 87 | case TMS320C64X_FUNIT_Scxx . . $ TMS320C64X_FUNIT_S.: |
| 88 | printfcxx . . $ printf(581fddd72a8db8fc).("S%u\n", tms320c64x->funitcxx . . $ cs_tms320c64x#funit..sidecxx . . $ cs_tms320c64x#$anonymous_type_2#side.); |
| 89 | break; |
| 90 | case TMS320C64X_FUNIT_NOcxx . . $ TMS320C64X_FUNIT_NO.: |
| 91 | printfcxx . . $ printf(581fddd72a8db8fc).("No Functional Unit\n"); |
| 92 | break; |
| 93 | default: |
| 94 | printfcxx . . $ printf(581fddd72a8db8fc).("Unknown (Unit %u, Side %u)\n", tms320c64x->funitcxx . . $ cs_tms320c64x#funit..unitcxx . . $ cs_tms320c64x#$anonymous_type_2#unit., tms320c64x->funitcxx . . $ cs_tms320c64x#funit..sidecxx . . $ cs_tms320c64x#$anonymous_type_2#side.); |
| 95 | break; |
| 96 | } |
| 97 | if(tms320c64x->funitcxx . . $ cs_tms320c64x#funit..crosspathcxx . . $ cs_tms320c64x#$anonymous_type_2#crosspath. == 1) |
| 98 | printfcxx . . $ printf(581fddd72a8db8fc).("\tCrosspath: 1\n"); |
| 99 | |
| 100 | if(tms320c64x->conditioncxx . . $ cs_tms320c64x#condition..regcxx . . $ cs_tms320c64x#$anonymous_type_1#reg. != TMS320C64X_REG_INVALIDcxx . . $ TMS320C64X_REG_INVALID.) |
| 101 | printfcxx . . $ printf(581fddd72a8db8fc).("\tCondition: [%c%s]\n", (tms320c64x->conditioncxx . . $ cs_tms320c64x#condition..zerocxx . . $ cs_tms320c64x#$anonymous_type_1#zero. == 1) ? '!' : ' ', cs_reg_namecxx . . $ cs_reg_name(efd1348d9ae5172e).(handle, tms320c64x->conditioncxx . . $ cs_tms320c64x#condition..regcxx . . $ cs_tms320c64x#$anonymous_type_1#reg.)); |
| 102 | printfcxx . . $ printf(581fddd72a8db8fc).("\tParallel: %s\n", (tms320c64x->parallelcxx . . $ cs_tms320c64x#parallel. == 1) ? "true" : "false"); |
| 103 | |
| 104 | printfcxx . . $ printf(581fddd72a8db8fc).("\n"); |
| 105 | } |