mmix-opc.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /* mmix-opc.c -- MMIX opcode table
  2. Copyright (C) 2001-2022 Free Software Foundation, Inc.
  3. Written by Hans-Peter Nilsson (hp@bitrange.com)
  4. This file is part of the GNU opcodes library.
  5. This library is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. It is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  12. 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 COPYING. If not, write to the
  15. Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. #include <stdio.h>
  18. #include "opcode/mmix.h"
  19. #include "symcat.h"
  20. /* Register-name-table for special registers. */
  21. const struct mmix_spec_reg mmix_spec_regs[] =
  22. {
  23. /* Keep rJ at top; it's the most frequently used one. */
  24. {"rJ", 4},
  25. {"rA", 21},
  26. {"rB", 0},
  27. {"rC", 8},
  28. {"rD", 1},
  29. {"rE", 2},
  30. {"rF", 22},
  31. {"rG", 19},
  32. {"rH", 3},
  33. {"rI", 12},
  34. {"rK", 15},
  35. {"rL", 20},
  36. {"rM", 5},
  37. {"rN", 9},
  38. {"rO", 10},
  39. {"rP", 23},
  40. {"rQ", 16},
  41. {"rR", 6},
  42. {"rS", 11},
  43. {"rT", 13},
  44. {"rU", 17},
  45. {"rV", 18},
  46. {"rW", 24},
  47. {"rX", 25},
  48. {"rY", 26},
  49. {"rZ", 27},
  50. {"rBB", 7},
  51. {"rTT", 14},
  52. {"rWW", 28},
  53. {"rXX", 29},
  54. {"rYY", 30},
  55. {"rZZ", 31},
  56. {NULL, 0}
  57. };
  58. /* Opcode-table. In order to cut down on redundant contents, we use helper
  59. macros. */
  60. /* All bits in the opcode-byte are significant. Add "| ..." expressions
  61. to add zero-bits. */
  62. #undef O
  63. #define O(m) ((unsigned long) (m) << 24UL), ((~(unsigned long) (m) & 255) << 24)
  64. /* Bits 7..1 of the opcode are significant. */
  65. #undef Z
  66. #define Z(m) ((unsigned long) (m) << 24), ((~(unsigned long) (m) & 254) << 24)
  67. /* For easier overview of the table. */
  68. #define N mmix_type_normal
  69. #define B mmix_type_branch
  70. #define C mmix_type_condbranch
  71. #define MB mmix_type_memaccess_byte
  72. #define MW mmix_type_memaccess_wyde
  73. #define MT mmix_type_memaccess_tetra
  74. #define MO mmix_type_memaccess_octa
  75. #define M mmix_type_memaccess_block
  76. #define J mmix_type_jsr
  77. #define P mmix_type_pseudo
  78. #define OP(y) XCONCAT2 (mmix_operands_,y)
  79. /* Groups of instructions specified here must, if all are matching the
  80. same instruction, be consecutive, in order more-specific to
  81. less-specific match. */
  82. const struct mmix_opcode mmix_opcodes[] =
  83. {
  84. {"trap", O (0), OP (xyz_opt), J},
  85. {"fcmp", O (1), OP (regs), N},
  86. {"flot", Z (8), OP (roundregs_z), N},
  87. {"fun", O (2), OP (regs), N},
  88. {"feql", O (3), OP (regs), N},
  89. {"flotu", Z (10), OP (roundregs_z), N},
  90. {"fadd", O (4), OP (regs), N},
  91. {"fix", O (5), OP (roundregs), N},
  92. {"sflot", Z (12), OP (roundregs_z), N},
  93. {"fsub", O (6), OP (regs), N},
  94. {"fixu", O (7), OP (roundregs), N},
  95. {"sflotu", Z (14), OP (roundregs_z), N},
  96. {"fmul", O (16), OP (regs), N},
  97. {"fcmpe", O (17), OP (regs), N},
  98. {"mul", Z (24), OP (regs_z), N},
  99. {"fune", O (18), OP (regs), N},
  100. {"feqle", O (19), OP (regs), N},
  101. {"mulu", Z (26), OP (regs_z), N},
  102. {"fdiv", O (20), OP (regs), N},
  103. {"fsqrt", O (21), OP (roundregs), N},
  104. {"div", Z (28), OP (regs_z), N},
  105. {"frem", O (22), OP (regs), N},
  106. {"fint", O (23), OP (roundregs), N},
  107. {"divu", Z (30), OP (regs_z), N},
  108. {"add", Z (0x20), OP (regs_z), N},
  109. {"2addu", Z (0x28), OP (regs_z), N},
  110. {"addu", Z (0x22), OP (regs_z), N},
  111. /* Synonym for ADDU. Put after ADDU, since we don't prefer it for
  112. disassembly. It's supposed to be used for addresses, so we make it
  113. a memory block reference for purposes of assembly. */
  114. {"lda", Z (0x22), OP (regs_z_opt), M},
  115. {"4addu", Z (0x2a), OP (regs_z), N},
  116. {"sub", Z (0x24), OP (regs_z), N},
  117. {"8addu", Z (0x2c), OP (regs_z), N},
  118. {"subu", Z (0x26), OP (regs_z), N},
  119. {"16addu", Z (0x2e), OP (regs_z), N},
  120. {"cmp", Z (0x30), OP (regs_z), N},
  121. {"sl", Z (0x38), OP (regs_z), N},
  122. {"cmpu", Z (0x32), OP (regs_z), N},
  123. {"slu", Z (0x3a), OP (regs_z), N},
  124. {"neg", Z (0x34), OP (neg), N},
  125. {"sr", Z (0x3c), OP (regs_z), N},
  126. {"negu", Z (0x36), OP (neg), N},
  127. {"sru", Z (0x3e), OP (regs_z), N},
  128. {"bn", Z (0x40), OP (regaddr), C},
  129. {"bnn", Z (0x48), OP (regaddr), C},
  130. {"bz", Z (0x42), OP (regaddr), C},
  131. {"bnz", Z (0x4a), OP (regaddr), C},
  132. {"bp", Z (0x44), OP (regaddr), C},
  133. {"bnp", Z (0x4c), OP (regaddr), C},
  134. {"bod", Z (0x46), OP (regaddr), C},
  135. {"bev", Z (0x4e), OP (regaddr), C},
  136. {"pbn", Z (0x50), OP (regaddr), C},
  137. {"pbnn", Z (0x58), OP (regaddr), C},
  138. {"pbz", Z (0x52), OP (regaddr), C},
  139. {"pbnz", Z (0x5a), OP (regaddr), C},
  140. {"pbp", Z (0x54), OP (regaddr), C},
  141. {"pbnp", Z (0x5c), OP (regaddr), C},
  142. {"pbod", Z (0x56), OP (regaddr), C},
  143. {"pbev", Z (0x5e), OP (regaddr), C},
  144. {"csn", Z (0x60), OP (regs_z), N},
  145. {"csnn", Z (0x68), OP (regs_z), N},
  146. {"csz", Z (0x62), OP (regs_z), N},
  147. {"csnz", Z (0x6a), OP (regs_z), N},
  148. {"csp", Z (0x64), OP (regs_z), N},
  149. {"csnp", Z (0x6c), OP (regs_z), N},
  150. {"csod", Z (0x66), OP (regs_z), N},
  151. {"csev", Z (0x6e), OP (regs_z), N},
  152. {"zsn", Z (0x70), OP (regs_z), N},
  153. {"zsnn", Z (0x78), OP (regs_z), N},
  154. {"zsz", Z (0x72), OP (regs_z), N},
  155. {"zsnz", Z (0x7a), OP (regs_z), N},
  156. {"zsp", Z (0x74), OP (regs_z), N},
  157. {"zsnp", Z (0x7c), OP (regs_z), N},
  158. {"zsod", Z (0x76), OP (regs_z), N},
  159. {"zsev", Z (0x7e), OP (regs_z), N},
  160. {"ldb", Z (0x80), OP (regs_z_opt), MB},
  161. {"ldt", Z (0x88), OP (regs_z_opt), MT},
  162. {"ldbu", Z (0x82), OP (regs_z_opt), MB},
  163. {"ldtu", Z (0x8a), OP (regs_z_opt), MT},
  164. {"ldw", Z (0x84), OP (regs_z_opt), MW},
  165. {"ldo", Z (0x8c), OP (regs_z_opt), MO},
  166. {"ldwu", Z (0x86), OP (regs_z_opt), MW},
  167. {"ldou", Z (0x8e), OP (regs_z_opt), MO},
  168. {"ldsf", Z (0x90), OP (regs_z_opt), MT},
  169. /* This doesn't seem to access memory, just the TLB. */
  170. {"ldvts", Z (0x98), OP (regs_z_opt), M},
  171. {"ldht", Z (0x92), OP (regs_z_opt), MT},
  172. /* Neither does this per-se. */
  173. {"preld", Z (0x9a), OP (x_regs_z), N},
  174. {"cswap", Z (0x94), OP (regs_z_opt), MO},
  175. {"prego", Z (0x9c), OP (x_regs_z), N},
  176. {"ldunc", Z (0x96), OP (regs_z_opt), MO},
  177. {"go", Z (GO_INSN_BYTE),
  178. OP (regs_z_opt), B},
  179. {"stb", Z (0xa0), OP (regs_z_opt), MB},
  180. {"stt", Z (0xa8), OP (regs_z_opt), MT},
  181. {"stbu", Z (0xa2), OP (regs_z_opt), MB},
  182. {"sttu", Z (0xaa), OP (regs_z_opt), MT},
  183. {"stw", Z (0xa4), OP (regs_z_opt), MW},
  184. {"sto", Z (0xac), OP (regs_z_opt), MO},
  185. {"stwu", Z (0xa6), OP (regs_z_opt), MW},
  186. {"stou", Z (0xae), OP (regs_z_opt), MO},
  187. {"stsf", Z (0xb0), OP (regs_z_opt), MT},
  188. {"syncd", Z (0xb8), OP (x_regs_z), M},
  189. {"stht", Z (0xb2), OP (regs_z_opt), MT},
  190. {"prest", Z (0xba), OP (x_regs_z), M},
  191. {"stco", Z (0xb4), OP (x_regs_z), MO},
  192. {"syncid", Z (0xbc), OP (x_regs_z), M},
  193. {"stunc", Z (0xb6), OP (regs_z_opt), MO},
  194. {"pushgo", Z (PUSHGO_INSN_BYTE),
  195. OP (pushgo), J},
  196. /* Synonym for OR with a zero Z. */
  197. {"set", O (0xc1)
  198. | 0xff, OP (set), N},
  199. {"or", Z (0xc0), OP (regs_z), N},
  200. {"and", Z (0xc8), OP (regs_z), N},
  201. {"orn", Z (0xc2), OP (regs_z), N},
  202. {"andn", Z (0xca), OP (regs_z), N},
  203. {"nor", Z (0xc4), OP (regs_z), N},
  204. {"nand", Z (0xcc), OP (regs_z), N},
  205. {"xor", Z (0xc6), OP (regs_z), N},
  206. {"nxor", Z (0xce), OP (regs_z), N},
  207. {"bdif", Z (0xd0), OP (regs_z), N},
  208. {"mux", Z (0xd8), OP (regs_z), N},
  209. {"wdif", Z (0xd2), OP (regs_z), N},
  210. {"sadd", Z (0xda), OP (regs_z), N},
  211. {"tdif", Z (0xd4), OP (regs_z), N},
  212. {"mor", Z (0xdc), OP (regs_z), N},
  213. {"odif", Z (0xd6), OP (regs_z), N},
  214. {"mxor", Z (0xde), OP (regs_z), N},
  215. {"seth", O (0xe0), OP (reg_yz), N},
  216. {"setmh", O (0xe1), OP (reg_yz), N},
  217. {"orh", O (0xe8), OP (reg_yz), N},
  218. {"ormh", O (0xe9), OP (reg_yz), N},
  219. {"setml", O (0xe2), OP (reg_yz), N},
  220. {"setl", O (SETL_INSN_BYTE),
  221. OP (reg_yz), N},
  222. {"orml", O (0xea), OP (reg_yz), N},
  223. {"orl", O (0xeb), OP (reg_yz), N},
  224. {"inch", O (INCH_INSN_BYTE),
  225. OP (reg_yz), N},
  226. {"incmh", O (INCMH_INSN_BYTE),
  227. OP (reg_yz), N},
  228. {"andnh", O (0xec), OP (reg_yz), N},
  229. {"andnmh", O (0xed), OP (reg_yz), N},
  230. {"incml", O (INCML_INSN_BYTE),
  231. OP (reg_yz), N},
  232. {"incl", O (0xe7), OP (reg_yz), N},
  233. {"andnml", O (0xee), OP (reg_yz), N},
  234. {"andnl", O (0xef), OP (reg_yz), N},
  235. {"jmp", Z (0xf0), OP (jmp), B},
  236. {"pop", O (0xf8), OP (pop), B},
  237. {"resume", O (0xf9)
  238. | 0xffff00, OP (resume), B},
  239. {"pushj", Z (0xf2), OP (pushj), J},
  240. {"save", O (0xfa)
  241. | 0xffff, OP (save), M},
  242. {"unsave", O (0xfb)
  243. | 0xffff00, OP (unsave), M},
  244. {"geta", Z (0xf4), OP (regaddr), N},
  245. {"sync", O (0xfc), OP (sync), N},
  246. {"swym", O (SWYM_INSN_BYTE),
  247. OP (xyz_opt), N},
  248. {"put", Z (0xf6) | 0xff00, OP (put), N},
  249. {"get", O (0xfe) | 0xffe0, OP (get), N},
  250. {"trip", O (0xff), OP (xyz_opt), J},
  251. /* We have mmixal pseudos in the ordinary instruction table so we can
  252. avoid the "set" vs. ".set" ambiguity that would be the effect if we
  253. had pseudos handled "normally" and defined NO_PSEUDO_DOT.
  254. Note that IS and GREG are handled fully by md_start_line_hook, so
  255. they're not here. */
  256. {"loc", ~0, ~0, OP (loc), P},
  257. {"prefix", ~0, ~0, OP (prefix), P},
  258. {"byte", ~0, ~0, OP (byte), P},
  259. {"wyde", ~0, ~0, OP (wyde), P},
  260. {"tetra", ~0, ~0, OP (tetra), P},
  261. {"octa", ~0, ~0, OP (octa), P},
  262. {"local", ~0, ~0, OP (local), P},
  263. {"bspec", ~0, ~0, OP (bspec), P},
  264. {"espec", ~0, ~0, OP (espec), P},
  265. {NULL, ~0, ~0, OP (none), N}
  266. };