1*3d8817e4Smiod /* tic54x.h -- Header file for TI TMS320C54X opcode table 2*3d8817e4Smiod Copyright 1999, 2000, 2001 Free Software Foundation, Inc. 3*3d8817e4Smiod Written by Timothy Wall (twall@cygnus.com) 4*3d8817e4Smiod 5*3d8817e4Smiod This file is part of GDB, GAS, and the GNU binutils. 6*3d8817e4Smiod 7*3d8817e4Smiod GDB, GAS, and the GNU binutils are free software; you can redistribute 8*3d8817e4Smiod them and/or modify them under the terms of the GNU General Public 9*3d8817e4Smiod License as published by the Free Software Foundation; either version 10*3d8817e4Smiod 1, or (at your option) any later version. 11*3d8817e4Smiod 12*3d8817e4Smiod GDB, GAS, and the GNU binutils are distributed in the hope that they 13*3d8817e4Smiod will be useful, but WITHOUT ANY WARRANTY; without even the implied 14*3d8817e4Smiod warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 15*3d8817e4Smiod the GNU General Public License for more details. 16*3d8817e4Smiod 17*3d8817e4Smiod You should have received a copy of the GNU General Public License 18*3d8817e4Smiod along with this file; see the file COPYING. If not, write to the Free 19*3d8817e4Smiod Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 20*3d8817e4Smiod 02110-1301, USA. */ 21*3d8817e4Smiod 22*3d8817e4Smiod #ifndef _opcode_tic54x_h_ 23*3d8817e4Smiod #define _opcode_tic54x_h_ 24*3d8817e4Smiod 25*3d8817e4Smiod typedef struct _symbol 26*3d8817e4Smiod { 27*3d8817e4Smiod const char *name; 28*3d8817e4Smiod unsigned short value; 29*3d8817e4Smiod } symbol; 30*3d8817e4Smiod 31*3d8817e4Smiod enum optype { 32*3d8817e4Smiod OPT = 0x8000, 33*3d8817e4Smiod OP_None = 0x0, 34*3d8817e4Smiod 35*3d8817e4Smiod OP_Xmem, /* AR3 or AR4, indirect */ 36*3d8817e4Smiod OP_Ymem, /* AR3 or AR4, indirect */ 37*3d8817e4Smiod OP_pmad, /* PROG mem, direct */ 38*3d8817e4Smiod OP_dmad, /* DATA mem, direct */ 39*3d8817e4Smiod OP_Smem, 40*3d8817e4Smiod OP_Lmem, /* 32-bit single-addressed (direct/indirect) */ 41*3d8817e4Smiod OP_MMR, 42*3d8817e4Smiod OP_PA, 43*3d8817e4Smiod OP_Sind, 44*3d8817e4Smiod OP_xpmad, 45*3d8817e4Smiod OP_xpmad_ms7, 46*3d8817e4Smiod OP_MMRX, 47*3d8817e4Smiod OP_MMRY, 48*3d8817e4Smiod 49*3d8817e4Smiod OP_SRC1, /* src accumulator in bit 8 */ 50*3d8817e4Smiod OP_SRC, /* src accumulator in bit 9 */ 51*3d8817e4Smiod OP_RND, /* rounded result dst accumulator, opposite of bit 8 */ 52*3d8817e4Smiod OP_DST, /* dst accumulator in bit 8 */ 53*3d8817e4Smiod OP_ARX, /* arX in bits 0-3 */ 54*3d8817e4Smiod OP_SHIFT, /* -16 to 15 (SHIFT), bits 0-4 */ 55*3d8817e4Smiod OP_SHFT, /* 0 to 15 (SHIFT1 in summary), bits 0-3 */ 56*3d8817e4Smiod OP_B, /* ACC B only */ 57*3d8817e4Smiod OP_A, /* ACC A only */ 58*3d8817e4Smiod 59*3d8817e4Smiod OP_lk, /* 16-bit immediate, '#' optional */ 60*3d8817e4Smiod OP_TS, 61*3d8817e4Smiod OP_k8, /* -128 <= k <= 128 */ 62*3d8817e4Smiod OP_16, /* literal "16" */ 63*3d8817e4Smiod OP_BITC, /* 0 to 16 */ 64*3d8817e4Smiod OP_CC, /* condition code */ 65*3d8817e4Smiod OP_CC2, /* 4-bit condition code */ 66*3d8817e4Smiod OP_CC3, /* 2-bit condition code */ 67*3d8817e4Smiod OP_123, /* 1, 2, or 3 */ 68*3d8817e4Smiod OP_031, /* 0-31, numeric */ 69*3d8817e4Smiod OP_k5, /* 0 to 31 */ 70*3d8817e4Smiod OP_k8u, /* 0 to 255 */ 71*3d8817e4Smiod OP_ASM, /* "ASM" */ 72*3d8817e4Smiod OP_T, /* "T" */ 73*3d8817e4Smiod OP_DP, /* "DP" */ 74*3d8817e4Smiod OP_ARP, /* "ARP" */ 75*3d8817e4Smiod OP_k3, /* 0-7 */ 76*3d8817e4Smiod OP_lku, /* 0 to 65535 */ 77*3d8817e4Smiod OP_N, /* 0/1 or ST0/ST1 */ 78*3d8817e4Smiod OP_SBIT, /* status bit or 0-15 */ 79*3d8817e4Smiod OP_12, /* one or two */ 80*3d8817e4Smiod OP_k9, /* 9 bits of data page (DP) address */ 81*3d8817e4Smiod OP_TRN, /* "TRN" */ 82*3d8817e4Smiod 83*3d8817e4Smiod }; 84*3d8817e4Smiod 85*3d8817e4Smiod typedef struct _template 86*3d8817e4Smiod { 87*3d8817e4Smiod /* The opcode mnemonic */ 88*3d8817e4Smiod const char *name; 89*3d8817e4Smiod unsigned int words; /* insn size in words */ 90*3d8817e4Smiod int minops, maxops; /* min/max operand count */ 91*3d8817e4Smiod /* The significant bits in the opcode. Other bits are zero. 92*3d8817e4Smiod Instructions with more than 16 bits of opcode store the rest in the upper 93*3d8817e4Smiod 16 bits. 94*3d8817e4Smiod */ 95*3d8817e4Smiod unsigned short opcode; 96*3d8817e4Smiod #define INDIRECT(OP) ((OP)&0x80) 97*3d8817e4Smiod #define MOD(OP) (((OP)>>3)&0xF) 98*3d8817e4Smiod #define ARF(OP) ((OP)&0x7) 99*3d8817e4Smiod #define IS_LKADDR(OP) (INDIRECT(OP) && MOD(OP)>=12) 100*3d8817e4Smiod #define SRC(OP) ((OP)&0x200) 101*3d8817e4Smiod #define DST(OP) ((OP)&0x100) 102*3d8817e4Smiod #define SRC1(OP) ((OP)&0x100) 103*3d8817e4Smiod #define SHIFT(OP) (((OP)&0x10)?(((OP)&0x1F)-32):((OP)&0x1F)) 104*3d8817e4Smiod #define SHFT(OP) ((OP)&0xF) 105*3d8817e4Smiod #define ARX(OP) ((OP)&0x7) 106*3d8817e4Smiod #define XMEM(OP) (((OP)&0x00F0)>>4) 107*3d8817e4Smiod #define YMEM(OP) ((OP)&0x000F) 108*3d8817e4Smiod #define XMOD(C) (((C)&0xC)>>2) 109*3d8817e4Smiod #define XARX(C) (((C)&0x3)+2) 110*3d8817e4Smiod #define CC3(OP) (((OP)>>8)&0x3) 111*3d8817e4Smiod #define SBIT(OP) ((OP)&0xF) 112*3d8817e4Smiod #define MMR(OP) ((OP)&0x7F) 113*3d8817e4Smiod #define MMRX(OP) ((((OP)>>4)&0xF)+16) 114*3d8817e4Smiod #define MMRY(OP) (((OP)&0xF)+16) 115*3d8817e4Smiod 116*3d8817e4Smiod #define OPTYPE(X) ((X)&~OPT) 117*3d8817e4Smiod 118*3d8817e4Smiod /* Ones in this mask indicate which bits must match the opcode field. 119*3d8817e4Smiod Zeroes indicate don't care bits (operands and/or opcode options) */ 120*3d8817e4Smiod unsigned short mask; 121*3d8817e4Smiod 122*3d8817e4Smiod /* An array of operand codes (at most 4 operands) */ 123*3d8817e4Smiod #define MAX_OPERANDS 4 124*3d8817e4Smiod enum optype operand_types[MAX_OPERANDS]; 125*3d8817e4Smiod 126*3d8817e4Smiod /* Special purpose flags (e.g. branch type, parallel, delay, etc) 127*3d8817e4Smiod */ 128*3d8817e4Smiod unsigned short flags; 129*3d8817e4Smiod #define B_NEXT 0 /* normal execution, next insn is next address */ 130*3d8817e4Smiod #define B_BRANCH 1 /* next insn is in opcode */ 131*3d8817e4Smiod #define B_RET 2 /* next insn is on stack */ 132*3d8817e4Smiod #define B_BACC 3 /* next insn is in acc */ 133*3d8817e4Smiod #define B_REPEAT 4 /* next insn repeats */ 134*3d8817e4Smiod #define FL_BMASK 0x07 135*3d8817e4Smiod 136*3d8817e4Smiod #define FL_DELAY 0x10 /* instruction uses delay slots */ 137*3d8817e4Smiod #define FL_EXT 0x20 /* instruction takes two words */ 138*3d8817e4Smiod #define FL_FAR 0x40 /* far mode addressing */ 139*3d8817e4Smiod #define FL_LP 0x80 /* LP-only instruction */ 140*3d8817e4Smiod #define FL_NR 0x100 /* no repeat allowed */ 141*3d8817e4Smiod #define FL_SMR 0x200 /* Smem read (for flagging write-only *+ARx */ 142*3d8817e4Smiod 143*3d8817e4Smiod #define FL_PAR 0x400 /* Parallel instruction. */ 144*3d8817e4Smiod 145*3d8817e4Smiod unsigned short opcode2, mask2; /* some insns have an extended opcode */ 146*3d8817e4Smiod 147*3d8817e4Smiod const char* parname; 148*3d8817e4Smiod enum optype paroperand_types[MAX_OPERANDS]; 149*3d8817e4Smiod 150*3d8817e4Smiod } template; 151*3d8817e4Smiod 152*3d8817e4Smiod extern const template tic54x_unknown_opcode; 153*3d8817e4Smiod extern const template tic54x_optab[]; 154*3d8817e4Smiod extern const template tic54x_paroptab[]; 155*3d8817e4Smiod extern const symbol mmregs[], regs[]; 156*3d8817e4Smiod extern const symbol condition_codes[], cc2_codes[], status_bits[]; 157*3d8817e4Smiod extern const symbol cc3_codes[]; 158*3d8817e4Smiod extern const char *misc_symbols[]; 159*3d8817e4Smiod struct disassemble_info; 160*3d8817e4Smiod extern const template* tic54x_get_insn (struct disassemble_info *, 161*3d8817e4Smiod bfd_vma, unsigned short, int *); 162*3d8817e4Smiod 163*3d8817e4Smiod #endif /* _opcode_tic54x_h_ */ 164