tic54x.h 5.4 KB

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