dlx.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* Table of opcodes for the DLX microprocess.
  2. Copyright (C) 2002-2015 Free Software Foundation, Inc.
  3. This file is part of GDB and GAS.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA.
  16. Initially created by Kuang Hwa Lin, 2002. */
  17. /* Following are the function codes for the Special OP (ALU). */
  18. #define ALUOP 0x00000000
  19. #define SPECIALOP 0x00000000
  20. #define NOPF 0x00000000
  21. #define SLLF 0x00000004
  22. #define SRLF 0x00000006
  23. #define SRAF 0x00000007
  24. #define SEQUF 0x00000010
  25. #define SNEUF 0x00000011
  26. #define SLTUF 0x00000012
  27. #define SGTUF 0x00000013
  28. #define SLEUF 0x00000014
  29. #define SGEUF 0x00000015
  30. #define ADDF 0x00000020
  31. #define ADDUF 0x00000021
  32. #define SUBF 0x00000022
  33. #define SUBUF 0x00000023
  34. #define ANDF 0x00000024
  35. #define ORF 0x00000025
  36. #define XORF 0x00000026
  37. #define SEQF 0x00000028
  38. #define SNEF 0x00000029
  39. #define SLTF 0x0000002A
  40. #define SGTF 0x0000002B
  41. #define SLEF 0x0000002C
  42. #define SGEF 0x0000002D
  43. /* Following special functions was not mentioned in the
  44. Hennessy's book but was implemented in the RTL. */
  45. #define MVTSF 0x00000030
  46. #define MVFSF 0x00000031
  47. #define BSWAPF 0x00000032
  48. #define LUTF 0x00000033
  49. /* Following special functions was mentioned in the
  50. Hennessy's book but was not implemented in the RTL. */
  51. #define MULTF 0x00000005
  52. #define MULTUF 0x00000006
  53. #define DIVF 0x00000007
  54. #define DIVUF 0x00000008
  55. /* Following are the rest of the OPcodes:
  56. JOP = (0x002 << 26), JALOP = (0x003 << 26), BEQOP = (0x004 << 26), BNEOP = (0x005 << 26)
  57. ADDIOP = (0x008 << 26), ADDUIOP= (0x009 << 26), SUBIOP = (0x00A << 26), SUBUIOP= (0x00B << 26)
  58. ANDIOP = (0x00C << 26), ORIOP = (0x00D << 26), XORIOP = (0x00E << 26), LHIOP = (0x00F << 26)
  59. RFEOP = (0x010 << 26), TRAPOP = (0x011 << 26), JROP = (0x012 << 26), JALROP = (0x013 << 26)
  60. BREAKOP= (0x014 << 26)
  61. SEQIOP = (0x018 << 26), SNEIOP = (0x019 << 26), SLTIOP = (0x01A << 26), SGTIOP = (0x01B << 26)
  62. SLEIOP = (0x01C << 26), SGEIOP = (0x01D << 26)
  63. LBOP = (0x020 << 26), LHOP = (0x021 << 26), LWOP = (0x023 << 26), LBUOP = (0x024 << 26)
  64. LHUOP = (0x025 << 26), SBOP = (0x028 << 26), SHOP = (0x029 << 26), SWOP = (0x02B << 26)
  65. LSBUOP = (0x026 << 26), LSHU = (0x027 << 26), LSW = (0x02C << 26),
  66. SEQUIOP= (0x030 << 26), SNEUIOP= (0x031 << 26), SLTUIOP= (0x032 << 26), SGTUIOP= (0x033 << 26)
  67. SLEUIOP= (0x034 << 26), SGEUIOP= (0x035 << 26)
  68. SLLIOP = (0x036 << 26), SRLIOP = (0x037 << 26), SRAIOP = (0x038 << 26). */
  69. #define JOP 0x08000000
  70. #define JALOP 0x0c000000
  71. #define BEQOP 0x10000000
  72. #define BNEOP 0x14000000
  73. #define ADDIOP 0x20000000
  74. #define ADDUIOP 0x24000000
  75. #define SUBIOP 0x28000000
  76. #define SUBUIOP 0x2c000000
  77. #define ANDIOP 0x30000000
  78. #define ORIOP 0x34000000
  79. #define XORIOP 0x38000000
  80. #define LHIOP 0x3c000000
  81. #define RFEOP 0x40000000
  82. #define TRAPOP 0x44000000
  83. #define JROP 0x48000000
  84. #define JALROP 0x4c000000
  85. #define BREAKOP 0x50000000
  86. #define SEQIOP 0x60000000
  87. #define SNEIOP 0x64000000
  88. #define SLTIOP 0x68000000
  89. #define SGTIOP 0x6c000000
  90. #define SLEIOP 0x70000000
  91. #define SGEIOP 0x74000000
  92. #define LBOP 0x80000000
  93. #define LHOP 0x84000000
  94. #define LWOP 0x8c000000
  95. #define LBUOP 0x90000000
  96. #define LHUOP 0x94000000
  97. #define LDSTBU
  98. #define LDSTHU
  99. #define SBOP 0xa0000000
  100. #define SHOP 0xa4000000
  101. #define SWOP 0xac000000
  102. #define LDST
  103. #define SEQUIOP 0xc0000000
  104. #define SNEUIOP 0xc4000000
  105. #define SLTUIOP 0xc8000000
  106. #define SGTUIOP 0xcc000000
  107. #define SLEUIOP 0xd0000000
  108. #define SGEUIOP 0xd4000000
  109. #define SLLIOP 0xd8000000
  110. #define SRLIOP 0xdc000000
  111. #define SRAIOP 0xe0000000
  112. /* Following 3 ops was added to provide the MP atonmic operation. */
  113. #define LSBUOP 0x98000000
  114. #define LSHUOP 0x9c000000
  115. #define LSWOP 0xb0000000
  116. /* Following opcode was defined in the Hennessy's book as
  117. "normal" opcode but was implemented in the RTL as special
  118. functions. */
  119. #if 0
  120. #define MVTSOP 0x50000000
  121. #define MVFSOP 0x54000000
  122. #endif
  123. struct dlx_opcode
  124. {
  125. /* Name of the instruction. */
  126. char *name;
  127. /* Opcode word. */
  128. unsigned long opcode;
  129. /* A string of characters which describe the operands.
  130. Valid characters are:
  131. , Itself. The character appears in the assembly code.
  132. a rs1 The register number is in bits 21-25 of the instruction.
  133. b rs2/rd The register number is in bits 16-20 of the instruction.
  134. c rd. The register number is in bits 11-15 of the instruction.
  135. f FUNC bits 0-10 of the instruction.
  136. i An immediate operand is in bits 0-16 of the instruction. 0 extended
  137. I An immediate operand is in bits 0-16 of the instruction. sign extended
  138. d An 16 bit PC relative displacement.
  139. D An immediate operand is in bits 0-25 of the instruction.
  140. N No opperands needed, for nops.
  141. P it can be a register or a 16 bit operand. */
  142. char *args;
  143. };
  144. static const struct dlx_opcode dlx_opcodes[] =
  145. {
  146. /* Arithmetic and Logic R-TYPE instructions. */
  147. { "nop", (ALUOP|NOPF), "N" }, /* NOP */
  148. { "add", (ALUOP|ADDF), "c,a,b" }, /* Add */
  149. { "addu", (ALUOP|ADDUF), "c,a,b" }, /* Add Unsigned */
  150. { "sub", (ALUOP|SUBF), "c,a,b" }, /* SUB */
  151. { "subu", (ALUOP|SUBUF), "c,a,b" }, /* Sub Unsigned */
  152. { "mult", (ALUOP|MULTF), "c,a,b" }, /* MULTIPLY */
  153. { "multu", (ALUOP|MULTUF), "c,a,b" }, /* MULTIPLY Unsigned */
  154. { "div", (ALUOP|DIVF), "c,a,b" }, /* DIVIDE */
  155. { "divu", (ALUOP|DIVUF), "c,a,b" }, /* DIVIDE Unsigned */
  156. { "and", (ALUOP|ANDF), "c,a,b" }, /* AND */
  157. { "or", (ALUOP|ORF), "c,a,b" }, /* OR */
  158. { "xor", (ALUOP|XORF), "c,a,b" }, /* Exclusive OR */
  159. { "sll", (ALUOP|SLLF), "c,a,b" }, /* SHIFT LEFT LOGICAL */
  160. { "sra", (ALUOP|SRAF), "c,a,b" }, /* SHIFT RIGHT ARITHMETIC */
  161. { "srl", (ALUOP|SRLF), "c,a,b" }, /* SHIFT RIGHT LOGICAL */
  162. { "seq", (ALUOP|SEQF), "c,a,b" }, /* Set if equal */
  163. { "sne", (ALUOP|SNEF), "c,a,b" }, /* Set if not equal */
  164. { "slt", (ALUOP|SLTF), "c,a,b" }, /* Set if less */
  165. { "sgt", (ALUOP|SGTF), "c,a,b" }, /* Set if greater */
  166. { "sle", (ALUOP|SLEF), "c,a,b" }, /* Set if less or equal */
  167. { "sge", (ALUOP|SGEF), "c,a,b" }, /* Set if greater or equal */
  168. { "sequ", (ALUOP|SEQUF), "c,a,b" }, /* Set if equal unsigned */
  169. { "sneu", (ALUOP|SNEUF), "c,a,b" }, /* Set if not equal unsigned */
  170. { "sltu", (ALUOP|SLTUF), "c,a,b" }, /* Set if less unsigned */
  171. { "sgtu", (ALUOP|SGTUF), "c,a,b" }, /* Set if greater unsigned */
  172. { "sleu", (ALUOP|SLEUF), "c,a,b" }, /* Set if less or equal unsigned*/
  173. { "sgeu", (ALUOP|SGEUF), "c,a,b" }, /* Set if greater or equal */
  174. { "mvts", (ALUOP|MVTSF), "c,a" }, /* Move to special register */
  175. { "mvfs", (ALUOP|MVFSF), "c,a" }, /* Move from special register */
  176. { "bswap", (ALUOP|BSWAPF), "c,a,b" }, /* ??? Was not documented */
  177. { "lut", (ALUOP|LUTF), "c,a,b" }, /* ????? same as above */
  178. /* Arithmetic and Logical Immediate I-TYPE instructions. */
  179. { "addi", ADDIOP, "b,a,I" }, /* Add Immediate */
  180. { "addui", ADDUIOP, "b,a,i" }, /* Add Usigned Immediate */
  181. { "subi", SUBIOP, "b,a,I" }, /* Sub Immediate */
  182. { "subui", SUBUIOP, "b,a,i" }, /* Sub Unsigned Immedated */
  183. { "andi", ANDIOP, "b,a,i" }, /* AND Immediate */
  184. { "ori", ORIOP, "b,a,i" }, /* OR Immediate */
  185. { "xori", XORIOP, "b,a,i" }, /* Exclusive OR Immediate */
  186. { "slli", SLLIOP, "b,a,i" }, /* SHIFT LEFT LOCICAL Immediate */
  187. { "srai", SRAIOP, "b,a,i" }, /* SHIFT RIGHT ARITH. Immediate */
  188. { "srli", SRLIOP, "b,a,i" }, /* SHIFT RIGHT LOGICAL Immediate*/
  189. { "seqi", SEQIOP, "b,a,i" }, /* Set if equal */
  190. { "snei", SNEIOP, "b,a,i" }, /* Set if not equal */
  191. { "slti", SLTIOP, "b,a,i" }, /* Set if less */
  192. { "sgti", SGTIOP, "b,a,i" }, /* Set if greater */
  193. { "slei", SLEIOP, "b,a,i" }, /* Set if less or equal */
  194. { "sgei", SGEIOP, "b,a,i" }, /* Set if greater or equal */
  195. { "sequi", SEQUIOP, "b,a,i" }, /* Set if equal */
  196. { "sneui", SNEUIOP, "b,a,i" }, /* Set if not equal */
  197. { "sltui", SLTUIOP, "b,a,i" }, /* Set if less */
  198. { "sgtui", SGTUIOP, "b,a,i" }, /* Set if greater */
  199. { "sleui", SLEUIOP, "b,a,i" }, /* Set if less or equal */
  200. { "sgeui", SGEUIOP, "b,a,i" }, /* Set if greater or equal */
  201. /* Macros for I type instructions. */
  202. { "mov", ADDIOP, "b,P" }, /* a move macro */
  203. { "movu", ADDUIOP, "b,P" }, /* a move macro, unsigned */
  204. #if 0
  205. /* Move special. */
  206. { "mvts", MVTSOP, "b,a" }, /* Move From Integer to Special */
  207. { "mvfs", MVFSOP, "b,a" }, /* Move From Special to Integer */
  208. #endif
  209. /* Load high Immediate I-TYPE instruction. */
  210. { "lhi", LHIOP, "b,i" }, /* Load High Immediate */
  211. { "lui", LHIOP, "b,i" }, /* Load High Immediate */
  212. { "sethi", LHIOP, "b,i" }, /* Load High Immediate */
  213. /* LOAD/STORE BYTE 8 bits I-TYPE. */
  214. { "lb", LBOP, "b,a,I" }, /* Load Byte */
  215. { "lbu", LBUOP, "b,a,I" }, /* Load Byte Unsigned */
  216. { "ldstbu", LSBUOP, "b,a,I" }, /* Load store Byte Unsigned */
  217. { "sb", SBOP, "b,a,I" }, /* Store Byte */
  218. /* LOAD/STORE HALFWORD 16 bits. */
  219. { "lh", LHOP, "b,a,I" }, /* Load Halfword */
  220. { "lhu", LHUOP, "b,a,I" }, /* Load Halfword Unsigned */
  221. { "ldsthu", LSHUOP, "b,a,I" }, /* Load Store Halfword Unsigned */
  222. { "sh", SHOP, "b,a,I" }, /* Store Halfword */
  223. /* LOAD/STORE WORD 32 bits. */
  224. { "lw", LWOP, "b,a,I" }, /* Load Word */
  225. { "sw", SWOP, "b,a,I" }, /* Store Word */
  226. { "ldstw", LSWOP, "b,a,I" }, /* Load Store Word */
  227. /* Branch PC-relative, 16 bits offset. */
  228. { "beqz", BEQOP, "a,d" }, /* Branch if a == 0 */
  229. { "bnez", BNEOP, "a,d" }, /* Branch if a != 0 */
  230. { "beq", BEQOP, "a,d" }, /* Branch if a == 0 */
  231. { "bne", BNEOP, "a,d" }, /* Branch if a != 0 */
  232. /* Jumps Trap and RFE J-TYPE. */
  233. { "j", JOP, "D" }, /* Jump, PC-relative 26 bits */
  234. { "jal", JALOP, "D" }, /* JAL, PC-relative 26 bits */
  235. { "break", BREAKOP, "D" }, /* break to OS */
  236. { "trap" , TRAPOP, "D" }, /* TRAP to OS */
  237. { "rfe", RFEOP, "N" }, /* Return From Exception */
  238. /* Macros. */
  239. { "call", JOP, "D" }, /* Jump, PC-relative 26 bits */
  240. /* Jumps Trap and RFE I-TYPE. */
  241. { "jr", JROP, "a" }, /* Jump Register, Abs (32 bits) */
  242. { "jalr", JALROP, "a" }, /* JALR, Abs (32 bits) */
  243. /* Macros. */
  244. { "retr", JROP, "a" }, /* Jump Register, Abs (32 bits) */
  245. { "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES.
  246. This lets code examine entry i + 1 without
  247. checking if we've run off the end of the table. */
  248. };
  249. const unsigned int num_dlx_opcodes = (((sizeof dlx_opcodes) / (sizeof dlx_opcodes[0])) - 1);