4 #ifdef CAPSTONE_HAS_TMS320C64X 
    8 #include "../../cs_priv.h" 
    9 #include "../../utils.h" 
   13 #include "../../MCInst.h" 
   14 #include "../../MCInstrDesc.h" 
   15 #include "../../MCFixedLenDisassembler.h" 
   16 #include "../../MCRegisterInfo.h" 
   17 #include "../../MCDisassembler.h" 
   18 #include "../../MathExtras.h" 
   85 #include "TMS320C64xGenDisassemblerTables.inc" 
   87 #define GET_REGINFO_ENUM 
   88 #define GET_REGINFO_MC_DESC 
   89 #include "TMS320C64xGenRegisterInfo.inc" 
   91 static const unsigned GPRegsDecoderTable[] = {
 
   92         TMS320C64x_A0,  TMS320C64x_A1,  TMS320C64x_A2,  TMS320C64x_A3,
 
   93         TMS320C64x_A4,  TMS320C64x_A5,  TMS320C64x_A6,  TMS320C64x_A7,
 
   94         TMS320C64x_A8,  TMS320C64x_A9,  TMS320C64x_A10, TMS320C64x_A11,
 
   95         TMS320C64x_A12, TMS320C64x_A13, TMS320C64x_A14, TMS320C64x_A15,
 
   96         TMS320C64x_A16, TMS320C64x_A17, TMS320C64x_A18, TMS320C64x_A19,
 
   97         TMS320C64x_A20, TMS320C64x_A21, TMS320C64x_A22, TMS320C64x_A23,
 
   98         TMS320C64x_A24, TMS320C64x_A25, TMS320C64x_A26, TMS320C64x_A27,
 
   99         TMS320C64x_A28, TMS320C64x_A29, TMS320C64x_A30, TMS320C64x_A31
 
  102 static const unsigned ControlRegsDecoderTable[] = {
 
  103         TMS320C64x_AMR,    TMS320C64x_CSR,  TMS320C64x_ISR,   TMS320C64x_ICR,
 
  104         TMS320C64x_IER,    TMS320C64x_ISTP, TMS320C64x_IRP,   TMS320C64x_NRP,
 
  105         ~0U,               ~0U,             TMS320C64x_TSCL,  TMS320C64x_TSCH,
 
  106         ~0U,               TMS320C64x_ILC,  TMS320C64x_RILC,  TMS320C64x_REP,
 
  107         TMS320C64x_PCE1,   TMS320C64x_DNUM, ~0U,              ~0U,
 
  108         ~0U,               TMS320C64x_SSR,  TMS320C64x_GPLYA, TMS320C64x_GPLYB,
 
  109         TMS320C64x_GFPGFR, TMS320C64x_DIER, TMS320C64x_TSR,   TMS320C64x_ITSR,
 
  110         TMS320C64x_NTSR,   TMS320C64x_ECR,  ~0U,              TMS320C64x_IERR
 
  119 static unsigned getReg(
const unsigned *RegTable, 
unsigned RegNo)
 
  123         return RegTable[RegNo];
 
  134         Reg = getReg(GPRegsDecoderTable, RegNo);
 
  150         Reg = getReg(ControlRegsDecoderTable, RegNo);
 
  165         if(imm & (1 << (5 - 1)))
 
  166                 imm |= ~((1 << 5) - 1);
 
  180         if(imm & (1 << (16 - 1)))
 
  181                 imm |= ~((1 << 16) - 1);
 
  195         if(imm & (1 << (7 - 1)))
 
  196                 imm |= ~((1 << 7) - 1);
 
  211         if(imm & (1 << (10 - 1)))
 
  212                 imm |= ~((1 << 10) - 1);
 
  227         if(imm & (1 << (12 - 1)))
 
  228                 imm |= ~((1 << 12) - 1);
 
  243         if(imm & (1 << (21 - 1)))
 
  244                 imm |= ~((1 << 21) - 1);
 
  255         return DecodeMemOperandSc(Inst, Val | (1 << 15), 
Address, Decoder);
 
  262         unsigned basereg, offsetreg;
 
  264         scaled = (Val >> 15) & 1;
 
  265         base = (Val >> 10) & 0x1f;
 
  266         offset = (Val >> 5) & 0x1f;
 
  267         mode = (Val >> 1) & 0xf;
 
  274         basereg = getReg(GPRegsDecoderTable, 
base);
 
  297                         offsetreg = getReg(GPRegsDecoderTable, 
offset);
 
  298                         if (offsetreg ==  ~0U)
 
  320         offset = (Val >> 1) & 0x7fff;
 
  334         Reg = getReg(GPRegsDecoderTable, RegNo);
 
  348         Reg = getReg(GPRegsDecoderTable, RegNo << 1);
 
  404                         Inst->
flat_insn->detail->tms320c64x.condition.zero = 0;
 
  407                         Inst->
flat_insn->detail->tms320c64x.condition.zero = 1;
 
  410                         Inst->
flat_insn->detail->tms320c64x.condition.zero = 0;
 
  427                 for(
i = 0; 
i < Inst->
size; 
i++) {
 
  429                         if(
op->Kind == kRegister) {
 
  443                         Inst->
flat_insn->detail->tms320c64x.funit.side = 1;
 
  446                         Inst->
flat_insn->detail->tms320c64x.funit.side = 2;
 
  449                         Inst->
flat_insn->detail->tms320c64x.funit.side = 0;
 
  467                         Inst->
flat_insn->detail->tms320c64x.parallel = 0;
 
  470                         Inst->
flat_insn->detail->tms320c64x.parallel = 1;
 
  473                         Inst->
flat_insn->detail->tms320c64x.parallel = -1;
 
  492                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 0;
 
  495                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 1;
 
  497                         if(
op->Kind == kRegister) {
 
  505                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = -1;
 
  524                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 0;
 
  527                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 1;
 
  529                         if(
op->Kind == kRegister) {
 
  537                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = -1;
 
  556                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 0;
 
  559                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = 2;
 
  561                         if(
op->Kind == kRegister) {
 
  569                         Inst->
flat_insn->detail->tms320c64x.funit.crosspath = -1;
 
  586 #define GET_INSTRINFO_ENUM 
  587 #include "TMS320C64xGenInstrInfo.inc" 
  604         result = decodeInstruction_4(DecoderTable32, MI, insn, address, info, 0);
 
  620                         TMS320C64xMCRegisterClasses, 7,
 
  622                         TMS320C64xRegDiffLists,
 
  624                         TMS320C64xSubRegIdxLists, 1,