tic80-opc.c 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. /* Opcode table for TI TMS320C80 (MVP).
  2. Copyright (C) 1996-2015 Free Software Foundation, Inc.
  3. This file is part of the GNU opcodes library.
  4. This library 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, or (at your option)
  7. any later version.
  8. It is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this file; see the file COPYING. If not, write to the
  14. Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #include "sysdep.h"
  17. #include <stdio.h>
  18. #include "opcode/tic80.h"
  19. /* This file holds various tables for the TMS320C80 (MVP).
  20. The opcode table is strictly constant data, so the compiler should
  21. be able to put it in the .text section.
  22. This file also holds the operand table. All knowledge about
  23. inserting operands into instructions and vice-versa is kept in this
  24. file.
  25. The predefined register table maps from register names to register
  26. values. */
  27. /* Table of predefined symbol names, such as general purpose registers,
  28. floating point registers, condition codes, control registers, and bit
  29. numbers.
  30. The table is sorted case independently by name so that it is suitable for
  31. searching via a binary search using a case independent comparison
  32. function.
  33. Note that the type of the symbol is stored in the upper bits of the value
  34. field, which allows the value and type to be passed around as a unit in a
  35. single int. The types have to be masked off before using the numeric
  36. value as a number.
  37. */
  38. const struct predefined_symbol tic80_predefined_symbols[] =
  39. {
  40. { "a0", TIC80_OPERAND_FPA | 0 },
  41. { "a1", TIC80_OPERAND_FPA | 1 },
  42. { "alw.b", TIC80_OPERAND_CC | 7 },
  43. { "alw.h", TIC80_OPERAND_CC | 15 },
  44. { "alw.w", TIC80_OPERAND_CC | 23 },
  45. { "ANASTAT", TIC80_OPERAND_CR | 0x34 },
  46. { "BRK1", TIC80_OPERAND_CR | 0x39 },
  47. { "BRK2", TIC80_OPERAND_CR | 0x3A },
  48. { "CONFIG", TIC80_OPERAND_CR | 2 },
  49. { "DLRU", TIC80_OPERAND_CR | 0x500 },
  50. { "DTAG0", TIC80_OPERAND_CR | 0x400 },
  51. { "DTAG1", TIC80_OPERAND_CR | 0x401 },
  52. { "DTAG10", TIC80_OPERAND_CR | 0x40A },
  53. { "DTAG11", TIC80_OPERAND_CR | 0x40B },
  54. { "DTAG12", TIC80_OPERAND_CR | 0x40C },
  55. { "DTAG13", TIC80_OPERAND_CR | 0x40D },
  56. { "DTAG14", TIC80_OPERAND_CR | 0x40E },
  57. { "DTAG15", TIC80_OPERAND_CR | 0x40F },
  58. { "DTAG2", TIC80_OPERAND_CR | 0x402 },
  59. { "DTAG3", TIC80_OPERAND_CR | 0x403 },
  60. { "DTAG4", TIC80_OPERAND_CR | 0x404 },
  61. { "DTAG5", TIC80_OPERAND_CR | 0x405 },
  62. { "DTAG6", TIC80_OPERAND_CR | 0x406 },
  63. { "DTAG7", TIC80_OPERAND_CR | 0x407 },
  64. { "DTAG8", TIC80_OPERAND_CR | 0x408 },
  65. { "DTAG9", TIC80_OPERAND_CR | 0x409 },
  66. { "ECOMCNTL", TIC80_OPERAND_CR | 0x33 },
  67. { "EIP", TIC80_OPERAND_CR | 1 },
  68. { "EPC", TIC80_OPERAND_CR | 0 },
  69. { "eq.b", TIC80_OPERAND_BITNUM | 0 },
  70. { "eq.f", TIC80_OPERAND_BITNUM | 20 },
  71. { "eq.h", TIC80_OPERAND_BITNUM | 10 },
  72. { "eq.w", TIC80_OPERAND_BITNUM | 20 },
  73. { "eq0.b", TIC80_OPERAND_CC | 2 },
  74. { "eq0.h", TIC80_OPERAND_CC | 10 },
  75. { "eq0.w", TIC80_OPERAND_CC | 18 },
  76. { "FLTADR", TIC80_OPERAND_CR | 0x11 },
  77. { "FLTDTH", TIC80_OPERAND_CR | 0x14 },
  78. { "FLTDTL", TIC80_OPERAND_CR | 0x13 },
  79. { "FLTOP", TIC80_OPERAND_CR | 0x10 },
  80. { "FLTTAG", TIC80_OPERAND_CR | 0x12 },
  81. { "FPST", TIC80_OPERAND_CR | 8 },
  82. { "ge.b", TIC80_OPERAND_BITNUM | 5 },
  83. { "ge.f", TIC80_OPERAND_BITNUM | 25 },
  84. { "ge.h", TIC80_OPERAND_BITNUM | 15 },
  85. { "ge.w", TIC80_OPERAND_BITNUM | 25 },
  86. { "ge0.b", TIC80_OPERAND_CC | 3 },
  87. { "ge0.h", TIC80_OPERAND_CC | 11 },
  88. { "ge0.w", TIC80_OPERAND_CC | 19 },
  89. { "gt.b", TIC80_OPERAND_BITNUM | 2 },
  90. { "gt.f", TIC80_OPERAND_BITNUM | 22 },
  91. { "gt.h", TIC80_OPERAND_BITNUM | 12 },
  92. { "gt.w", TIC80_OPERAND_BITNUM | 22 },
  93. { "gt0.b", TIC80_OPERAND_CC | 1 },
  94. { "gt0.h", TIC80_OPERAND_CC | 9 },
  95. { "gt0.w", TIC80_OPERAND_CC | 17 },
  96. { "hi.b", TIC80_OPERAND_BITNUM | 6 },
  97. { "hi.h", TIC80_OPERAND_BITNUM | 16 },
  98. { "hi.w", TIC80_OPERAND_BITNUM | 26 },
  99. { "hs.b", TIC80_OPERAND_BITNUM | 9 },
  100. { "hs.h", TIC80_OPERAND_BITNUM | 19 },
  101. { "hs.w", TIC80_OPERAND_BITNUM | 29 },
  102. { "ib.f", TIC80_OPERAND_BITNUM | 28 },
  103. { "IE", TIC80_OPERAND_CR | 6 },
  104. { "ILRU", TIC80_OPERAND_CR | 0x300 },
  105. { "in.f", TIC80_OPERAND_BITNUM | 27 },
  106. { "IN0P", TIC80_OPERAND_CR | 0x4000 },
  107. { "IN1P", TIC80_OPERAND_CR | 0x4001 },
  108. { "INTPEN", TIC80_OPERAND_CR | 4 },
  109. { "ITAG0", TIC80_OPERAND_CR | 0x200 },
  110. { "ITAG1", TIC80_OPERAND_CR | 0x201 },
  111. { "ITAG10", TIC80_OPERAND_CR | 0x20A },
  112. { "ITAG11", TIC80_OPERAND_CR | 0x20B },
  113. { "ITAG12", TIC80_OPERAND_CR | 0x20C },
  114. { "ITAG13", TIC80_OPERAND_CR | 0x20D },
  115. { "ITAG14", TIC80_OPERAND_CR | 0x20E },
  116. { "ITAG15", TIC80_OPERAND_CR | 0x20F },
  117. { "ITAG2", TIC80_OPERAND_CR | 0x202 },
  118. { "ITAG3", TIC80_OPERAND_CR | 0x203 },
  119. { "ITAG4", TIC80_OPERAND_CR | 0x204 },
  120. { "ITAG5", TIC80_OPERAND_CR | 0x205 },
  121. { "ITAG6", TIC80_OPERAND_CR | 0x206 },
  122. { "ITAG7", TIC80_OPERAND_CR | 0x207 },
  123. { "ITAG8", TIC80_OPERAND_CR | 0x208 },
  124. { "ITAG9", TIC80_OPERAND_CR | 0x209 },
  125. { "le.b", TIC80_OPERAND_BITNUM | 3 },
  126. { "le.f", TIC80_OPERAND_BITNUM | 23 },
  127. { "le.h", TIC80_OPERAND_BITNUM | 13 },
  128. { "le.w", TIC80_OPERAND_BITNUM | 23 },
  129. { "le0.b", TIC80_OPERAND_CC | 6 },
  130. { "le0.h", TIC80_OPERAND_CC | 14 },
  131. { "le0.w", TIC80_OPERAND_CC | 22 },
  132. { "lo.b", TIC80_OPERAND_BITNUM | 8 },
  133. { "lo.h", TIC80_OPERAND_BITNUM | 18 },
  134. { "lo.w", TIC80_OPERAND_BITNUM | 28 },
  135. { "ls.b", TIC80_OPERAND_BITNUM | 7 },
  136. { "ls.h", TIC80_OPERAND_BITNUM | 17 },
  137. { "ls.w", TIC80_OPERAND_BITNUM | 27 },
  138. { "lt.b", TIC80_OPERAND_BITNUM | 4 },
  139. { "lt.f", TIC80_OPERAND_BITNUM | 24 },
  140. { "lt.h", TIC80_OPERAND_BITNUM | 14 },
  141. { "lt.w", TIC80_OPERAND_BITNUM | 24 },
  142. { "lt0.b", TIC80_OPERAND_CC | 4 },
  143. { "lt0.h", TIC80_OPERAND_CC | 12 },
  144. { "lt0.w", TIC80_OPERAND_CC | 20 },
  145. { "MIP", TIC80_OPERAND_CR | 0x31 },
  146. { "MPC", TIC80_OPERAND_CR | 0x30 },
  147. { "ne.b", TIC80_OPERAND_BITNUM | 1 },
  148. { "ne.f", TIC80_OPERAND_BITNUM | 21 },
  149. { "ne.h", TIC80_OPERAND_BITNUM | 11 },
  150. { "ne.w", TIC80_OPERAND_BITNUM | 21 },
  151. { "ne0.b", TIC80_OPERAND_CC | 5 },
  152. { "ne0.h", TIC80_OPERAND_CC | 13 },
  153. { "ne0.w", TIC80_OPERAND_CC | 21 },
  154. { "nev.b", TIC80_OPERAND_CC | 0 },
  155. { "nev.h", TIC80_OPERAND_CC | 8 },
  156. { "nev.w", TIC80_OPERAND_CC | 16 },
  157. { "ob.f", TIC80_OPERAND_BITNUM | 29 },
  158. { "or.f", TIC80_OPERAND_BITNUM | 31 },
  159. { "ou.f", TIC80_OPERAND_BITNUM | 26 },
  160. { "OUTP", TIC80_OPERAND_CR | 0x4002 },
  161. { "PKTREQ", TIC80_OPERAND_CR | 0xD },
  162. { "PPERROR", TIC80_OPERAND_CR | 0xA },
  163. { "r0", TIC80_OPERAND_GPR | 0 },
  164. { "r1", TIC80_OPERAND_GPR | 1 },
  165. { "r10", TIC80_OPERAND_GPR | 10 },
  166. { "r11", TIC80_OPERAND_GPR | 11 },
  167. { "r12", TIC80_OPERAND_GPR | 12 },
  168. { "r13", TIC80_OPERAND_GPR | 13 },
  169. { "r14", TIC80_OPERAND_GPR | 14 },
  170. { "r15", TIC80_OPERAND_GPR | 15 },
  171. { "r16", TIC80_OPERAND_GPR | 16 },
  172. { "r17", TIC80_OPERAND_GPR | 17 },
  173. { "r18", TIC80_OPERAND_GPR | 18 },
  174. { "r19", TIC80_OPERAND_GPR | 19 },
  175. { "r2", TIC80_OPERAND_GPR | 2 },
  176. { "r20", TIC80_OPERAND_GPR | 20 },
  177. { "r21", TIC80_OPERAND_GPR | 21 },
  178. { "r22", TIC80_OPERAND_GPR | 22 },
  179. { "r23", TIC80_OPERAND_GPR | 23 },
  180. { "r24", TIC80_OPERAND_GPR | 24 },
  181. { "r25", TIC80_OPERAND_GPR | 25 },
  182. { "r26", TIC80_OPERAND_GPR | 26 },
  183. { "r27", TIC80_OPERAND_GPR | 27 },
  184. { "r28", TIC80_OPERAND_GPR | 28 },
  185. { "r29", TIC80_OPERAND_GPR | 29 },
  186. { "r3", TIC80_OPERAND_GPR | 3 },
  187. { "r30", TIC80_OPERAND_GPR | 30 },
  188. { "r31", TIC80_OPERAND_GPR | 31 },
  189. { "r4", TIC80_OPERAND_GPR | 4 },
  190. { "r5", TIC80_OPERAND_GPR | 5 },
  191. { "r6", TIC80_OPERAND_GPR | 6 },
  192. { "r7", TIC80_OPERAND_GPR | 7 },
  193. { "r8", TIC80_OPERAND_GPR | 8 },
  194. { "r9", TIC80_OPERAND_GPR | 9 },
  195. { "SYSSTK", TIC80_OPERAND_CR | 0x20 },
  196. { "SYSTMP", TIC80_OPERAND_CR | 0x21 },
  197. { "TCOUNT", TIC80_OPERAND_CR | 0xE },
  198. { "TSCALE", TIC80_OPERAND_CR | 0xF },
  199. { "uo.f", TIC80_OPERAND_BITNUM | 30 },
  200. };
  201. const int tic80_num_predefined_symbols = sizeof (tic80_predefined_symbols) / sizeof (struct predefined_symbol);
  202. /* This function takes a predefined symbol name in NAME, symbol class
  203. in CLASS, and translates it to a numeric value, which it returns.
  204. If CLASS is zero, any symbol that matches NAME is translated. If
  205. CLASS is non-zero, then only a symbol that has symbol_class CLASS is
  206. matched.
  207. If no translation is possible, it returns -1, a value not used by
  208. any predefined symbol. Note that the predefined symbol array is
  209. presorted case independently by name.
  210. This function is implemented with the assumption that there are no
  211. duplicate names in the predefined symbol array, which happens to be
  212. true at the moment.
  213. */
  214. int
  215. tic80_symbol_to_value (name, symbol_class)
  216. char *name;
  217. int symbol_class;
  218. {
  219. const struct predefined_symbol *pdsp;
  220. int low = 0;
  221. int middle;
  222. int high = tic80_num_predefined_symbols - 1;
  223. int cmp;
  224. int rtnval = -1;
  225. while (low <= high)
  226. {
  227. middle = (low + high) / 2;
  228. cmp = strcasecmp (name, tic80_predefined_symbols[middle].name);
  229. if (cmp < 0)
  230. {
  231. high = middle - 1;
  232. }
  233. else if (cmp > 0)
  234. {
  235. low = middle + 1;
  236. }
  237. else
  238. {
  239. pdsp = &tic80_predefined_symbols[middle];
  240. if ((symbol_class == 0) || (symbol_class & PDS_VALUE (pdsp)))
  241. {
  242. rtnval = PDS_VALUE (pdsp);
  243. }
  244. /* For now we assume that there are no duplicate names */
  245. break;
  246. }
  247. }
  248. return (rtnval);
  249. }
  250. /* This function takes a value VAL and finds a matching predefined
  251. symbol that is in the operand symbol_class specified by CLASS. If CLASS
  252. is zero, the first matching symbol is returned. */
  253. const char *
  254. tic80_value_to_symbol (val, symbol_class)
  255. int val;
  256. int symbol_class;
  257. {
  258. const struct predefined_symbol *pdsp;
  259. int ival;
  260. char *name;
  261. name = NULL;
  262. for (pdsp = tic80_predefined_symbols;
  263. pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols;
  264. pdsp++)
  265. {
  266. ival = PDS_VALUE (pdsp) & ~TIC80_OPERAND_MASK;
  267. if (ival == val)
  268. {
  269. if ((symbol_class == 0) || (symbol_class & PDS_VALUE (pdsp)))
  270. {
  271. /* Found the desired match */
  272. name = PDS_NAME (pdsp);
  273. break;
  274. }
  275. }
  276. }
  277. return (name);
  278. }
  279. /* This function returns a pointer to the next symbol in the predefined
  280. symbol table after PDSP, or NULL if PDSP points to the last symbol. If
  281. PDSP is NULL, it returns the first symbol in the table. Thus it can be
  282. used to walk through the table by first calling it with NULL and then
  283. calling it with each value it returned on the previous call, until it
  284. returns NULL. */
  285. const struct predefined_symbol *
  286. tic80_next_predefined_symbol (pdsp)
  287. const struct predefined_symbol *pdsp;
  288. {
  289. if (pdsp == NULL)
  290. {
  291. pdsp = tic80_predefined_symbols;
  292. }
  293. else if (pdsp >= tic80_predefined_symbols &&
  294. pdsp < tic80_predefined_symbols + tic80_num_predefined_symbols - 1)
  295. {
  296. pdsp++;
  297. }
  298. else
  299. {
  300. pdsp = NULL;
  301. }
  302. return (pdsp);
  303. }
  304. /* The operands table. The fields are:
  305. bits, shift, insertion function, extraction function, flags
  306. */
  307. const struct tic80_operand tic80_operands[] =
  308. {
  309. /* The zero index is used to indicate the end of the list of operands. */
  310. #define UNUSED (0)
  311. { 0, 0, 0, 0, 0 },
  312. /* Short signed immediate value in bits 14-0. */
  313. #define SSI (UNUSED + 1)
  314. { 15, 0, NULL, NULL, TIC80_OPERAND_SIGNED },
  315. /* Short unsigned immediate value in bits 14-0 */
  316. #define SUI (SSI + 1)
  317. { 15, 0, NULL, NULL, 0 },
  318. /* Short unsigned bitfield in bits 14-0. We distinguish this
  319. from a regular unsigned immediate value only for the convenience
  320. of the disassembler and the user. */
  321. #define SUBF (SUI + 1)
  322. { 15, 0, NULL, NULL, TIC80_OPERAND_BITFIELD },
  323. /* Long signed immediate in following 32 bit word */
  324. #define LSI (SUBF + 1)
  325. { 32, 0, NULL, NULL, TIC80_OPERAND_SIGNED },
  326. /* Long unsigned immediate in following 32 bit word */
  327. #define LUI (LSI + 1)
  328. { 32, 0, NULL, NULL, 0 },
  329. /* Long unsigned bitfield in following 32 bit word. We distinguish
  330. this from a regular unsigned immediate value only for the
  331. convenience of the disassembler and the user. */
  332. #define LUBF (LUI + 1)
  333. { 32, 0, NULL, NULL, TIC80_OPERAND_BITFIELD },
  334. /* Single precision floating point immediate in following 32 bit
  335. word. */
  336. #define SPFI (LUBF + 1)
  337. { 32, 0, NULL, NULL, TIC80_OPERAND_FLOAT },
  338. /* Register in bits 4-0 */
  339. #define REG_0 (SPFI + 1)
  340. { 5, 0, NULL, NULL, TIC80_OPERAND_GPR },
  341. /* Even register in bits 4-0 */
  342. #define REG_0_E (REG_0 + 1)
  343. { 5, 0, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
  344. /* Register in bits 26-22 */
  345. #define REG_22 (REG_0_E + 1)
  346. { 5, 22, NULL, NULL, TIC80_OPERAND_GPR },
  347. /* Even register in bits 26-22 */
  348. #define REG_22_E (REG_22 + 1)
  349. { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
  350. /* Register in bits 31-27 */
  351. #define REG_DEST (REG_22_E + 1)
  352. { 5, 27, NULL, NULL, TIC80_OPERAND_GPR },
  353. /* Even register in bits 31-27 */
  354. #define REG_DEST_E (REG_DEST + 1)
  355. { 5, 27, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_EVEN },
  356. /* Floating point accumulator register (a0-a3) specified by bit 16 (MSB)
  357. and bit 11 (LSB) */
  358. /* FIXME! Needs to use functions to insert and extract the register
  359. number in bits 16 and 11. */
  360. #define REG_FPA (REG_DEST_E + 1)
  361. { 0, 0, NULL, NULL, TIC80_OPERAND_FPA },
  362. /* Short signed PC word offset in bits 14-0 */
  363. #define OFF_SS_PC (REG_FPA + 1)
  364. { 15, 0, NULL, NULL, TIC80_OPERAND_PCREL | TIC80_OPERAND_SIGNED },
  365. /* Long signed PC word offset in following 32 bit word */
  366. #define OFF_SL_PC (OFF_SS_PC + 1)
  367. { 32, 0, NULL, NULL, TIC80_OPERAND_PCREL | TIC80_OPERAND_SIGNED },
  368. /* Short signed base relative byte offset in bits 14-0 */
  369. #define OFF_SS_BR (OFF_SL_PC + 1)
  370. { 15, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED },
  371. /* Long signed base relative byte offset in following 32 bit word */
  372. #define OFF_SL_BR (OFF_SS_BR + 1)
  373. { 32, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED },
  374. /* Long signed base relative byte offset in following 32 bit word
  375. with optional ":s" modifier flag in bit 11 */
  376. #define OFF_SL_BR_SCALED (OFF_SL_BR + 1)
  377. { 32, 0, NULL, NULL, TIC80_OPERAND_BASEREL | TIC80_OPERAND_SIGNED | TIC80_OPERAND_SCALED },
  378. /* BITNUM in bits 31-27 */
  379. #define BITNUM (OFF_SL_BR_SCALED + 1)
  380. { 5, 27, NULL, NULL, TIC80_OPERAND_BITNUM },
  381. /* Condition code in bits 31-27 */
  382. #define CC (BITNUM + 1)
  383. { 5, 27, NULL, NULL, TIC80_OPERAND_CC },
  384. /* Control register number in bits 14-0 */
  385. #define CR_SI (CC + 1)
  386. { 15, 0, NULL, NULL, TIC80_OPERAND_CR },
  387. /* Control register number in next 32 bit word */
  388. #define CR_LI (CR_SI + 1)
  389. { 32, 0, NULL, NULL, TIC80_OPERAND_CR },
  390. /* A base register in bits 26-22, enclosed in parens */
  391. #define REG_BASE (CR_LI + 1)
  392. { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS },
  393. /* A base register in bits 26-22, enclosed in parens, with optional ":m"
  394. flag in bit 17 (short immediate instructions only) */
  395. #define REG_BASE_M_SI (REG_BASE + 1)
  396. { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS | TIC80_OPERAND_M_SI },
  397. /* A base register in bits 26-22, enclosed in parens, with optional ":m"
  398. flag in bit 15 (long immediate and register instructions only) */
  399. #define REG_BASE_M_LI (REG_BASE_M_SI + 1)
  400. { 5, 22, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_PARENS | TIC80_OPERAND_M_LI },
  401. /* Scaled register in bits 4-0, with optional ":s" modifier flag in bit 11 */
  402. #define REG_SCALED (REG_BASE_M_LI + 1)
  403. { 5, 0, NULL, NULL, TIC80_OPERAND_GPR | TIC80_OPERAND_SCALED },
  404. /* Unsigned immediate in bits 4-0, used only for shift instructions */
  405. #define ROTATE (REG_SCALED + 1)
  406. { 5, 0, NULL, NULL, 0 },
  407. /* Unsigned immediate in bits 9-5, used only for shift instructions */
  408. #define ENDMASK (ROTATE + 1)
  409. { 5, 5, NULL, NULL, TIC80_OPERAND_ENDMASK },
  410. };
  411. const int tic80_num_operands = sizeof (tic80_operands)/sizeof(*tic80_operands);
  412. /* Macros used to generate entries for the opcodes table. */
  413. #define FIXME 0
  414. /* Short-Immediate Format Instructions - basic opcode */
  415. #define OP_SI(x) (((x) & 0x7F) << 15)
  416. #define MASK_SI OP_SI(0x7F)
  417. /* Long-Immediate Format Instructions - basic opcode */
  418. #define OP_LI(x) (((x) & 0x3FF) << 12)
  419. #define MASK_LI OP_LI(0x3FF)
  420. /* Register Format Instructions - basic opcode */
  421. #define OP_REG(x) OP_LI(x) /* For readability */
  422. #define MASK_REG MASK_LI /* For readability */
  423. /* The 'n' bit at bit 10 */
  424. #define n(x) ((x) << 10)
  425. /* The 'i' bit at bit 11 */
  426. #define i(x) ((x) << 11)
  427. /* The 'F' bit at bit 27 */
  428. #define F(x) ((x) << 27)
  429. /* The 'E' bit at bit 27 */
  430. #define E(x) ((x) << 27)
  431. /* The 'M' bit at bit 15 in register and long immediate opcodes */
  432. #define M_REG(x) ((x) << 15)
  433. #define M_LI(x) ((x) << 15)
  434. /* The 'M' bit at bit 17 in short immediate opcodes */
  435. #define M_SI(x) ((x) << 17)
  436. /* The 'SZ' field at bits 14-13 in register and long immediate opcodes */
  437. #define SZ_REG(x) ((x) << 13)
  438. #define SZ_LI(x) ((x) << 13)
  439. /* The 'SZ' field at bits 16-15 in short immediate opcodes */
  440. #define SZ_SI(x) ((x) << 15)
  441. /* The 'D' (direct external memory access) bit at bit 10 in long immediate
  442. and register opcodes. */
  443. #define D(x) ((x) << 10)
  444. /* The 'S' (scale offset by data size) bit at bit 11 in long immediate
  445. and register opcodes. */
  446. #define S(x) ((x) << 11)
  447. /* The 'PD' field at bits 10-9 in floating point instructions */
  448. #define PD(x) ((x) << 9)
  449. /* The 'P2' field at bits 8-7 in floating point instructions */
  450. #define P2(x) ((x) << 7)
  451. /* The 'P1' field at bits 6-5 in floating point instructions */
  452. #define P1(x) ((x) << 5)
  453. /* The 'a' field at bit 16 in vector instructions */
  454. #define V_a1(x) ((x) << 16)
  455. /* The 'a' field at bit 11 in vector instructions */
  456. #define V_a0(x) ((x) << 11)
  457. /* The 'm' field at bit 10 in vector instructions */
  458. #define V_m(x) ((x) << 10)
  459. /* The 'S' field at bit 9 in vector instructions */
  460. #define V_S(x) ((x) << 9)
  461. /* The 'Z' field at bit 8 in vector instructions */
  462. #define V_Z(x) ((x) << 8)
  463. /* The 'p' field at bit 6 in vector instructions */
  464. #define V_p(x) ((x) << 6)
  465. /* The opcode field at bits 21-17 for vector instructions */
  466. #define OP_V(x) ((x) << 17)
  467. #define MASK_V OP_V(0x1F)
  468. /* The opcode table. Formatted for better readability on a wide screen. Also, all
  469. entries with the same mnemonic are sorted so that they are adjacent in the table,
  470. allowing the use of a hash table to locate the first of a sequence of opcodes that have
  471. a particular name. The short immediate forms also come before the long immediate forms
  472. so that the assembler will pick the "best fit" for the size of the operand, except for
  473. the case of the PC relative forms, where the long forms come first and are the default
  474. forms. */
  475. const struct tic80_opcode tic80_opcodes[] = {
  476. /* The "nop" instruction is really "rdcr 0,r0". We put it first so that this
  477. specific bit pattern will get disassembled as a nop rather than an rdcr. The
  478. mask of all ones ensures that this will happen. */
  479. {"nop", OP_SI(0x4), ~0, 0, {0} },
  480. /* The "br" instruction is really "bbz target,r0,31". We put it first so that
  481. this specific bit pattern will get disassembled as a br rather than bbz. */
  482. {"br", OP_SI(0x48), 0xFFFF8000, 0, {OFF_SS_PC} },
  483. {"br", OP_LI(0x391), 0xFFFFF000, 0, {OFF_SL_PC} },
  484. {"br", OP_REG(0x390), 0xFFFFF000, 0, {REG_0} },
  485. {"br.a", OP_SI(0x49), 0xFFFF8000, 0, {OFF_SS_PC} },
  486. {"br.a", OP_LI(0x393), 0xFFFFF000, 0, {OFF_SL_PC} },
  487. {"br.a", OP_REG(0x392), 0xFFFFF000, 0, {REG_0} },
  488. /* Signed integer ADD */
  489. {"add", OP_SI(0x58), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
  490. {"add", OP_LI(0x3B1), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
  491. {"add", OP_REG(0x3B0), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  492. /* Unsigned integer ADD */
  493. {"addu", OP_SI(0x59), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
  494. {"addu", OP_LI(0x3B3), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
  495. {"addu", OP_REG(0x3B2), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  496. /* Bitwise AND */
  497. {"and", OP_SI(0x11), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  498. {"and", OP_LI(0x323), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  499. {"and", OP_REG(0x322), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  500. {"and.tt", OP_SI(0x11), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  501. {"and.tt", OP_LI(0x323), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  502. {"and.tt", OP_REG(0x322), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  503. /* Bitwise AND with ones complement of both sources */
  504. {"and.ff", OP_SI(0x18), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  505. {"and.ff", OP_LI(0x331), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  506. {"and.ff", OP_REG(0x330), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  507. /* Bitwise AND with ones complement of source 1 */
  508. {"and.ft", OP_SI(0x14), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  509. {"and.ft", OP_LI(0x329), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  510. {"and.ft", OP_REG(0x328), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  511. /* Bitwise AND with ones complement of source 2 */
  512. {"and.tf", OP_SI(0x12), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  513. {"and.tf", OP_LI(0x325), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  514. {"and.tf", OP_REG(0x324), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  515. /* Branch Bit One - nonannulled */
  516. {"bbo", OP_SI(0x4A), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
  517. {"bbo", OP_LI(0x395), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
  518. {"bbo", OP_REG(0x394), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
  519. /* Branch Bit One - annulled */
  520. {"bbo.a", OP_SI(0x4B), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
  521. {"bbo.a", OP_LI(0x397), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
  522. {"bbo.a", OP_REG(0x396), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
  523. /* Branch Bit Zero - nonannulled */
  524. {"bbz", OP_SI(0x48), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
  525. {"bbz", OP_LI(0x391), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
  526. {"bbz", OP_REG(0x390), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
  527. /* Branch Bit Zero - annulled */
  528. {"bbz.a", OP_SI(0x49), MASK_SI, 0, {OFF_SS_PC, REG_22, BITNUM} },
  529. {"bbz.a", OP_LI(0x393), MASK_LI, 0, {OFF_SL_PC, REG_22, BITNUM} },
  530. {"bbz.a", OP_REG(0x392), MASK_REG, 0, {REG_0, REG_22, BITNUM} },
  531. /* Branch Conditional - nonannulled */
  532. {"bcnd", OP_SI(0x4C), MASK_SI, 0, {OFF_SS_PC, REG_22, CC} },
  533. {"bcnd", OP_LI(0x399), MASK_LI, 0, {OFF_SL_PC, REG_22, CC} },
  534. {"bcnd", OP_REG(0x398), MASK_REG, 0, {REG_0, REG_22, CC} },
  535. /* Branch Conditional - annulled */
  536. {"bcnd.a", OP_SI(0x4D), MASK_SI, 0, {OFF_SS_PC, REG_22, CC} },
  537. {"bcnd.a", OP_LI(0x39B), MASK_LI, 0, {OFF_SL_PC, REG_22, CC} },
  538. {"bcnd.a", OP_REG(0x39A), MASK_REG, 0, {REG_0, REG_22, CC} },
  539. /* Branch Control Register */
  540. {"brcr", OP_SI(0x6), MASK_SI, 0, {CR_SI} },
  541. {"brcr", OP_LI(0x30D), MASK_LI, 0, {CR_LI} },
  542. {"brcr", OP_REG(0x30C), MASK_REG, 0, {REG_0} },
  543. /* Branch and save return - nonannulled */
  544. {"bsr", OP_SI(0x40), MASK_SI, 0, {OFF_SS_PC, REG_DEST} },
  545. {"bsr", OP_LI(0x381), MASK_LI, 0, {OFF_SL_PC, REG_DEST} },
  546. {"bsr", OP_REG(0x380), MASK_REG, 0, {REG_0, REG_DEST} },
  547. /* Branch and save return - annulled */
  548. {"bsr.a", OP_SI(0x41), MASK_SI, 0, {OFF_SS_PC, REG_DEST} },
  549. {"bsr.a", OP_LI(0x383), MASK_LI, 0, {OFF_SL_PC, REG_DEST} },
  550. {"bsr.a", OP_REG(0x382), MASK_REG, 0, {REG_0, REG_DEST} },
  551. /* Send command */
  552. {"cmnd", OP_SI(0x2), MASK_SI, 0, {SUI} },
  553. {"cmnd", OP_LI(0x305), MASK_LI, 0, {LUI} },
  554. {"cmnd", OP_REG(0x304), MASK_REG, 0, {REG_0} },
  555. /* Integer compare */
  556. {"cmp", OP_SI(0x50), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
  557. {"cmp", OP_LI(0x3A1), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
  558. {"cmp", OP_REG(0x3A0), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  559. /* Flush data cache subblock - don't clear subblock preset flag */
  560. {"dcachec", OP_SI(0x38), F(1) | (MASK_SI & ~M_SI(1)), 0, {SSI, REG_BASE_M_SI} },
  561. {"dcachec", OP_LI(0x371), F(1) | (MASK_LI & ~M_LI(1)) | S(1) | D(1), 0, {LSI, REG_BASE_M_LI} },
  562. {"dcachec", OP_REG(0x370), F(1) | (MASK_REG & ~M_REG(1)) | S(1) | D(1), 0, {REG_0, REG_BASE_M_LI} },
  563. /* Flush data cache subblock - clear subblock preset flag */
  564. {"dcachef", OP_SI(0x38) | F(1), F(1) | (MASK_SI & ~M_SI(1)), 0, {SSI, REG_BASE_M_SI} },
  565. {"dcachef", OP_LI(0x371) | F(1), F(1) | (MASK_LI & ~M_LI(1)) | S(1) | D(1), 0, {LSI, REG_BASE_M_LI} },
  566. {"dcachef", OP_REG(0x370) | F(1), F(1) | (MASK_REG & ~M_REG(1)) | S(1) | D(1), 0, {REG_0, REG_BASE_M_LI} },
  567. /* Direct load signed data into register */
  568. {"dld", OP_LI(0x345) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  569. {"dld", OP_REG(0x344) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  570. {"dld.b", OP_LI(0x341) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  571. {"dld.b", OP_REG(0x340) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  572. {"dld.d", OP_LI(0x347) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  573. {"dld.d", OP_REG(0x346) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  574. {"dld.h", OP_LI(0x343) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  575. {"dld.h", OP_REG(0x342) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  576. /* Direct load unsigned data into register */
  577. {"dld.ub", OP_LI(0x351) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  578. {"dld.ub", OP_REG(0x350) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  579. {"dld.uh", OP_LI(0x353) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  580. {"dld.uh", OP_REG(0x352) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  581. /* Direct store data into memory */
  582. {"dst", OP_LI(0x365) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  583. {"dst", OP_REG(0x364) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  584. {"dst.b", OP_LI(0x361) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  585. {"dst.b", OP_REG(0x360) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  586. {"dst.d", OP_LI(0x367) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  587. {"dst.d", OP_REG(0x366) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  588. {"dst.h", OP_LI(0x363) | D(1), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  589. {"dst.h", OP_REG(0x362) | D(1), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  590. /* Emulation stop */
  591. {"estop", OP_LI(0x3FC), MASK_LI, 0, {0} },
  592. /* Emulation trap */
  593. {"etrap", OP_SI(0x1) | E(1), MASK_SI | E(1), 0, {SUI} },
  594. {"etrap", OP_LI(0x303) | E(1), MASK_LI | E(1), 0, {LUI} },
  595. {"etrap", OP_REG(0x302) | E(1), MASK_REG | E(1), 0, {REG_0} },
  596. /* Floating-point addition */
  597. {"fadd.ddd", OP_REG(0x3E0) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
  598. {"fadd.dsd", OP_REG(0x3E0) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
  599. {"fadd.sdd", OP_LI(0x3E1) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
  600. {"fadd.sdd", OP_REG(0x3E0) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
  601. {"fadd.ssd", OP_LI(0x3E1) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
  602. {"fadd.ssd", OP_REG(0x3E0) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
  603. {"fadd.sss", OP_LI(0x3E1) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
  604. {"fadd.sss", OP_REG(0x3E0) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  605. /* Floating point compare */
  606. {"fcmp.dd", OP_REG(0x3EA) | PD(0) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST} },
  607. {"fcmp.ds", OP_REG(0x3EA) | PD(0) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST} },
  608. {"fcmp.sd", OP_LI(0x3EB) | PD(0) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST} },
  609. {"fcmp.sd", OP_REG(0x3EA) | PD(0) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST} },
  610. {"fcmp.ss", OP_LI(0x3EB) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
  611. {"fcmp.ss", OP_REG(0x3EA) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  612. /* Floating point divide */
  613. {"fdiv.ddd", OP_REG(0x3E6) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
  614. {"fdiv.dsd", OP_REG(0x3E6) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
  615. {"fdiv.sdd", OP_LI(0x3E7) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
  616. {"fdiv.sdd", OP_REG(0x3E6) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
  617. {"fdiv.ssd", OP_LI(0x3E7) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
  618. {"fdiv.ssd", OP_REG(0x3E6) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
  619. {"fdiv.sss", OP_LI(0x3E7) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
  620. {"fdiv.sss", OP_REG(0x3E6) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  621. /* Floating point multiply */
  622. {"fmpy.ddd", OP_REG(0x3E4) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
  623. {"fmpy.dsd", OP_REG(0x3E4) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
  624. {"fmpy.iii", OP_LI(0x3E5) | PD(2) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_22, REG_DEST} },
  625. {"fmpy.iii", OP_REG(0x3E4) | PD(2) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  626. {"fmpy.sdd", OP_LI(0x3E5) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
  627. {"fmpy.sdd", OP_REG(0x3E4) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
  628. {"fmpy.ssd", OP_LI(0x3E5) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
  629. {"fmpy.ssd", OP_REG(0x3E4) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
  630. {"fmpy.sss", OP_LI(0x3E5) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
  631. {"fmpy.sss", OP_REG(0x3E4) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  632. {"fmpy.uuu", OP_LI(0x3E5) | PD(3) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LUI, REG_22, REG_DEST} },
  633. {"fmpy.uuu", OP_REG(0x3E4) | PD(3) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  634. /* Convert/Round to Minus Infinity */
  635. {"frndm.dd", OP_REG(0x3E8) | PD(1) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
  636. {"frndm.di", OP_REG(0x3E8) | PD(2) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  637. {"frndm.ds", OP_REG(0x3E8) | PD(0) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  638. {"frndm.du", OP_REG(0x3E8) | PD(3) | P2(3) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  639. {"frndm.id", OP_LI(0x3E9) | PD(1) | P2(3) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  640. {"frndm.id", OP_REG(0x3E8) | PD(1) | P2(3) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  641. {"frndm.is", OP_LI(0x3E9) | PD(0) | P2(3) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  642. {"frndm.is", OP_REG(0x3E8) | PD(0) | P2(3) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  643. {"frndm.sd", OP_LI(0x3E9) | PD(1) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
  644. {"frndm.sd", OP_REG(0x3E8) | PD(1) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  645. {"frndm.si", OP_LI(0x3E9) | PD(2) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  646. {"frndm.si", OP_REG(0x3E8) | PD(2) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  647. {"frndm.ss", OP_LI(0x3E9) | PD(0) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  648. {"frndm.ss", OP_REG(0x3E8) | PD(0) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  649. {"frndm.su", OP_LI(0x3E9) | PD(3) | P2(3) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  650. {"frndm.su", OP_REG(0x3E8) | PD(3) | P2(3) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  651. {"frndm.ud", OP_LI(0x3E9) | PD(1) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  652. {"frndm.ud", OP_REG(0x3E8) | PD(1) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  653. {"frndm.us", OP_LI(0x3E9) | PD(0) | P2(3) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  654. {"frndm.us", OP_REG(0x3E8) | PD(0) | P2(3) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  655. /* Convert/Round to Nearest */
  656. {"frndn.dd", OP_REG(0x3E8) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
  657. {"frndn.di", OP_REG(0x3E8) | PD(2) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  658. {"frndn.ds", OP_REG(0x3E8) | PD(0) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  659. {"frndn.du", OP_REG(0x3E8) | PD(3) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  660. {"frndn.id", OP_LI(0x3E9) | PD(1) | P2(0) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  661. {"frndn.id", OP_REG(0x3E8) | PD(1) | P2(0) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  662. {"frndn.is", OP_LI(0x3E9) | PD(0) | P2(0) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  663. {"frndn.is", OP_REG(0x3E8) | PD(0) | P2(0) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  664. {"frndn.sd", OP_LI(0x3E9) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
  665. {"frndn.sd", OP_REG(0x3E8) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  666. {"frndn.si", OP_LI(0x3E9) | PD(2) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  667. {"frndn.si", OP_REG(0x3E8) | PD(2) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  668. {"frndn.ss", OP_LI(0x3E9) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  669. {"frndn.ss", OP_REG(0x3E8) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  670. {"frndn.su", OP_LI(0x3E9) | PD(3) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  671. {"frndn.su", OP_REG(0x3E8) | PD(3) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  672. {"frndn.ud", OP_LI(0x3E9) | PD(1) | P2(0) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  673. {"frndn.ud", OP_REG(0x3E8) | PD(1) | P2(0) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  674. {"frndn.us", OP_LI(0x3E9) | PD(0) | P2(0) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  675. {"frndn.us", OP_REG(0x3E8) | PD(0) | P2(0) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  676. /* Convert/Round to Positive Infinity */
  677. {"frndp.dd", OP_REG(0x3E8) | PD(1) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
  678. {"frndp.di", OP_REG(0x3E8) | PD(2) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  679. {"frndp.ds", OP_REG(0x3E8) | PD(0) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  680. {"frndp.du", OP_REG(0x3E8) | PD(3) | P2(2) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  681. {"frndp.id", OP_LI(0x3E9) | PD(1) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  682. {"frndp.id", OP_REG(0x3E8) | PD(1) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  683. {"frndp.is", OP_LI(0x3E9) | PD(0) | P2(2) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  684. {"frndp.is", OP_REG(0x3E8) | PD(0) | P2(2) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  685. {"frndp.sd", OP_LI(0x3E9) | PD(1) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
  686. {"frndp.sd", OP_REG(0x3E8) | PD(1) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  687. {"frndp.si", OP_LI(0x3E9) | PD(2) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  688. {"frndp.si", OP_REG(0x3E8) | PD(2) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  689. {"frndp.ss", OP_LI(0x3E9) | PD(0) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  690. {"frndp.ss", OP_REG(0x3E8) | PD(0) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  691. {"frndp.su", OP_LI(0x3E9) | PD(3) | P2(2) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  692. {"frndp.su", OP_REG(0x3E8) | PD(3) | P2(2) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  693. {"frndp.ud", OP_LI(0x3E9) | PD(1) | P2(2) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  694. {"frndp.ud", OP_REG(0x3E8) | PD(1) | P2(2) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  695. {"frndp.us", OP_LI(0x3E9) | PD(0) | P2(2) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  696. {"frndp.us", OP_REG(0x3E8) | PD(0) | P2(2) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  697. /* Convert/Round to Zero */
  698. {"frndz.dd", OP_REG(0x3E8) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
  699. {"frndz.di", OP_REG(0x3E8) | PD(2) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  700. {"frndz.ds", OP_REG(0x3E8) | PD(0) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  701. {"frndz.du", OP_REG(0x3E8) | PD(3) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST} },
  702. {"frndz.id", OP_LI(0x3E9) | PD(1) | P2(1) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  703. {"frndz.id", OP_REG(0x3E8) | PD(1) | P2(1) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  704. {"frndz.is", OP_LI(0x3E9) | PD(0) | P2(1) | P1(2), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  705. {"frndz.is", OP_REG(0x3E8) | PD(0) | P2(1) | P1(2), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  706. {"frndz.sd", OP_LI(0x3E9) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
  707. {"frndz.sd", OP_REG(0x3E8) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  708. {"frndz.si", OP_LI(0x3E9) | PD(2) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  709. {"frndz.si", OP_REG(0x3E8) | PD(2) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  710. {"frndz.ss", OP_LI(0x3E9) | PD(0) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  711. {"frndz.ss", OP_REG(0x3E8) | PD(0) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  712. {"frndz.su", OP_LI(0x3E9) | PD(3) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  713. {"frndz.su", OP_REG(0x3E8) | PD(3) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  714. {"frndz.ud", OP_LI(0x3E9) | PD(1) | P2(1) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST_E} },
  715. {"frndz.ud", OP_REG(0x3E8) | PD(1) | P2(1) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  716. {"frndz.us", OP_LI(0x3E9) | PD(0) | P2(1) | P1(3), MASK_LI | PD(3) | P2(3) | P1(3), 0, {LSI, REG_DEST} },
  717. {"frndz.us", OP_REG(0x3E8) | PD(0) | P2(1) | P1(3), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  718. /* Floating point square root */
  719. {"fsqrt.dd", OP_REG(0x3EE) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_DEST_E} },
  720. {"fsqrt.sd", OP_LI(0x3EF) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST_E} },
  721. {"fsqrt.sd", OP_REG(0x3EE) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST_E} },
  722. {"fsqrt.ss", OP_LI(0x3EF) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_DEST} },
  723. {"fsqrt.ss", OP_REG(0x3EE) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_DEST} },
  724. /* Floating point subtraction */
  725. { "fsub.ddd", OP_REG(0x3E2) | PD(1) | P2(1) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22_E, REG_DEST_E} },
  726. { "fsub.dsd", OP_REG(0x3E2) | PD(1) | P2(0) | P1(1), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0_E, REG_22, REG_DEST_E} },
  727. { "fsub.sdd", OP_LI(0x3E3) | PD(1) | P2(1) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22_E, REG_DEST_E} },
  728. { "fsub.sdd", OP_REG(0x3E2) | PD(1) | P2(1) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22_E, REG_DEST_E} },
  729. { "fsub.ssd", OP_LI(0x3E3) | PD(1) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST_E} },
  730. { "fsub.ssd", OP_REG(0x3E2) | PD(1) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST_E} },
  731. { "fsub.sss", OP_LI(0x3E3) | PD(0) | P2(0) | P1(0), MASK_LI | PD(3) | P2(3) | P1(3), 0, {SPFI, REG_22, REG_DEST} },
  732. { "fsub.sss", OP_REG(0x3E2) | PD(0) | P2(0) | P1(0), MASK_REG | PD(3) | P2(3) | P1(3), 0, {REG_0, REG_22, REG_DEST} },
  733. /* Illegal instructions */
  734. {"illop0", OP_SI(0x0), MASK_SI, 0, {0} },
  735. {"illopF", 0x1FF << 13, 0x1FF << 13, 0, {0} },
  736. /* Jump and save return */
  737. {"jsr", OP_SI(0x44), MASK_SI, 0, {OFF_SS_BR, REG_BASE, REG_DEST} },
  738. {"jsr", OP_LI(0x389), MASK_LI, 0, {OFF_SL_BR, REG_BASE, REG_DEST} },
  739. {"jsr", OP_REG(0x388), MASK_REG, 0, {REG_0, REG_BASE, REG_DEST} },
  740. {"jsr.a", OP_SI(0x45), MASK_SI, 0, {OFF_SS_BR, REG_BASE, REG_DEST} },
  741. {"jsr.a", OP_LI(0x38B), MASK_LI, 0, {OFF_SL_BR, REG_BASE, REG_DEST} },
  742. {"jsr.a", OP_REG(0x38A), MASK_REG, 0, {REG_0, REG_BASE, REG_DEST} },
  743. /* Load Signed Data Into Register */
  744. {"ld", OP_SI(0x22), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  745. {"ld", OP_LI(0x345) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  746. {"ld", OP_REG(0x344) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  747. {"ld.b", OP_SI(0x20), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  748. {"ld.b", OP_LI(0x341) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  749. {"ld.b", OP_REG(0x340) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  750. {"ld.d", OP_SI(0x23), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST_E} },
  751. {"ld.d", OP_LI(0x347) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  752. {"ld.d", OP_REG(0x346) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  753. {"ld.h", OP_SI(0x21), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  754. {"ld.h", OP_LI(0x343) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  755. {"ld.h", OP_REG(0x342) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  756. /* Load Unsigned Data Into Register */
  757. {"ld.ub", OP_SI(0x28), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  758. {"ld.ub", OP_LI(0x351) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  759. {"ld.ub", OP_REG(0x350) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  760. {"ld.uh", OP_SI(0x29), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  761. {"ld.uh", OP_LI(0x353) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  762. {"ld.uh", OP_REG(0x352) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  763. /* Leftmost one */
  764. {"lmo", OP_LI(0x3F0), MASK_LI, 0, {REG_22, REG_DEST} },
  765. /* Bitwise logical OR. Note that "or.tt" and "or" are the same instructions. */
  766. {"or.ff", OP_SI(0x1E), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
  767. {"or.ff", OP_LI(0x33D), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
  768. {"or.ff", OP_REG(0x33C), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  769. {"or.ft", OP_SI(0x1D), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
  770. {"or.ft", OP_LI(0x33B), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
  771. {"or.ft", OP_REG(0x33A), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  772. {"or.tf", OP_SI(0x1B), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
  773. {"or.tf", OP_LI(0x337), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
  774. {"or.tf", OP_REG(0x336), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  775. {"or.tt", OP_SI(0x17), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
  776. {"or.tt", OP_LI(0x32F), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
  777. {"or.tt", OP_REG(0x32E), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  778. {"or", OP_SI(0x17), MASK_SI, 0, {SUI, REG_22, REG_DEST} },
  779. {"or", OP_LI(0x32F), MASK_LI, 0, {LUI, REG_22, REG_DEST} },
  780. {"or", OP_REG(0x32E), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  781. /* Read Control Register */
  782. {"rdcr", OP_SI(0x4), MASK_SI | (0x1F << 22), 0, {CR_SI, REG_DEST} },
  783. {"rdcr", OP_LI(0x309), MASK_LI | (0x1F << 22), 0, {CR_LI, REG_DEST} },
  784. {"rdcr", OP_REG(0x308), MASK_REG | (0x1F << 22), 0, {REG_0, REG_DEST} },
  785. /* Rightmost one */
  786. {"rmo", OP_LI(0x3F2), MASK_LI, 0, {REG_22, REG_DEST} },
  787. /* Shift Register Left - note that rotl, shl, and ins are all alternate names for one of the shift instructions.
  788. They appear prior to their sl equivalent so that they will be diassembled as the alternate name. */
  789. {"ins", OP_REG(0x31E) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  790. {"ins", OP_SI(0xF) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  791. {"rotl", OP_REG(0x310) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  792. {"rotl", OP_SI(0x8) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  793. {"shl", OP_REG(0x31C) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  794. {"shl", OP_SI(0xE) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  795. {"sl.dm", OP_REG(0x312) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  796. {"sl.dm", OP_SI(0x9) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  797. {"sl.ds", OP_REG(0x314) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  798. {"sl.ds", OP_SI(0xA) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  799. {"sl.dz", OP_REG(0x310) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  800. {"sl.dz", OP_SI(0x8) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  801. {"sl.em", OP_REG(0x318) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  802. {"sl.em", OP_SI(0xC) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  803. {"sl.es", OP_REG(0x31A) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  804. {"sl.es", OP_SI(0xD) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  805. {"sl.ez", OP_REG(0x316) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  806. {"sl.ez", OP_SI(0xB) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  807. {"sl.im", OP_REG(0x31E) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  808. {"sl.im", OP_SI(0xF) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  809. {"sl.iz", OP_REG(0x31C) | i(0) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  810. {"sl.iz", OP_SI(0xE) | i(0) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  811. /* Shift Register Left With Inverted Endmask */
  812. {"sli.dm", OP_REG(0x312) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  813. {"sli.dm", OP_SI(0x9) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  814. {"sli.ds", OP_REG(0x314) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  815. {"sli.ds", OP_SI(0xA) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  816. {"sli.dz", OP_REG(0x310) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  817. {"sli.dz", OP_SI(0x8) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  818. {"sli.em", OP_REG(0x318) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  819. {"sli.em", OP_SI(0xC) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  820. {"sli.es", OP_REG(0x31A) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  821. {"sli.es", OP_SI(0xD) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  822. {"sli.ez", OP_REG(0x316) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  823. {"sli.ez", OP_SI(0xB) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  824. {"sli.im", OP_REG(0x31E) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  825. {"sli.im", OP_SI(0xF) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  826. {"sli.iz", OP_REG(0x31C) | i(1) | n(0), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  827. {"sli.iz", OP_SI(0xE) | i(1) | n(0), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  828. /* Shift Register Right - note that exts, extu, rotr, sra, and srl are all alternate names for one of the shift instructions.
  829. They appear prior to their sr equivalent so that they will be diassembled as the alternate name. */
  830. {"exts", OP_REG(0x314) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  831. {"exts", OP_SI(0xA) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  832. {"extu", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  833. {"extu", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  834. {"rotr", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  835. {"rotr", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  836. {"sra", OP_REG(0x31A) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  837. {"sra", OP_SI(0xD) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  838. {"srl", OP_REG(0x316) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  839. {"srl", OP_SI(0xB) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  840. {"sr.dm", OP_REG(0x312) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  841. {"sr.dm", OP_SI(0x9) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  842. {"sr.ds", OP_REG(0x314) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  843. {"sr.ds", OP_SI(0xA) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  844. {"sr.dz", OP_REG(0x310) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  845. {"sr.dz", OP_SI(0x8) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  846. {"sr.em", OP_REG(0x318) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  847. {"sr.em", OP_SI(0xC) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  848. {"sr.es", OP_REG(0x31A) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  849. {"sr.es", OP_SI(0xD) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  850. {"sr.ez", OP_REG(0x316) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  851. {"sr.ez", OP_SI(0xB) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  852. {"sr.im", OP_REG(0x31E) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  853. {"sr.im", OP_SI(0xF) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  854. {"sr.iz", OP_REG(0x31C) | i(0) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  855. {"sr.iz", OP_SI(0xE) | i(0) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  856. /* Shift Register Right With Inverted Endmask */
  857. {"sri.dm", OP_REG(0x312) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  858. {"sri.dm", OP_SI(0x9) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  859. {"sri.ds", OP_REG(0x314) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  860. {"sri.ds", OP_SI(0xA) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  861. {"sri.dz", OP_REG(0x310) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  862. {"sri.dz", OP_SI(0x8) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  863. {"sri.em", OP_REG(0x318) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  864. {"sri.em", OP_SI(0xC) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  865. {"sri.es", OP_REG(0x31A) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  866. {"sri.es", OP_SI(0xD) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  867. {"sri.ez", OP_REG(0x316) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  868. {"sri.ez", OP_SI(0xB) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  869. {"sri.im", OP_REG(0x31E) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  870. {"sri.im", OP_SI(0xF) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  871. {"sri.iz", OP_REG(0x31C) | i(1) | n(1), MASK_REG | i(1) | n(1), 0, {REG_0, ENDMASK, REG_22, REG_DEST} },
  872. {"sri.iz", OP_SI(0xE) | i(1) | n(1), MASK_SI | i(1) | n(1), 0, {ROTATE, ENDMASK, REG_22, REG_DEST} },
  873. /* Store Data into Memory */
  874. {"st", OP_SI(0x32), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  875. {"st", OP_LI(0x365) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  876. {"st", OP_REG(0x364) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  877. {"st.b", OP_SI(0x30), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  878. {"st.b", OP_LI(0x361) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  879. {"st.b", OP_REG(0x360) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  880. {"st.d", OP_SI(0x33), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST_E} },
  881. {"st.d", OP_LI(0x367) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  882. {"st.d", OP_REG(0x366) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST_E} },
  883. {"st.h", OP_SI(0x31), (MASK_SI & ~M_SI(1)), 0, {OFF_SS_BR, REG_BASE_M_SI, REG_DEST} },
  884. {"st.h", OP_LI(0x363) | D(0), (MASK_LI & ~M_REG(1)) | D(1), 0, {OFF_SL_BR_SCALED, REG_BASE_M_LI, REG_DEST} },
  885. {"st.h", OP_REG(0x362) | D(0), (MASK_REG & ~M_REG(1)) | D(1), 0, {REG_SCALED, REG_BASE_M_LI, REG_DEST} },
  886. /* Signed Integer Subtract */
  887. {"sub", OP_SI(0x5A), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
  888. {"sub", OP_LI(0x3B5), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
  889. {"sub", OP_REG(0x3B4), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  890. /* Unsigned Integer Subtract */
  891. {"subu", OP_SI(0x5B), MASK_SI, 0, {SSI, REG_22, REG_DEST} },
  892. {"subu", OP_LI(0x3B7), MASK_LI, 0, {LSI, REG_22, REG_DEST} },
  893. {"subu", OP_REG(0x3B6), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  894. /* Write Control Register
  895. Is a special form of the "swcr" instruction so comes before it in the table. */
  896. {"wrcr", OP_SI(0x5), MASK_SI | (0x1F << 27), 0, {CR_SI, REG_22} },
  897. {"wrcr", OP_LI(0x30B), MASK_LI | (0x1F << 27), 0, {CR_LI, REG_22} },
  898. {"wrcr", OP_REG(0x30A), MASK_REG | (0x1F << 27), 0, {REG_0, REG_22} },
  899. /* Swap Control Register */
  900. {"swcr", OP_SI(0x5), MASK_SI, 0, {CR_SI, REG_22, REG_DEST} },
  901. {"swcr", OP_LI(0x30B), MASK_LI, 0, {CR_LI, REG_22, REG_DEST} },
  902. {"swcr", OP_REG(0x30A), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  903. /* Trap */
  904. {"trap", OP_SI(0x1) | E(0), MASK_SI | E(1), 0, {SUI} },
  905. {"trap", OP_LI(0x303) | E(0), MASK_LI | E(1), 0, {LUI} },
  906. {"trap", OP_REG(0x302) | E(0), MASK_REG | E(1), 0, {REG_0} },
  907. /* Vector Floating-Point Add */
  908. {"vadd.dd", OP_REG(0x3C0) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0_E, REG_22_E, REG_22_E} },
  909. {"vadd.sd", OP_LI(0x3C1) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22_E, REG_22_E} },
  910. {"vadd.sd", OP_REG(0x3C0) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E, REG_22_E} },
  911. {"vadd.ss", OP_LI(0x3C1) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22, REG_22} },
  912. {"vadd.ss", OP_REG(0x3C0) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22, REG_22} },
  913. /* Vector Floating-Point Multiply and Add to Accumulator FIXME! This is not yet fully implemented.
  914. From the documentation there appears to be no way to tell the difference between the opcodes for
  915. instructions that have register destinations and instructions that have accumulator destinations.
  916. Further investigation is necessary. Since this isn't critical to getting a TIC80 toolchain up
  917. and running, it is defered until later. */
  918. /* Vector Floating-Point Multiply
  919. Note: If r0 is in the destination reg, then this is a "vector nop" instruction. */
  920. {"vmpy.dd", OP_REG(0x3C4) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0_E, REG_22_E, REG_22_E} },
  921. {"vmpy.sd", OP_LI(0x3C5) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {SPFI, REG_22_E, REG_22_E} },
  922. {"vmpy.sd", OP_REG(0x3C4) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0, REG_22_E, REG_22_E} },
  923. {"vmpy.ss", OP_LI(0x3C5) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {SPFI, REG_22, REG_22} },
  924. {"vmpy.ss", OP_REG(0x3C4) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR | TIC80_NO_R0_DEST, {REG_0, REG_22, REG_22} },
  925. /* Vector Floating-Point Multiply and Subtract from Accumulator
  926. FIXME: See note above for vmac instruction */
  927. /* Vector Floating-Point Subtract Accumulator From Source
  928. FIXME: See note above for vmac instruction */
  929. /* Vector Round With Floating-Point Input
  930. FIXME: See note above for vmac instruction */
  931. /* Vector Round with Integer Input */
  932. {"vrnd.id", OP_LI (0x3CB) | P2(1) | P1(0), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LSI, REG_22_E}},
  933. {"vrnd.id", OP_REG (0x3CA) | P2(1) | P1(0), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E}},
  934. {"vrnd.is", OP_LI (0x3CB) | P2(0) | P1(0), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LSI, REG_22}},
  935. {"vrnd.is", OP_REG (0x3CA) | P2(0) | P1(0), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22}},
  936. {"vrnd.ud", OP_LI (0x3CB) | P2(1) | P1(1), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LUI, REG_22_E}},
  937. {"vrnd.ud", OP_REG (0x3CA) | P2(1) | P1(1), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E}},
  938. {"vrnd.us", OP_LI (0x3CB) | P2(0) | P1(1), MASK_LI | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {LUI, REG_22}},
  939. {"vrnd.us", OP_REG (0x3CA) | P2(0) | P1(1), MASK_REG | V_a0(1) | V_Z(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22}},
  940. /* Vector Floating-Point Subtract */
  941. {"vsub.dd", OP_REG(0x3C2) | P2(1) | P1(1), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0_E, REG_22_E, REG_22_E} },
  942. {"vsub.sd", OP_LI(0x3C3) | P2(1) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22_E, REG_22_E} },
  943. {"vsub.sd", OP_REG(0x3C2) | P2(1) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22_E, REG_22_E} },
  944. {"vsub.ss", OP_LI(0x3C3) | P2(0) | P1(0), MASK_LI | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {SPFI, REG_22, REG_22} },
  945. {"vsub.ss", OP_REG(0x3C2) | P2(0) | P1(0), MASK_REG | V_a1(1) | P2(1) | P1(1), TIC80_VECTOR, {REG_0, REG_22, REG_22} },
  946. /* Vector Load Data Into Register - Note that the vector load/store instructions come after the other
  947. vector instructions so that the disassembler will always print the load/store instruction second for
  948. vector instructions that have two instructions in the same opcode. */
  949. {"vld0.d", OP_V(0x1E) | V_m(1) | V_S(1) | V_p(0), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
  950. {"vld0.s", OP_V(0x1E) | V_m(1) | V_S(0) | V_p(0), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
  951. {"vld1.d", OP_V(0x1E) | V_m(1) | V_S(1) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
  952. {"vld1.s", OP_V(0x1E) | V_m(1) | V_S(0) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
  953. /* Vector Store Data Into Memory - Note that the vector load/store instructions come after the other
  954. vector instructions so that the disassembler will always print the load/store instruction second for
  955. vector instructions that have two instructions in the same opcode. */
  956. {"vst.d", OP_V(0x1E) | V_m(0) | V_S(1) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST_E} },
  957. {"vst.s", OP_V(0x1E) | V_m(0) | V_S(0) | V_p(1), MASK_V | V_m(1) | V_S(1) | V_p(1), TIC80_VECTOR, {REG_DEST} },
  958. {"xnor", OP_SI(0x19), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  959. {"xnor", OP_LI(0x333), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  960. {"xnor", OP_REG(0x332), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  961. {"xor", OP_SI(0x16), MASK_SI, 0, {SUBF, REG_22, REG_DEST} },
  962. {"xor", OP_LI(0x32D), MASK_LI, 0, {LUBF, REG_22, REG_DEST} },
  963. {"xor", OP_REG(0x32C), MASK_REG, 0, {REG_0, REG_22, REG_DEST} },
  964. };
  965. const int tic80_num_opcodes = sizeof (tic80_opcodes) / sizeof (tic80_opcodes[0]);