z8kgen.c 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  1. /* Copyright (C) 2001-2015 Free Software Foundation, Inc.
  2. This file is part of the GNU opcodes library.
  3. This library is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3, or (at your option)
  6. any later version.
  7. It is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  9. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  10. License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this file; see the file COPYING. If not, write to the
  13. Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
  14. MA 02110-1301, USA. */
  15. /* This program generates z8k-opc.h. */
  16. #include "sysdep.h"
  17. #include <stdio.h>
  18. #include "libiberty.h"
  19. #define BYTE_INFO_LEN 10
  20. struct op
  21. {
  22. char *flags;
  23. int cycles;
  24. char type;
  25. char *bits;
  26. char *name;
  27. /* Unique number for stable sorting. */
  28. int id;
  29. };
  30. #define iswhite(x) ((x) == ' ' || (x) == '\t')
  31. static struct op opt[] =
  32. {
  33. {"------", 2, 8, "0011 0110 0000 0000", "bpt", 0}, /* Breakpoint used by the simulator. */
  34. {"------", 10, 8, "0000 1111 0000 1100", "brk", 0}, /* Breakpoint used by real hardware.
  35. (ext0f #0x0c). */
  36. {"------", 10, 8, "0000 1110 imm8", "ext0e imm8", 0},
  37. {"------", 10, 8, "0000 1111 imm8", "ext0f imm8", 0},
  38. {"------", 10, 8, "1000 1110 imm8", "ext8e imm8", 0},
  39. {"------", 10, 8, "1000 1111 imm8", "ext8f imm8", 0},
  40. {"------", 10, 8, "0011 0110 imm8", "rsvd36", 0},
  41. {"------", 10, 8, "0011 1000 imm8", "rsvd38", 0},
  42. {"------", 10, 8, "0111 1000 imm8", "rsvd78", 0},
  43. {"------", 10, 8, "0111 1110 imm8", "rsvd7e", 0},
  44. {"------", 10, 8, "1001 1101 imm8", "rsvd9d", 0},
  45. {"------", 10, 8, "1001 1111 imm8", "rsvd9f", 0},
  46. {"------", 10, 8, "1011 1001 imm8", "rsvdb9", 0},
  47. {"------", 10, 8, "1011 1111 imm8", "rsvdbf", 0},
  48. {"---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 1000", "ldd @rd,@rs,rr", 0},
  49. {"---V--", 11, 16, "1011 1011 ssN0 1001 0000 rrrr ddN0 0000", "lddr @rd,@rs,rr", 0},
  50. {"---V--", 11, 8, "1011 1010 ssN0 1001 0000 rrrr ddN0 0000", "lddrb @rd,@rs,rr", 0},
  51. {"---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 0000", "ldir @rd,@rs,rr", 0},
  52. {"CZSV--", 11, 16, "1011 1011 ssN0 0000 0000 rrrr dddd cccc", "cpi rd,@rs,rr,cc", 0},
  53. {"CZSV--", 11, 16, "1011 1011 ssN0 0100 0000 rrrr dddd cccc", "cpir rd,@rs,rr,cc", 0},
  54. {"CZSV--", 11, 16, "1011 1011 ssN0 1100 0000 rrrr dddd cccc", "cpdr rd,@rs,rr,cc", 0},
  55. {"---V--", 11, 16, "1011 1011 ssN0 0001 0000 rrrr ddN0 1000", "ldi @rd,@rs,rr", 0},
  56. {"CZSV--", 11, 16, "1011 1011 ssN0 1000 0000 rrrr dddd cccc", "cpd rd,@rs,rr,cc", 0},
  57. {"---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 0000", "ldirb @rd,@rs,rr", 0},
  58. {"---V--", 11, 8, "1011 1010 ssN0 1001 0000 rrrr ddN0 1000", "lddb @rd,@rs,rr", 0},
  59. {"---V--", 11, 8, "1011 1010 ssN0 0001 0000 rrrr ddN0 1000", "ldib @rd,@rs,rr", 0},
  60. {"CZSV--", 11, 8, "1011 1010 ssN0 1000 0000 rrrr dddd cccc", "cpdb rbd,@rs,rr,cc", 0},
  61. {"CZSV--", 11, 8, "1011 1010 ssN0 1100 0000 rrrr dddd cccc", "cpdrb rbd,@rs,rr,cc", 0},
  62. {"CZSV--", 11, 8, "1011 1010 ssN0 0000 0000 rrrr dddd cccc", "cpib rbd,@rs,rr,cc", 0},
  63. {"CZSV--", 11, 8, "1011 1010 ssN0 0100 0000 rrrr dddd cccc", "cpirb rbd,@rs,rr,cc", 0},
  64. {"CZSV--", 11, 16, "1011 1011 ssN0 1010 0000 rrrr ddN0 cccc", "cpsd @rd,@rs,rr,cc", 0},
  65. {"CZSV--", 11, 8, "1011 1010 ssN0 1010 0000 rrrr ddN0 cccc", "cpsdb @rd,@rs,rr,cc", 0},
  66. {"CZSV--", 11, 16, "1011 1011 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdr @rd,@rs,rr,cc", 0},
  67. {"CZSV--", 11, 8, "1011 1010 ssN0 1110 0000 rrrr ddN0 cccc", "cpsdrb @rd,@rs,rr,cc", 0},
  68. {"CZSV--", 11, 16, "1011 1011 ssN0 0010 0000 rrrr ddN0 cccc", "cpsi @rd,@rs,rr,cc", 0},
  69. {"CZSV--", 11, 8, "1011 1010 ssN0 0010 0000 rrrr ddN0 cccc", "cpsib @rd,@rs,rr,cc", 0},
  70. {"CZSV--", 11, 16, "1011 1011 ssN0 0110 0000 rrrr ddN0 cccc", "cpsir @rd,@rs,rr,cc", 0},
  71. {"CZSV--", 11, 8, "1011 1010 ssN0 0110 0000 rrrr ddN0 cccc", "cpsirb @rd,@rs,rr,cc", 0},
  72. {"CZSV--", 5, 16, "1011 0101 ssss dddd", "adc rd,rs", 0},
  73. {"CZSVDH", 5, 8, "1011 0100 ssss dddd", "adcb rbd,rbs", 0},
  74. {"CZSV--", 7, 16, "0000 0001 ssN0 dddd", "add rd,@rs", 0},
  75. {"CZSV--", 9, 16, "0100 0001 0000 dddd address_src", "add rd,address_src", 0},
  76. {"CZSV--", 10, 16, "0100 0001 ssN0 dddd address_src", "add rd,address_src(rs)", 0},
  77. {"CZSV--", 7, 16, "0000 0001 0000 dddd imm16", "add rd,imm16", 0},
  78. {"CZSV--", 4, 16, "1000 0001 ssss dddd", "add rd,rs", 0},
  79. {"CZSVDH", 7, 8, "0000 0000 ssN0 dddd", "addb rbd,@rs", 0},
  80. {"CZSVDH", 9, 8, "0100 0000 0000 dddd address_src", "addb rbd,address_src", 0},
  81. {"CZSVDH", 10, 8, "0100 0000 ssN0 dddd address_src", "addb rbd,address_src(rs)", 0},
  82. {"CZSVDH", 7, 8, "0000 0000 0000 dddd imm8 imm8", "addb rbd,imm8", 0},
  83. {"CZSVDH", 4, 8, "1000 0000 ssss dddd", "addb rbd,rbs", 0},
  84. {"CZSV--", 14, 32, "0001 0110 ssN0 dddd", "addl rrd,@rs", 0},
  85. {"CZSV--", 15, 32, "0101 0110 0000 dddd address_src", "addl rrd,address_src", 0},
  86. {"CZSV--", 16, 32, "0101 0110 ssN0 dddd address_src", "addl rrd,address_src(rs)", 0},
  87. {"CZSV--", 14, 32, "0001 0110 0000 dddd imm32", "addl rrd,imm32", 0},
  88. {"CZSV--", 8, 32, "1001 0110 ssss dddd", "addl rrd,rrs", 0},
  89. {"-ZS---", 7, 16, "0000 0111 ssN0 dddd", "and rd,@rs", 0},
  90. {"-ZS---", 9, 16, "0100 0111 0000 dddd address_src", "and rd,address_src", 0},
  91. {"-ZS---", 10, 16, "0100 0111 ssN0 dddd address_src", "and rd,address_src(rs)", 0},
  92. {"-ZS---", 7, 16, "0000 0111 0000 dddd imm16", "and rd,imm16", 0},
  93. {"-ZS---", 4, 16, "1000 0111 ssss dddd", "and rd,rs", 0},
  94. {"-ZSP--", 7, 8, "0000 0110 ssN0 dddd", "andb rbd,@rs", 0},
  95. {"-ZSP--", 9, 8, "0100 0110 0000 dddd address_src", "andb rbd,address_src", 0},
  96. {"-ZSP--", 10, 8, "0100 0110 ssN0 dddd address_src", "andb rbd,address_src(rs)", 0},
  97. {"-ZSP--", 7, 8, "0000 0110 0000 dddd imm8 imm8", "andb rbd,imm8", 0},
  98. {"-ZSP--", 4, 8, "1000 0110 ssss dddd", "andb rbd,rbs", 0},
  99. {"-Z----", 8, 16, "0010 0111 ddN0 imm4", "bit @rd,imm4", 0},
  100. {"-Z----", 11, 16, "0110 0111 ddN0 imm4 address_dst", "bit address_dst(rd),imm4", 0},
  101. {"-Z----", 10, 16, "0110 0111 0000 imm4 address_dst", "bit address_dst,imm4", 0},
  102. {"-Z----", 4, 16, "1010 0111 dddd imm4", "bit rd,imm4", 0},
  103. {"-Z----", 10, 16, "0010 0111 0000 ssss 0000 dddd 0000 0000", "bit rd,rs", 0},
  104. {"-Z----", 8, 8, "0010 0110 ddN0 imm4", "bitb @rd,imm4", 0},
  105. {"-Z----", 11, 8, "0110 0110 ddN0 imm4 address_dst", "bitb address_dst(rd),imm4", 0},
  106. {"-Z----", 10, 8, "0110 0110 0000 imm4 address_dst", "bitb address_dst,imm4", 0},
  107. {"-Z----", 4, 8, "1010 0110 dddd imm4", "bitb rbd,imm4", 0},
  108. {"-Z----", 10, 8, "0010 0110 0000 ssss 0000 dddd 0000 0000", "bitb rbd,rs", 0},
  109. {"------", 10, 32, "0001 1111 ddN0 0000", "call @rd", 0},
  110. {"------", 12, 32, "0101 1111 0000 0000 address_dst", "call address_dst", 0},
  111. {"------", 13, 32, "0101 1111 ddN0 0000 address_dst", "call address_dst(rd)", 0},
  112. {"------", 10, 16, "1101 disp12", "calr disp12", 0},
  113. {"------", 8, 16, "0000 1101 ddN0 1000", "clr @rd", 0},
  114. {"------", 11, 16, "0100 1101 0000 1000 address_dst", "clr address_dst", 0},
  115. {"------", 12, 16, "0100 1101 ddN0 1000 address_dst", "clr address_dst(rd)", 0},
  116. {"------", 7, 16, "1000 1101 dddd 1000", "clr rd", 0},
  117. {"------", 8, 8, "0000 1100 ddN0 1000", "clrb @rd", 0},
  118. {"------", 11, 8, "0100 1100 0000 1000 address_dst", "clrb address_dst", 0},
  119. {"------", 12, 8, "0100 1100 ddN0 1000 address_dst", "clrb address_dst(rd)", 0},
  120. {"------", 7, 8, "1000 1100 dddd 1000", "clrb rbd", 0},
  121. {"-ZS---", 12, 16, "0000 1101 ddN0 0000", "com @rd", 0},
  122. {"-ZS---", 15, 16, "0100 1101 0000 0000 address_dst", "com address_dst", 0},
  123. {"-ZS---", 16, 16, "0100 1101 ddN0 0000 address_dst", "com address_dst(rd)", 0},
  124. {"-ZS---", 7, 16, "1000 1101 dddd 0000", "com rd", 0},
  125. {"-ZSP--", 12, 8, "0000 1100 ddN0 0000", "comb @rd", 0},
  126. {"-ZSP--", 15, 8, "0100 1100 0000 0000 address_dst", "comb address_dst", 0},
  127. {"-ZSP--", 16, 8, "0100 1100 ddN0 0000 address_dst", "comb address_dst(rd)", 0},
  128. {"-ZSP--", 7, 8, "1000 1100 dddd 0000", "comb rbd", 0},
  129. {"CZSP--", 7, 16, "1000 1101 flags 0101", "comflg flags", 0},
  130. {"CZSV--", 11, 16, "0000 1101 ddN0 0001 imm16", "cp @rd,imm16", 0},
  131. {"CZSV--", 15, 16, "0100 1101 ddN0 0001 address_dst imm16", "cp address_dst(rd),imm16", 0},
  132. {"CZSV--", 14, 16, "0100 1101 0000 0001 address_dst imm16", "cp address_dst,imm16", 0},
  133. {"CZSV--", 7, 16, "0000 1011 ssN0 dddd", "cp rd,@rs", 0},
  134. {"CZSV--", 9, 16, "0100 1011 0000 dddd address_src", "cp rd,address_src", 0},
  135. {"CZSV--", 10, 16, "0100 1011 ssN0 dddd address_src", "cp rd,address_src(rs)", 0},
  136. {"CZSV--", 7, 16, "0000 1011 0000 dddd imm16", "cp rd,imm16", 0},
  137. {"CZSV--", 4, 16, "1000 1011 ssss dddd", "cp rd,rs", 0},
  138. {"CZSV--", 11, 8, "0000 1100 ddN0 0001 imm8 imm8", "cpb @rd,imm8", 0},
  139. {"CZSV--", 15, 8, "0100 1100 ddN0 0001 address_dst imm8 imm8", "cpb address_dst(rd),imm8", 0},
  140. {"CZSV--", 14, 8, "0100 1100 0000 0001 address_dst imm8 imm8", "cpb address_dst,imm8", 0},
  141. {"CZSV--", 7, 8, "0000 1010 ssN0 dddd", "cpb rbd,@rs", 0},
  142. {"CZSV--", 9, 8, "0100 1010 0000 dddd address_src", "cpb rbd,address_src", 0},
  143. {"CZSV--", 10, 8, "0100 1010 ssN0 dddd address_src", "cpb rbd,address_src(rs)", 0},
  144. {"CZSV--", 7, 8, "0000 1010 0000 dddd imm8 imm8", "cpb rbd,imm8", 0},
  145. {"CZSV--", 4, 8, "1000 1010 ssss dddd", "cpb rbd,rbs", 0},
  146. {"CZSV--", 14, 32, "0001 0000 ssN0 dddd", "cpl rrd,@rs", 0},
  147. {"CZSV--", 15, 32, "0101 0000 0000 dddd address_src", "cpl rrd,address_src", 0},
  148. {"CZSV--", 16, 32, "0101 0000 ssN0 dddd address_src", "cpl rrd,address_src(rs)", 0},
  149. {"CZSV--", 14, 32, "0001 0000 0000 dddd imm32", "cpl rrd,imm32", 0},
  150. {"CZSV--", 8, 32, "1001 0000 ssss dddd", "cpl rrd,rrs", 0},
  151. {"CZS---", 5, 8, "1011 0000 dddd 0000", "dab rbd", 0},
  152. {"------", 11, 16, "1111 dddd 0disp7", "dbjnz rbd,disp7", 0},
  153. {"-ZSV--", 11, 16, "0010 1011 ddN0 imm4m1", "dec @rd,imm4m1", 0},
  154. {"-ZSV--", 14, 16, "0110 1011 ddN0 imm4m1 address_dst", "dec address_dst(rd),imm4m1", 0},
  155. {"-ZSV--", 13, 16, "0110 1011 0000 imm4m1 address_dst", "dec address_dst,imm4m1", 0},
  156. {"-ZSV--", 4, 16, "1010 1011 dddd imm4m1", "dec rd,imm4m1", 0},
  157. {"-ZSV--", 11, 8, "0010 1010 ddN0 imm4m1", "decb @rd,imm4m1", 0},
  158. {"-ZSV--", 14, 8, "0110 1010 ddN0 imm4m1 address_dst", "decb address_dst(rd),imm4m1", 0},
  159. {"-ZSV--", 13, 8, "0110 1010 0000 imm4m1 address_dst", "decb address_dst,imm4m1", 0},
  160. {"-ZSV--", 4, 8, "1010 1010 dddd imm4m1", "decb rbd,imm4m1", 0},
  161. {"------", 7, 16, "0111 1100 0000 00ii", "di i2", 0},
  162. {"CZSV--", 107, 16, "0001 1011 ssN0 dddd", "div rrd,@rs", 0},
  163. {"CZSV--", 107, 16, "0101 1011 0000 dddd address_src", "div rrd,address_src", 0},
  164. {"CZSV--", 107, 16, "0101 1011 ssN0 dddd address_src", "div rrd,address_src(rs)", 0},
  165. {"CZSV--", 107, 16, "0001 1011 0000 dddd imm16", "div rrd,imm16", 0},
  166. {"CZSV--", 107, 16, "1001 1011 ssss dddd", "div rrd,rs", 0},
  167. {"CZSV--", 744, 32, "0001 1010 ssN0 dddd", "divl rqd,@rs", 0},
  168. {"CZSV--", 745, 32, "0101 1010 0000 dddd address_src", "divl rqd,address_src", 0},
  169. {"CZSV--", 746, 32, "0101 1010 ssN0 dddd address_src", "divl rqd,address_src(rs)", 0},
  170. {"CZSV--", 744, 32, "0001 1010 0000 dddd imm32", "divl rqd,imm32", 0},
  171. {"CZSV--", 744, 32, "1001 1010 ssss dddd", "divl rqd,rrs", 0},
  172. {"------", 11, 16, "1111 dddd 1disp7", "djnz rd,disp7", 0},
  173. {"------", 7, 16, "0111 1100 0000 01ii", "ei i2", 0},
  174. {"------", 6, 16, "1010 1101 ssss dddd", "ex rd,rs", 0},
  175. {"------", 12, 16, "0010 1101 ssN0 dddd", "ex rd,@rs", 0},
  176. {"------", 15, 16, "0110 1101 0000 dddd address_src", "ex rd,address_src", 0},
  177. {"------", 16, 16, "0110 1101 ssN0 dddd address_src", "ex rd,address_src(rs)", 0},
  178. {"------", 12, 8, "0010 1100 ssN0 dddd", "exb rbd,@rs", 0},
  179. {"------", 15, 8, "0110 1100 0000 dddd address_src", "exb rbd,address_src", 0},
  180. {"------", 16, 8, "0110 1100 ssN0 dddd address_src", "exb rbd,address_src(rs)", 0},
  181. {"------", 6, 8, "1010 1100 ssss dddd", "exb rbd,rbs", 0},
  182. {"------", 11, 16, "1011 0001 dddd 1010", "exts rrd", 0},
  183. {"------", 11, 8, "1011 0001 dddd 0000", "extsb rd", 0},
  184. {"------", 11, 32, "1011 0001 dddd 0111", "extsl rqd", 0},
  185. {"------", 8, 16, "0111 1010 0000 0000", "halt", 0},
  186. {"------", 10, 16, "0011 1101 ssss dddd", "in rd,@ri", 0},
  187. {"------", 12, 8, "0011 1100 ssss dddd", "inb rbd,@ri", 0},
  188. {"------", 12, 16, "0011 1011 dddd 0100 imm16", "in rd,imm16", 0},
  189. {"------", 10, 8, "0011 1010 dddd 0100 imm16", "inb rbd,imm16", 0},
  190. {"-ZSV--", 11, 16, "0010 1001 ddN0 imm4m1", "inc @rd,imm4m1", 0},
  191. {"-ZSV--", 14, 16, "0110 1001 ddN0 imm4m1 address_dst", "inc address_dst(rd),imm4m1", 0},
  192. {"-ZSV--", 13, 16, "0110 1001 0000 imm4m1 address_dst", "inc address_dst,imm4m1", 0},
  193. {"-ZSV--", 4, 16, "1010 1001 dddd imm4m1", "inc rd,imm4m1", 0},
  194. {"-ZSV--", 11, 8, "0010 1000 ddN0 imm4m1", "incb @rd,imm4m1", 0},
  195. {"-ZSV--", 14, 8, "0110 1000 ddN0 imm4m1 address_dst", "incb address_dst(rd),imm4m1", 0},
  196. {"-ZSV--", 13, 8, "0110 1000 0000 imm4m1 address_dst", "incb address_dst,imm4m1", 0},
  197. {"-ZSV--", 4, 8, "1010 1000 dddd imm4m1", "incb rbd,imm4m1", 0},
  198. {"---V--", 21, 16, "0011 1011 ssss 1000 0000 aaaa ddN0 1000", "ind @rd,@ri,ra", 0},
  199. {"---V--", 21, 8, "0011 1010 ssss 1000 0000 aaaa ddN0 1000", "indb @rd,@ri,ra", 0},
  200. {"---V--", 11, 16, "0011 1011 ssss 1000 0000 aaaa ddN0 0000", "indr @rd,@ri,ra", 0},
  201. {"---V--", 11, 8, "0011 1010 ssss 1000 0000 aaaa ddN0 0000", "indrb @rd,@ri,ra", 0},
  202. {"---V--", 21, 16, "0011 1011 ssss 0000 0000 aaaa ddN0 1000", "ini @rd,@ri,ra", 0},
  203. {"---V--", 21, 8, "0011 1010 ssss 0000 0000 aaaa ddN0 1000", "inib @rd,@ri,ra", 0},
  204. {"---V--", 11, 16, "0011 1011 ssss 0000 0000 aaaa ddN0 0000", "inir @rd,@ri,ra", 0},
  205. {"---V--", 11, 8, "0011 1010 ssss 0000 0000 aaaa ddN0 0000", "inirb @rd,@ri,ra", 0},
  206. {"CZSVDH", 13, 16, "0111 1011 0000 0000", "iret", 0},
  207. {"------", 10, 16, "0001 1110 ddN0 cccc", "jp cc,@rd", 0},
  208. {"------", 7, 16, "0101 1110 0000 cccc address_dst", "jp cc,address_dst", 0},
  209. {"------", 8, 16, "0101 1110 ddN0 cccc address_dst", "jp cc,address_dst(rd)", 0},
  210. {"------", 6, 16, "1110 cccc disp8", "jr cc,disp8", 0},
  211. {"------", 7, 16, "0000 1101 ddN0 0101 imm16", "ld @rd,imm16", 0},
  212. {"------", 8, 16, "0010 1111 ddN0 ssss", "ld @rd,rs", 0},
  213. {"------", 15, 16, "0100 1101 ddN0 0101 address_dst imm16", "ld address_dst(rd),imm16", 0},
  214. {"------", 12, 16, "0110 1111 ddN0 ssss address_dst", "ld address_dst(rd),rs", 0},
  215. {"------", 14, 16, "0100 1101 0000 0101 address_dst imm16", "ld address_dst,imm16", 0},
  216. {"------", 11, 16, "0110 1111 0000 ssss address_dst", "ld address_dst,rs", 0},
  217. {"------", 14, 16, "0011 0011 ddN0 ssss imm16", "ld rd(imm16),rs", 0},
  218. {"------", 14, 16, "0111 0011 ddN0 ssss 0000 xxxx 0000 0000", "ld rd(rx),rs", 0},
  219. {"------", 7, 16, "0010 0001 ssN0 dddd", "ld rd,@rs", 0},
  220. {"------", 9, 16, "0110 0001 0000 dddd address_src", "ld rd,address_src", 0},
  221. {"------", 10, 16, "0110 0001 ssN0 dddd address_src", "ld rd,address_src(rs)", 0},
  222. {"------", 7, 16, "0010 0001 0000 dddd imm16", "ld rd,imm16", 0},
  223. {"------", 3, 16, "1010 0001 ssss dddd", "ld rd,rs", 0},
  224. {"------", 14, 16, "0011 0001 ssN0 dddd imm16", "ld rd,rs(imm16)", 0},
  225. {"------", 14, 16, "0111 0001 ssN0 dddd 0000 xxxx 0000 0000", "ld rd,rs(rx)", 0},
  226. {"------", 7, 8, "0000 1100 ddN0 0101 imm8 imm8", "ldb @rd,imm8", 0},
  227. {"------", 8, 8, "0010 1110 ddN0 ssss", "ldb @rd,rbs", 0},
  228. {"------", 15, 8, "0100 1100 ddN0 0101 address_dst imm8 imm8", "ldb address_dst(rd),imm8", 0},
  229. {"------", 12, 8, "0110 1110 ddN0 ssss address_dst", "ldb address_dst(rd),rbs", 0},
  230. {"------", 14, 8, "0100 1100 0000 0101 address_dst imm8 imm8", "ldb address_dst,imm8", 0},
  231. {"------", 11, 8, "0110 1110 0000 ssss address_dst", "ldb address_dst,rbs", 0},
  232. {"------", 14, 8, "0011 0010 ddN0 ssss imm16", "ldb rd(imm16),rbs", 0},
  233. {"------", 14, 8, "0111 0010 ddN0 ssss 0000 xxxx 0000 0000", "ldb rd(rx),rbs", 0},
  234. {"------", 7, 8, "0010 0000 ssN0 dddd", "ldb rbd,@rs", 0},
  235. {"------", 9, 8, "0110 0000 0000 dddd address_src", "ldb rbd,address_src", 0},
  236. {"------", 10, 8, "0110 0000 ssN0 dddd address_src", "ldb rbd,address_src(rs)", 0},
  237. {"------", 5, 8, "1100 dddd imm8", "ldb rbd,imm8", 0},
  238. {"------", 7, 8, "0010 0000 0000 dddd imm8 imm8", "ldb rbd,imm8", 0},
  239. {"------", 3, 8, "1010 0000 ssss dddd", "ldb rbd,rbs", 0},
  240. {"------", 14, 8, "0011 0000 ssN0 dddd imm16", "ldb rbd,rs(imm16)", 0},
  241. {"------", 14, 8, "0111 0000 ssN0 dddd 0000 xxxx 0000 0000", "ldb rbd,rs(rx)", 0},
  242. {"------", 11, 32, "0001 1101 ddN0 ssss", "ldl @rd,rrs", 0},
  243. {"------", 14, 32, "0101 1101 ddN0 ssss address_dst", "ldl address_dst(rd),rrs", 0},
  244. {"------", 15, 32, "0101 1101 0000 ssss address_dst", "ldl address_dst,rrs", 0},
  245. {"------", 17, 32, "0011 0111 ddN0 ssss imm16", "ldl rd(imm16),rrs", 0},
  246. {"------", 17, 32, "0111 0111 ddN0 ssss 0000 xxxx 0000 0000", "ldl rd(rx),rrs", 0},
  247. {"------", 11, 32, "0001 0100 ssN0 dddd", "ldl rrd,@rs", 0},
  248. {"------", 12, 32, "0101 0100 0000 dddd address_src", "ldl rrd,address_src", 0},
  249. {"------", 13, 32, "0101 0100 ssN0 dddd address_src", "ldl rrd,address_src(rs)", 0},
  250. {"------", 11, 32, "0001 0100 0000 dddd imm32", "ldl rrd,imm32", 0},
  251. {"------", 5, 32, "1001 0100 ssss dddd", "ldl rrd,rrs", 0},
  252. {"------", 17, 32, "0011 0101 ssN0 dddd imm16", "ldl rrd,rs(imm16)", 0},
  253. {"------", 17, 32, "0111 0101 ssN0 dddd 0000 xxxx 0000 0000", "ldl rrd,rs(rx)", 0},
  254. {"------", 12, 16, "0111 0110 0000 dddd address_src", "lda prd,address_src", 0},
  255. {"------", 13, 16, "0111 0110 ssN0 dddd address_src", "lda prd,address_src(rs)", 0},
  256. {"------", 15, 16, "0011 0100 ssN0 dddd imm16", "lda prd,rs(imm16)", 0},
  257. {"------", 15, 16, "0111 0100 ssN0 dddd 0000 xxxx 0000 0000", "lda prd,rs(rx)", 0},
  258. {"------", 15, 16, "0011 0100 0000 dddd disp16", "ldar prd,disp16", 0},
  259. {"------", 7, 32, "0111 1101 ssss 1ccc", "ldctl ctrl,rs", 0},
  260. {"------", 7, 32, "0111 1101 dddd 0ccc", "ldctl rd,ctrl", 0},
  261. {"------", 5, 16, "1011 1101 dddd imm4", "ldk rd,imm4", 0},
  262. {"------", 11, 16, "0001 1100 ddN0 1001 0000 ssss 0000 imm4m1", "ldm @rd,rs,n", 0},
  263. {"------", 15, 16, "0101 1100 ddN0 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst(rd),rs,n", 0},
  264. {"------", 14, 16, "0101 1100 0000 1001 0000 ssss 0000 imm4m1 address_dst", "ldm address_dst,rs,n", 0},
  265. {"------", 11, 16, "0001 1100 ssN0 0001 0000 dddd 0000 imm4m1", "ldm rd,@rs,n", 0},
  266. {"------", 15, 16, "0101 1100 ssN0 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src(rs),n", 0},
  267. {"------", 14, 16, "0101 1100 0000 0001 0000 dddd 0000 imm4m1 address_src", "ldm rd,address_src,n", 0},
  268. {"CZSVDH", 12, 16, "0011 1001 ssN0 0000", "ldps @rs", 0},
  269. {"CZSVDH", 16, 16, "0111 1001 0000 0000 address_src", "ldps address_src", 0},
  270. {"CZSVDH", 17, 16, "0111 1001 ssN0 0000 address_src", "ldps address_src(rs)", 0},
  271. {"------", 14, 16, "0011 0011 0000 ssss disp16", "ldr disp16,rs", 0},
  272. {"------", 14, 16, "0011 0001 0000 dddd disp16", "ldr rd,disp16", 0},
  273. {"------", 14, 8, "0011 0010 0000 ssss disp16", "ldrb disp16,rbs", 0},
  274. {"------", 14, 8, "0011 0000 0000 dddd disp16", "ldrb rbd,disp16", 0},
  275. {"------", 17, 32, "0011 0111 0000 ssss disp16", "ldrl disp16,rrs", 0},
  276. {"------", 17, 32, "0011 0101 0000 dddd disp16", "ldrl rrd,disp16", 0},
  277. {"CZS---", 7, 16, "0111 1011 0000 1010", "mbit", 0},
  278. {"-ZS---", 12, 16, "0111 1011 dddd 1101", "mreq rd", 0},
  279. {"------", 5, 16, "0111 1011 0000 1001", "mres", 0},
  280. {"------", 5, 16, "0111 1011 0000 1000", "mset", 0},
  281. {"CZSV--", 70, 16, "0001 1001 ssN0 dddd", "mult rrd,@rs", 0},
  282. {"CZSV--", 70, 16, "0101 1001 0000 dddd address_src", "mult rrd,address_src", 0},
  283. {"CZSV--", 70, 16, "0101 1001 ssN0 dddd address_src", "mult rrd,address_src(rs)", 0},
  284. {"CZSV--", 70, 16, "0001 1001 0000 dddd imm16", "mult rrd,imm16", 0},
  285. {"CZSV--", 70, 16, "1001 1001 ssss dddd", "mult rrd,rs", 0},
  286. {"CZSV--", 282, 32, "0001 1000 ssN0 dddd", "multl rqd,@rs", 0},
  287. {"CZSV--", 282, 32, "0101 1000 0000 dddd address_src", "multl rqd,address_src", 0},
  288. {"CZSV--", 282, 32, "0101 1000 ssN0 dddd address_src", "multl rqd,address_src(rs)", 0},
  289. {"CZSV--", 282, 32, "0001 1000 0000 dddd imm32", "multl rqd,imm32", 0},
  290. {"CZSV--", 282, 32, "1001 1000 ssss dddd", "multl rqd,rrs", 0},
  291. {"CZSV--", 12, 16, "0000 1101 ddN0 0010", "neg @rd", 0},
  292. {"CZSV--", 15, 16, "0100 1101 0000 0010 address_dst", "neg address_dst", 0},
  293. {"CZSV--", 16, 16, "0100 1101 ddN0 0010 address_dst", "neg address_dst(rd)", 0},
  294. {"CZSV--", 7, 16, "1000 1101 dddd 0010", "neg rd", 0},
  295. {"CZSV--", 12, 8, "0000 1100 ddN0 0010", "negb @rd", 0},
  296. {"CZSV--", 15, 8, "0100 1100 0000 0010 address_dst", "negb address_dst", 0},
  297. {"CZSV--", 16, 8, "0100 1100 ddN0 0010 address_dst", "negb address_dst(rd)", 0},
  298. {"CZSV--", 7, 8, "1000 1100 dddd 0010", "negb rbd", 0},
  299. {"------", 7, 16, "1000 1101 0000 0111", "nop", 0},
  300. {"CZS---", 7, 16, "0000 0101 ssN0 dddd", "or rd,@rs", 0},
  301. {"CZS---", 9, 16, "0100 0101 0000 dddd address_src", "or rd,address_src", 0},
  302. {"CZS---", 10, 16, "0100 0101 ssN0 dddd address_src", "or rd,address_src(rs)", 0},
  303. {"CZS---", 7, 16, "0000 0101 0000 dddd imm16", "or rd,imm16", 0},
  304. {"CZS---", 4, 16, "1000 0101 ssss dddd", "or rd,rs", 0},
  305. {"CZSP--", 7, 8, "0000 0100 ssN0 dddd", "orb rbd,@rs", 0},
  306. {"CZSP--", 9, 8, "0100 0100 0000 dddd address_src", "orb rbd,address_src", 0},
  307. {"CZSP--", 10, 8, "0100 0100 ssN0 dddd address_src", "orb rbd,address_src(rs)", 0},
  308. {"CZSP--", 7, 8, "0000 0100 0000 dddd imm8 imm8", "orb rbd,imm8", 0},
  309. {"CZSP--", 4, 8, "1000 0100 ssss dddd", "orb rbd,rbs", 0},
  310. {"------", 10, 16, "0011 1111 dddd ssss", "out @ro,rs", 0},
  311. {"------", 12, 16, "0011 1011 ssss 0110 imm16", "out imm16,rs", 0},
  312. {"------", 10, 8, "0011 1110 dddd ssss", "outb @ro,rbs", 0},
  313. {"------", 12, 8, "0011 1010 ssss 0110 imm16", "outb imm16,rbs", 0},
  314. {"---V--", 21, 16, "0011 1011 ssN0 1010 0000 aaaa dddd 1000", "outd @ro,@rs,ra", 0},
  315. {"---V--", 21, 8, "0011 1010 ssN0 1010 0000 aaaa dddd 1000", "outdb @ro,@rs,ra", 0},
  316. {"---V--", 11, 16, "0011 1011 ssN0 1010 0000 aaaa dddd 0000", "otdr @ro,@rs,ra", 0},
  317. {"---V--", 11, 8, "0011 1010 ssN0 1010 0000 aaaa dddd 0000", "otdrb @ro,@rs,ra", 0},
  318. {"---V--", 21, 16, "0011 1011 ssN0 0010 0000 aaaa dddd 1000", "outi @ro,@rs,ra", 0},
  319. {"---V--", 21, 8, "0011 1010 ssN0 0010 0000 aaaa dddd 1000", "outib @ro,@rs,ra", 0},
  320. {"---V--", 11, 16, "0011 1011 ssN0 0010 0000 aaaa dddd 0000", "otir @ro,@rs,ra", 0},
  321. {"---V--", 11, 8, "0011 1010 ssN0 0010 0000 aaaa dddd 0000", "otirb @ro,@rs,ra", 0},
  322. {"------", 12, 16, "0001 0111 ssN0 ddN0", "pop @rd,@rs", 0},
  323. {"------", 16, 16, "0101 0111 ssN0 ddN0 address_dst", "pop address_dst(rd),@rs", 0},
  324. {"------", 16, 16, "0101 0111 ssN0 0000 address_dst", "pop address_dst,@rs", 0},
  325. {"------", 8, 16, "1001 0111 ssN0 dddd", "pop rd,@rs", 0},
  326. {"------", 19, 32, "0001 0101 ssN0 ddN0", "popl @rd,@rs", 0},
  327. {"------", 23, 32, "0101 0101 ssN0 ddN0 address_dst", "popl address_dst(rd),@rs", 0},
  328. {"------", 23, 32, "0101 0101 ssN0 0000 address_dst", "popl address_dst,@rs", 0},
  329. {"------", 12, 32, "1001 0101 ssN0 dddd", "popl rrd,@rs", 0},
  330. {"------", 13, 16, "0001 0011 ddN0 ssN0", "push @rd,@rs", 0},
  331. {"------", 14, 16, "0101 0011 ddN0 0000 address_src", "push @rd,address_src", 0},
  332. {"------", 14, 16, "0101 0011 ddN0 ssN0 address_src", "push @rd,address_src(rs)", 0},
  333. {"------", 12, 16, "0000 1101 ddN0 1001 imm16", "push @rd,imm16", 0},
  334. {"------", 9, 16, "1001 0011 ddN0 ssss", "push @rd,rs", 0},
  335. {"------", 20, 32, "0001 0001 ddN0 ssN0", "pushl @rd,@rs", 0},
  336. {"------", 21, 32, "0101 0001 ddN0 ssN0 address_src", "pushl @rd,address_src(rs)", 0},
  337. {"------", 21, 32, "0101 0001 ddN0 0000 address_src", "pushl @rd,address_src", 0},
  338. {"------", 12, 32, "1001 0001 ddN0 ssss", "pushl @rd,rrs", 0},
  339. {"------", 11, 16, "0010 0011 ddN0 imm4", "res @rd,imm4", 0},
  340. {"------", 14, 16, "0110 0011 ddN0 imm4 address_dst", "res address_dst(rd),imm4", 0},
  341. {"------", 13, 16, "0110 0011 0000 imm4 address_dst", "res address_dst,imm4", 0},
  342. {"------", 4, 16, "1010 0011 dddd imm4", "res rd,imm4", 0},
  343. {"------", 10, 16, "0010 0011 0000 ssss 0000 dddd 0000 0000", "res rd,rs", 0},
  344. {"------", 11, 8, "0010 0010 ddN0 imm4", "resb @rd,imm4", 0},
  345. {"------", 14, 8, "0110 0010 ddN0 imm4 address_dst", "resb address_dst(rd),imm4", 0},
  346. {"------", 13, 8, "0110 0010 0000 imm4 address_dst", "resb address_dst,imm4", 0},
  347. {"------", 4, 8, "1010 0010 dddd imm4", "resb rbd,imm4", 0},
  348. {"------", 10, 8, "0010 0010 0000 ssss 0000 dddd 0000 0000", "resb rbd,rs", 0},
  349. {"CZSV--", 7, 16, "1000 1101 flags 0011", "resflg flags", 0},
  350. {"------", 10, 16, "1001 1110 0000 cccc", "ret cc", 0},
  351. {"CZSV--", 6, 16, "1011 0011 dddd 00I0", "rl rd,imm1or2", 0},
  352. {"CZSV--", 6, 8, "1011 0010 dddd 00I0", "rlb rbd,imm1or2", 0},
  353. {"CZSV--", 6, 16, "1011 0011 dddd 10I0", "rlc rd,imm1or2", 0},
  354. {"-Z----", 9, 8, "1011 0010 dddd 10I0", "rlcb rbd,imm1or2", 0},
  355. {"-Z----", 9, 8, "1011 1110 aaaa bbbb", "rldb rbb,rba", 0},
  356. {"CZSV--", 6, 16, "1011 0011 dddd 01I0", "rr rd,imm1or2", 0},
  357. {"CZSV--", 6, 8, "1011 0010 dddd 01I0", "rrb rbd,imm1or2", 0},
  358. {"CZSV--", 6, 16, "1011 0011 dddd 11I0", "rrc rd,imm1or2", 0},
  359. {"-Z----", 9, 8, "1011 0010 dddd 11I0", "rrcb rbd,imm1or2", 0},
  360. {"-Z----", 9, 8, "1011 1100 aaaa bbbb", "rrdb rbb,rba", 0},
  361. {"CZSV--", 5, 16, "1011 0111 ssss dddd", "sbc rd,rs", 0},
  362. {"CZSVDH", 5, 8, "1011 0110 ssss dddd", "sbcb rbd,rbs", 0},
  363. {"CZSVDH", 33, 8, "0111 1111 imm8", "sc imm8", 0},
  364. {"CZSV--", 15, 16, "1011 0011 dddd 1011 0000 ssss 0000 0000", "sda rd,rs", 0},
  365. {"CZSV--", 15, 8, "1011 0010 dddd 1011 0000 ssss 0000 0000", "sdab rbd,rs", 0},
  366. {"CZSV--", 15, 32, "1011 0011 dddd 1111 0000 ssss 0000 0000", "sdal rrd,rs", 0},
  367. {"CZS---", 15, 16, "1011 0011 dddd 0011 0000 ssss 0000 0000", "sdl rd,rs", 0},
  368. {"CZS---", 15, 8, "1011 0010 dddd 0011 0000 ssss 0000 0000", "sdlb rbd,rs", 0},
  369. {"CZS---", 15, 32, "1011 0011 dddd 0111 0000 ssss 0000 0000", "sdll rrd,rs", 0},
  370. {"------", 11, 16, "0010 0101 ddN0 imm4", "set @rd,imm4", 0},
  371. {"------", 14, 16, "0110 0101 ddN0 imm4 address_dst", "set address_dst(rd),imm4", 0},
  372. {"------", 13, 16, "0110 0101 0000 imm4 address_dst", "set address_dst,imm4", 0},
  373. {"------", 4, 16, "1010 0101 dddd imm4", "set rd,imm4", 0},
  374. {"------", 10, 16, "0010 0101 0000 ssss 0000 dddd 0000 0000", "set rd,rs", 0},
  375. {"------", 11, 8, "0010 0100 ddN0 imm4", "setb @rd,imm4", 0},
  376. {"------", 14, 8, "0110 0100 ddN0 imm4 address_dst", "setb address_dst(rd),imm4", 0},
  377. {"------", 13, 8, "0110 0100 0000 imm4 address_dst", "setb address_dst,imm4", 0},
  378. {"------", 4, 8, "1010 0100 dddd imm4", "setb rbd,imm4", 0},
  379. {"------", 10, 8, "0010 0100 0000 ssss 0000 dddd 0000 0000", "setb rbd,rs", 0},
  380. {"CZSV--", 7, 16, "1000 1101 flags 0001", "setflg flags", 0},
  381. {"------", 12, 16, "0011 1011 dddd 0101 imm16", "sin rd,imm16", 0},
  382. {"------", 10, 8, "0011 1010 dddd 0101 imm16", "sinb rbd,imm16", 0},
  383. {"---V--", 21, 16, "0011 1011 ssss 1001 0000 aaaa ddN0 1000", "sind @rd,@ri,ra", 0},
  384. {"---V--", 21, 8, "0011 1010 ssss 1001 0000 aaaa ddN0 1000", "sindb @rd,@ri,ra", 0},
  385. {"---V--", 11, 16, "0011 1011 ssss 1001 0000 aaaa ddN0 0000", "sindr @rd,@ri,ra", 0},
  386. {"---V--", 11, 8, "0011 1010 ssss 1001 0000 aaaa ddN0 0000", "sindrb @rd,@ri,ra", 0},
  387. {"---V--", 21, 16, "0011 1011 ssss 0001 0000 aaaa ddN0 1000", "sini @rd,@ri,ra", 0},
  388. {"---V--", 21, 8, "0011 1010 ssss 0001 0000 aaaa ddN0 1000", "sinib @rd,@ri,ra", 0},
  389. {"---V--", 11, 16, "0011 1011 ssss 0001 0000 aaaa ddN0 0000", "sinir @rd,@ri,ra", 0},
  390. {"---V--", 11, 8, "0011 1010 ssss 0001 0000 aaaa ddN0 0000", "sinirb @rd,@ri,ra", 0},
  391. {"CZSV--", 13, 16, "1011 0011 dddd 1001 0000 0000 imm8", "sla rd,imm8", 0},
  392. {"CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 0000 imm4", "slab rbd,imm4", 0},
  393. {"CZSV--", 13, 32, "1011 0011 dddd 1101 0000 0000 imm8", "slal rrd,imm8", 0},
  394. {"CZS---", 13, 16, "1011 0011 dddd 0001 0000 0000 imm8", "sll rd,imm8", 0},
  395. {"CZS---", 13, 8, "1011 0010 dddd 0001 iiii iiii 0000 imm4", "sllb rbd,imm4", 0},
  396. {"CZS---", 13, 32, "1011 0011 dddd 0101 0000 0000 imm8", "slll rrd,imm8", 0},
  397. {"------", 12, 16, "0011 1011 ssss 0110 imm16", "sout imm16,rs", 0},
  398. {"------", 12, 8, "0011 1010 ssss 0110 imm16", "soutb imm16,rbs", 0},
  399. {"---V--", 21, 16, "0011 1011 ssN0 1011 0000 aaaa dddd 1000", "soutd @ro,@rs,ra", 0},
  400. {"---V--", 21, 8, "0011 1010 ssN0 1011 0000 aaaa dddd 1000", "soutdb @ro,@rs,ra", 0},
  401. {"---V--", 11, 16, "0011 1011 ssN0 1011 0000 aaaa dddd 0000", "sotdr @ro,@rs,ra", 0},
  402. {"---V--", 11, 8, "0011 1010 ssN0 1011 0000 aaaa dddd 0000", "sotdrb @ro,@rs,ra", 0},
  403. {"---V--", 21, 16, "0011 1011 ssN0 0011 0000 aaaa dddd 1000", "souti @ro,@rs,ra", 0},
  404. {"---V--", 21, 8, "0011 1010 ssN0 0011 0000 aaaa dddd 1000", "soutib @ro,@rs,ra", 0},
  405. {"---V--", 11, 16, "0011 1011 ssN0 0011 0000 aaaa dddd 0000", "sotir @ro,@rs,ra", 0},
  406. {"---V--", 11, 8, "0011 1010 ssN0 0011 0000 aaaa dddd 0000", "sotirb @ro,@rs,ra", 0},
  407. {"CZSV--", 13, 16, "1011 0011 dddd 1001 1111 1111 nim8", "sra rd,imm8", 0},
  408. {"CZSV--", 13, 8, "1011 0010 dddd 1001 iiii iiii 1111 nim4", "srab rbd,imm4", 0},
  409. {"CZSV--", 13, 32, "1011 0011 dddd 1101 1111 1111 nim8", "sral rrd,imm8", 0},
  410. {"CZSV--", 13, 16, "1011 0011 dddd 0001 1111 1111 nim8", "srl rd,imm8", 0},
  411. {"CZSV--", 13, 8, "1011 0010 dddd 0001 iiii iiii 1111 nim4", "srlb rbd,imm4", 0},
  412. {"CZSV--", 13, 32, "1011 0011 dddd 0101 1111 1111 nim8", "srll rrd,imm8", 0},
  413. {"CZSV--", 7, 16, "0000 0011 ssN0 dddd", "sub rd,@rs", 0},
  414. {"CZSV--", 9, 16, "0100 0011 0000 dddd address_src", "sub rd,address_src", 0},
  415. {"CZSV--", 10, 16, "0100 0011 ssN0 dddd address_src", "sub rd,address_src(rs)", 0},
  416. {"CZSV--", 7, 16, "0000 0011 0000 dddd imm16", "sub rd,imm16", 0},
  417. {"CZSV--", 4, 16, "1000 0011 ssss dddd", "sub rd,rs", 0},
  418. {"CZSVDH", 7, 8, "0000 0010 ssN0 dddd", "subb rbd,@rs", 0},
  419. {"CZSVDH", 9, 8, "0100 0010 0000 dddd address_src", "subb rbd,address_src", 0},
  420. {"CZSVDH", 10, 8, "0100 0010 ssN0 dddd address_src", "subb rbd,address_src(rs)", 0},
  421. {"CZSVDH", 7, 8, "0000 0010 0000 dddd imm8 imm8", "subb rbd,imm8", 0},
  422. {"CZSVDH", 4, 8, "1000 0010 ssss dddd", "subb rbd,rbs", 0},
  423. {"CZSV--", 14, 32, "0001 0010 ssN0 dddd", "subl rrd,@rs", 0},
  424. {"CZSV--", 15, 32, "0101 0010 0000 dddd address_src", "subl rrd,address_src", 0},
  425. {"CZSV--", 16, 32, "0101 0010 ssN0 dddd address_src", "subl rrd,address_src(rs)", 0},
  426. {"CZSV--", 14, 32, "0001 0010 0000 dddd imm32", "subl rrd,imm32", 0},
  427. {"CZSV--", 8, 32, "1001 0010 ssss dddd", "subl rrd,rrs", 0},
  428. {"------", 5, 16, "1010 1111 dddd cccc", "tcc cc,rd", 0},
  429. {"------", 5, 8, "1010 1110 dddd cccc", "tccb cc,rbd", 0},
  430. {"-ZS---", 8, 16, "0000 1101 ddN0 0100", "test @rd", 0},
  431. {"------", 11, 16, "0100 1101 0000 0100 address_dst", "test address_dst", 0},
  432. {"------", 12, 16, "0100 1101 ddN0 0100 address_dst", "test address_dst(rd)", 0},
  433. {"------", 7, 16, "1000 1101 dddd 0100", "test rd", 0},
  434. {"-ZSP--", 8, 8, "0000 1100 ddN0 0100", "testb @rd", 0},
  435. {"-ZSP--", 11, 8, "0100 1100 0000 0100 address_dst", "testb address_dst", 0},
  436. {"-ZSP--", 12, 8, "0100 1100 ddN0 0100 address_dst", "testb address_dst(rd)", 0},
  437. {"-ZSP--", 7, 8, "1000 1100 dddd 0100", "testb rbd", 0},
  438. {"-ZS---", 13, 32, "0001 1100 ddN0 1000", "testl @rd", 0},
  439. {"-ZS---", 16, 32, "0101 1100 0000 1000 address_dst", "testl address_dst", 0},
  440. {"-ZS---", 17, 32, "0101 1100 ddN0 1000 address_dst", "testl address_dst(rd)", 0},
  441. {"-ZS---", 13, 32, "1001 1100 dddd 1000", "testl rrd", 0},
  442. {"---V--", 25, 8, "1011 1000 ddN0 1000 0000 rrrr ssN0 0000", "trdb @rd,@rs,rr", 0},
  443. {"---V--", 25, 8, "1011 1000 ddN0 1100 0000 rrrr ssN0 0000", "trdrb @rd,@rs,rr", 0},
  444. {"---V--", 25, 8, "1011 1000 ddN0 0000 0000 rrrr ssN0 0000", "trib @rd,@rs,rr", 0},
  445. {"---V--", 25, 8, "1011 1000 ddN0 0100 0000 rrrr ssN0 0000", "trirb @rd,@rs,rr", 0},
  446. {"-Z-V--", 25, 8, "1011 1000 aaN0 1010 0000 rrrr bbN0 0000", "trtdb @ra,@rb,rr", 0},
  447. {"-Z-V--", 25, 8, "1011 1000 aaN0 1110 0000 rrrr bbN0 1110", "trtdrb @ra,@rb,rr", 0},
  448. {"-Z-V--", 25, 8, "1011 1000 aaN0 0010 0000 rrrr bbN0 0000", "trtib @ra,@rb,rr", 0},
  449. {"-Z-V--", 25, 8, "1011 1000 aaN0 0110 0000 rrrr bbN0 1110", "trtirb @ra,@rb,rr", 0},
  450. {"--S---", 11, 16, "0000 1101 ddN0 0110", "tset @rd", 0},
  451. {"--S---", 14, 16, "0100 1101 0000 0110 address_dst", "tset address_dst", 0},
  452. {"--S---", 15, 16, "0100 1101 ddN0 0110 address_dst", "tset address_dst(rd)", 0},
  453. {"--S---", 7, 16, "1000 1101 dddd 0110", "tset rd", 0},
  454. {"--S---", 11, 8, "0000 1100 ddN0 0110", "tsetb @rd", 0},
  455. {"--S---", 14, 8, "0100 1100 0000 0110 address_dst", "tsetb address_dst", 0},
  456. {"--S---", 15, 8, "0100 1100 ddN0 0110 address_dst", "tsetb address_dst(rd)", 0},
  457. {"--S---", 7, 8, "1000 1100 dddd 0110", "tsetb rbd", 0},
  458. {"-ZS---", 7, 16, "0000 1001 ssN0 dddd", "xor rd,@rs", 0},
  459. {"-ZS---", 9, 16, "0100 1001 0000 dddd address_src", "xor rd,address_src", 0},
  460. {"-ZS---", 10, 16, "0100 1001 ssN0 dddd address_src", "xor rd,address_src(rs)", 0},
  461. {"-ZS---", 7, 16, "0000 1001 0000 dddd imm16", "xor rd,imm16", 0},
  462. {"-ZS---", 4, 16, "1000 1001 ssss dddd", "xor rd,rs", 0},
  463. {"-ZSP--", 7, 8, "0000 1000 ssN0 dddd", "xorb rbd,@rs", 0},
  464. {"-ZSP--", 9, 8, "0100 1000 0000 dddd address_src", "xorb rbd,address_src", 0},
  465. {"-ZSP--", 10, 8, "0100 1000 ssN0 dddd address_src", "xorb rbd,address_src(rs)", 0},
  466. {"-ZSP--", 7, 8, "0000 1000 0000 dddd imm8 imm8", "xorb rbd,imm8", 0},
  467. {"-ZSP--", 4, 8, "1000 1000 ssss dddd", "xorb rbd,rbs", 0},
  468. {"------", 7, 32, "1000 1100 dddd 0001", "ldctlb rbd,ctrl", 0},
  469. {"CZSVDH", 7, 32, "1000 1100 ssss 1001", "ldctlb ctrl,rbs", 0},
  470. {"*", 0, 0, 0, 0, 0}
  471. };
  472. static int
  473. count (void)
  474. {
  475. struct op *p = opt;
  476. int r = 0;
  477. while (p->name)
  478. {
  479. r++;
  480. p++;
  481. }
  482. return r;
  483. }
  484. static int
  485. func (const void *p1, const void *p2)
  486. {
  487. const struct op *a = p1;
  488. const struct op *b = p2;
  489. int ret = strcmp (a->name, b->name);
  490. if (ret != 0)
  491. return ret;
  492. return a->id > b->id ? 1 : -1;
  493. }
  494. /* opcode
  495. literal 0000 nnnn insert nnn into stream
  496. operand 0001 nnnn insert operand reg nnn into stream
  497. */
  498. struct tok_struct
  499. {
  500. char *match;
  501. char *token;
  502. int length;
  503. };
  504. static struct tok_struct args[] =
  505. {
  506. {"address_src(rs)", "CLASS_X+(ARG_RS)",},
  507. {"address_dst(rd)", "CLASS_X+(ARG_RD)",},
  508. {"rs(imm16)", "CLASS_BA+(ARG_RS)",},
  509. {"rd(imm16)", "CLASS_BA+(ARG_RD)",},
  510. {"prd", "CLASS_PR+(ARG_RD)",},
  511. {"address_src", "CLASS_DA+(ARG_SRC)",},
  512. {"address_dst", "CLASS_DA+(ARG_DST)",},
  513. {"rd(rx)", "CLASS_BX+(ARG_RD)",},
  514. {"rs(rx)", "CLASS_BX+(ARG_RS)",},
  515. {"disp16", "CLASS_DISP",},
  516. {"disp12", "CLASS_DISP",},
  517. {"disp7", "CLASS_DISP",},
  518. {"disp8", "CLASS_DISP",},
  519. {"flags", "CLASS_FLAGS",},
  520. {"imm16", "CLASS_IMM+(ARG_IMM16)",},
  521. {"imm1or2", "CLASS_IMM+(ARG_IMM1OR2)",},
  522. {"imm32", "CLASS_IMM+(ARG_IMM32)",},
  523. {"imm4m1", "CLASS_IMM +(ARG_IMM4M1)",},
  524. {"imm4", "CLASS_IMM +(ARG_IMM4)",},
  525. {"n", "CLASS_IMM + (ARG_IMM4M1)",},
  526. {"ctrl", "CLASS_CTRL",},
  527. {"rba", "CLASS_REG_BYTE+(ARG_RA)",},
  528. {"rbb", "CLASS_REG_BYTE+(ARG_RB)",},
  529. {"rbd", "CLASS_REG_BYTE+(ARG_RD)",},
  530. {"rbs", "CLASS_REG_BYTE+(ARG_RS)",},
  531. {"rbr", "CLASS_REG_BYTE+(ARG_RR)",},
  532. {"rrd", "CLASS_REG_LONG+(ARG_RD)",},
  533. {"rrs", "CLASS_REG_LONG+(ARG_RS)",},
  534. {"rqd", "CLASS_REG_QUAD+(ARG_RD)",},
  535. {"rd", "CLASS_REG_WORD+(ARG_RD)",},
  536. {"rs", "CLASS_REG_WORD+(ARG_RS)",},
  537. {"@rd", "CLASS_IR+(ARG_RD)",},
  538. {"@ra", "CLASS_IR+(ARG_RA)",},
  539. {"@rb", "CLASS_IR+(ARG_RB)",},
  540. {"@rs", "CLASS_IR+(ARG_RS)",},
  541. {"@ri", "CLASS_IRO+(ARG_RS)",},
  542. {"@ro", "CLASS_IRO+(ARG_RD)",},
  543. {"imm8", "CLASS_IMM+(ARG_IMM8)",},
  544. {"i2", "CLASS_IMM+(ARG_IMM2)",},
  545. {"cc", "CLASS_CC",},
  546. {"rr", "CLASS_REG_WORD+(ARG_RR)",},
  547. {"ra", "CLASS_REG_WORD+(ARG_RA)",},
  548. {"rs", "CLASS_REG_WORD+(ARG_RS)",},
  549. {"1", "CLASS_IMM+(ARG_IMM_1)",},
  550. {"2", "CLASS_IMM+(ARG_IMM_2)",},
  551. {0, 0}
  552. };
  553. static struct tok_struct toks[] =
  554. {
  555. {"0000", "CLASS_BIT+0", 1},
  556. {"0001", "CLASS_BIT+1", 1},
  557. {"0010", "CLASS_BIT+2", 1},
  558. {"0011", "CLASS_BIT+3", 1},
  559. {"0100", "CLASS_BIT+4", 1},
  560. {"0101", "CLASS_BIT+5", 1},
  561. {"0110", "CLASS_BIT+6", 1},
  562. {"0111", "CLASS_BIT+7", 1},
  563. {"1000", "CLASS_BIT+8", 1},
  564. {"1001", "CLASS_BIT+9", 1},
  565. {"1010", "CLASS_BIT+0xa", 1},
  566. {"1011", "CLASS_BIT+0xb", 1},
  567. {"1100", "CLASS_BIT+0xc", 1},
  568. {"1101", "CLASS_BIT+0xd", 1},
  569. {"1110", "CLASS_BIT+0xe", 1},
  570. {"1111", "CLASS_BIT+0xf", 1},
  571. {"00I0", "CLASS_BIT_1OR2+0", 1},
  572. {"00I0", "CLASS_BIT_1OR2+1", 1},
  573. {"00I0", "CLASS_BIT_1OR2+2", 1},
  574. {"00I0", "CLASS_BIT_1OR2+3", 1},
  575. {"01I0", "CLASS_BIT_1OR2+4", 1},
  576. {"01I0", "CLASS_BIT_1OR2+5", 1},
  577. {"01I0", "CLASS_BIT_1OR2+6", 1},
  578. {"01I0", "CLASS_BIT_1OR2+7", 1},
  579. {"10I0", "CLASS_BIT_1OR2+8", 1},
  580. {"10I0", "CLASS_BIT_1OR2+9", 1},
  581. {"10I0", "CLASS_BIT_1OR2+0xa", 1},
  582. {"10I0", "CLASS_BIT_1OR2+0xb", 1},
  583. {"11I0", "CLASS_BIT_1OR2+0xc", 1},
  584. {"11I0", "CLASS_BIT_1OR2+0xd", 1},
  585. {"11I0", "CLASS_BIT_1OR2+0xe", 1},
  586. {"11I0", "CLASS_BIT_1OR2+0xf", 1},
  587. {"ssss", "CLASS_REG+(ARG_RS)", 1},
  588. {"dddd", "CLASS_REG+(ARG_RD)", 1},
  589. {"aaaa", "CLASS_REG+(ARG_RA)", 1},
  590. {"bbbb", "CLASS_REG+(ARG_RB)", 1},
  591. {"rrrr", "CLASS_REG+(ARG_RR)", 1},
  592. {"ssN0", "CLASS_REGN0+(ARG_RS)", 1},
  593. {"ddN0", "CLASS_REGN0+(ARG_RD)", 1},
  594. {"aaN0", "CLASS_REGN0+(ARG_RA)", 1},
  595. {"bbN0", "CLASS_REGN0+(ARG_RB)", 1},
  596. {"rrN0", "CLASS_REGN0+(ARG_RR)", 1},
  597. {"cccc", "CLASS_CC", 1},
  598. {"nnnn", "CLASS_IMM+(ARG_IMMN)", 1},
  599. {"xxxx", "CLASS_REG+(ARG_RX)", 1},
  600. {"xxN0", "CLASS_REGN0+(ARG_RX)", 1},
  601. {"nminus1", "CLASS_IMM+(ARG_IMMNMINUS1)", 1},
  602. {"disp16", "CLASS_DISP+(ARG_DISP16)", 4},
  603. {"disp12", "CLASS_DISP+(ARG_DISP12)", 3},
  604. {"flags", "CLASS_FLAGS", 1},
  605. {"address_dst", "CLASS_ADDRESS+(ARG_DST)", 4},
  606. {"address_src", "CLASS_ADDRESS+(ARG_SRC)", 4},
  607. {"imm4m1", "CLASS_IMM+(ARG_IMM4M1)", 1},
  608. {"imm4", "CLASS_IMM+(ARG_IMM4)", 1},
  609. {"imm8", "CLASS_IMM+(ARG_IMM8)", 2},
  610. {"imm16", "CLASS_IMM+(ARG_IMM16)", 4},
  611. {"imm32", "CLASS_IMM+(ARG_IMM32)", 8},
  612. {"nim4", "CLASS_IMM+(ARG_NIM4)", 2},
  613. {"nim8", "CLASS_IMM+(ARG_NIM8)", 2},
  614. {"0ccc", "CLASS_0CCC", 1},
  615. {"1ccc", "CLASS_1CCC", 1},
  616. {"disp8", "CLASS_DISP8", 2},
  617. {"0disp7", "CLASS_0DISP7", 2},
  618. {"1disp7", "CLASS_1DISP7", 2},
  619. {"01ii", "CLASS_01II", 1},
  620. {"00ii", "CLASS_00II", 1},
  621. {"iiii", "CLASS_IGNORE", 1},
  622. {0, 0}
  623. };
  624. static char *
  625. translate (struct tok_struct *table, char *x, int *length)
  626. {
  627. int found;
  628. found = 0;
  629. while (table->match)
  630. {
  631. int l = strlen (table->match);
  632. if (strncmp (table->match, x, l) == 0)
  633. {
  634. /* Got a hit */
  635. printf ("%s", table->token);
  636. *length += table->length;
  637. return x + l;
  638. }
  639. table++;
  640. }
  641. fprintf (stderr, "Can't find %s\n", x);
  642. printf ("**** Can't find %s\n", x);
  643. while (*x)
  644. x++;
  645. return x;
  646. }
  647. static void
  648. chewbits (char *bits, int *length)
  649. {
  650. int n = 0;
  651. *length = 0;
  652. printf ("{");
  653. while (*bits)
  654. {
  655. while (*bits == ' ')
  656. {
  657. bits++;
  658. }
  659. bits = translate (toks, bits, length);
  660. n++;
  661. printf (",");
  662. }
  663. while (n < BYTE_INFO_LEN - 1)
  664. {
  665. printf ("0,");
  666. n++;
  667. }
  668. printf ("}");
  669. }
  670. static int
  671. chewname (char **name)
  672. {
  673. char *n;
  674. int nargs = 0;
  675. n = *name;
  676. while (*n && !iswhite (*n))
  677. n++;
  678. if (*n)
  679. {
  680. size_t len = n - *name;
  681. char *newname = xmalloc (len + 1);
  682. memcpy (newname, *name, len);
  683. newname[len] = 0;
  684. *name = newname;
  685. }
  686. printf ("\"%s\",OPC_%s,0,{", *name, *name);
  687. /* Scan the operands and make entries for them.
  688. Remember indirect things. */
  689. while (*n)
  690. {
  691. int d;
  692. while (*n == ',' || iswhite (*n))
  693. n++;
  694. nargs++;
  695. n = translate (args, n, &d);
  696. printf (",");
  697. }
  698. if (nargs == 0)
  699. {
  700. printf ("0");
  701. }
  702. printf ("},");
  703. return nargs;
  704. }
  705. static char *
  706. sub (char *x, char c)
  707. {
  708. /* Create copy. */
  709. char *ret = xstrdup (x);
  710. x = ret;
  711. while (*x)
  712. {
  713. if (x[0] == c && x[1] == c &&
  714. x[2] == c && x[3] == c)
  715. {
  716. x[2] = 'N';
  717. x[3] = '0';
  718. }
  719. x++;
  720. }
  721. return ret;
  722. }
  723. #if 0
  724. #define D(x) ((x) == '1' || (x) =='0')
  725. #define M(y) (strncmp(y,x,4)==0)
  726. static void
  727. printmangled (char *x)
  728. {
  729. return;
  730. while (*x)
  731. {
  732. if (D (x[0]) && D (x[1]) && D (x[2]) && D (x[3]))
  733. {
  734. printf ("XXXX");
  735. }
  736. else if (M ("ssss"))
  737. {
  738. printf ("ssss");
  739. }
  740. else if (M ("dddd"))
  741. {
  742. printf ("dddd");
  743. }
  744. else
  745. printf ("____");
  746. x += 4;
  747. if (x[0] == ' ')
  748. {
  749. printf ("_");
  750. x++;
  751. }
  752. }
  753. }
  754. #endif
  755. /*#define WORK_TYPE*/
  756. static void
  757. print_type (struct op *n)
  758. {
  759. #ifdef WORK_TYPE
  760. while (*s && !iswhite (*s))
  761. {
  762. l = *s;
  763. s++;
  764. }
  765. switch (l)
  766. {
  767. case 'l':
  768. printf ("32,");
  769. break;
  770. case 'b':
  771. printf ("8,");
  772. break;
  773. default:
  774. printf ("16,");
  775. break;
  776. }
  777. #else
  778. printf ("%2d,", n->type);
  779. #endif
  780. }
  781. static void
  782. internal (void)
  783. {
  784. int c = count ();
  785. int id;
  786. struct op *new_op = xmalloc (sizeof (struct op) * (c + 1));
  787. struct op *p = opt;
  788. memcpy (new_op, p, (c + 1) * sizeof (struct op));
  789. /* Assign unique id. */
  790. for (id = 0; id < c; id++)
  791. new_op[id].id = id;
  792. /* Sort all names in table alphabetically. */
  793. qsort (new_op, c, sizeof (struct op), func);
  794. p = new_op;
  795. while (p->flags && p->flags[0] != '*')
  796. {
  797. /* If there are any @rs, sub the ssss into a ssn0, (rs), (ssn0). */
  798. int loop = 1;
  799. printf ("\"%s\",%2d, ", p->flags, p->cycles);
  800. while (loop)
  801. {
  802. char *s = p->name;
  803. loop = 0;
  804. while (*s)
  805. {
  806. if (s[0] == '@')
  807. {
  808. char c;
  809. /* Skip the r and sub the string. */
  810. s++;
  811. c = s[1];
  812. p->bits = sub (p->bits, c);
  813. }
  814. if (s[0] == '(' && s[3] == ')')
  815. {
  816. p->bits = sub (p->bits, s[2]);
  817. }
  818. if (s[0] == '(')
  819. {
  820. p->bits = sub (p->bits, s[-1]);
  821. }
  822. s++;
  823. }
  824. }
  825. print_type (p);
  826. printf ("\"%s\",\"%s\",0,\n", p->bits, p->name);
  827. p++;
  828. }
  829. }
  830. static void
  831. gas (void)
  832. {
  833. int c = count ();
  834. int id;
  835. struct op *p = opt;
  836. int idx = -1;
  837. char *oldname = "";
  838. struct op *new_op = xmalloc (sizeof (struct op) * (c + 1));
  839. memcpy (new_op, p, (c + 1) * sizeof (struct op));
  840. /* Assign unique id. */
  841. for (id = 0; id < c; id++)
  842. new_op[id].id = id;
  843. /* Sort all names in table alphabetically. */
  844. qsort (new_op, c, sizeof (struct op), func);
  845. printf ("/* DO NOT EDIT! -*- buffer-read-only: t -*-\n");
  846. printf (" This file is automatically generated by z8kgen. */\n\n");
  847. printf ("/* Copyright (C) 2007-2015 Free Software Foundation, Inc.\n\
  848. \n\
  849. This file is part of the GNU opcodes library.\n\
  850. \n\
  851. This library is free software; you can redistribute it and/or modify\n\
  852. it under the terms of the GNU General Public License as published by\n\
  853. the Free Software Foundation; either version 3, or (at your option)\n\
  854. any later version.\n\
  855. \n\
  856. It is distributed in the hope that it will be useful, but WITHOUT\n\
  857. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n\
  858. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\n\
  859. License for more details.\n\
  860. \n\
  861. You should have received a copy of the GNU General Public License\n\
  862. along with this file; see the file COPYING. If not, write to the\n\
  863. Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,\n\
  864. MA 02110-1301, USA. */\n\n");
  865. printf ("#define ARG_MASK 0x0f\n");
  866. printf ("#define ARG_SRC 0x01\n");
  867. printf ("#define ARG_DST 0x02\n");
  868. printf ("#define ARG_RS 0x01\n");
  869. printf ("#define ARG_RD 0x02\n");
  870. printf ("#define ARG_RA 0x03\n");
  871. printf ("#define ARG_RB 0x04\n");
  872. printf ("#define ARG_RR 0x05\n");
  873. printf ("#define ARG_RX 0x06\n");
  874. printf ("#define ARG_IMM4 0x01\n");
  875. printf ("#define ARG_IMM8 0x02\n");
  876. printf ("#define ARG_IMM16 0x03\n");
  877. printf ("#define ARG_IMM32 0x04\n");
  878. printf ("#define ARG_IMMN 0x05\n");
  879. printf ("#define ARG_IMMNMINUS1 0x05\n");
  880. printf ("#define ARG_IMM_1 0x06\n");
  881. printf ("#define ARG_IMM_2 0x07\n");
  882. printf ("#define ARG_DISP16 0x08\n");
  883. printf ("#define ARG_NIM8 0x09\n");
  884. printf ("#define ARG_IMM2 0x0a\n");
  885. printf ("#define ARG_IMM1OR2 0x0b\n");
  886. printf ("#define ARG_DISP12 0x0b\n");
  887. printf ("#define ARG_NIM4 0x0c\n");
  888. printf ("#define ARG_DISP8 0x0c\n");
  889. printf ("#define ARG_IMM4M1 0x0d\n");
  890. printf ("#define CLASS_X 0x10\n");
  891. printf ("#define CLASS_BA 0x20\n");
  892. printf ("#define CLASS_DA 0x30\n");
  893. printf ("#define CLASS_BX 0x40\n");
  894. printf ("#define CLASS_DISP 0x50\n");
  895. printf ("#define CLASS_IMM 0x60\n");
  896. printf ("#define CLASS_CC 0x70\n");
  897. printf ("#define CLASS_CTRL 0x80\n");
  898. printf ("#define CLASS_IGNORE 0x90\n");
  899. printf ("#define CLASS_ADDRESS 0xd0\n");
  900. printf ("#define CLASS_0CCC 0xe0\n");
  901. printf ("#define CLASS_1CCC 0xf0\n");
  902. printf ("#define CLASS_0DISP7 0x100\n");
  903. printf ("#define CLASS_1DISP7 0x200\n");
  904. printf ("#define CLASS_01II 0x300\n");
  905. printf ("#define CLASS_00II 0x400\n");
  906. printf ("#define CLASS_BIT 0x500\n");
  907. printf ("#define CLASS_FLAGS 0x600\n");
  908. printf ("#define CLASS_IR 0x700\n");
  909. printf ("#define CLASS_IRO 0x800\n");
  910. printf ("#define CLASS_DISP8 0x900\n");
  911. printf ("#define CLASS_BIT_1OR2 0xa00\n");
  912. printf ("#define CLASS_REG 0x7000\n");
  913. printf ("#define CLASS_REG_BYTE 0x2000\n");
  914. printf ("#define CLASS_REG_WORD 0x3000\n");
  915. printf ("#define CLASS_REG_QUAD 0x4000\n");
  916. printf ("#define CLASS_REG_LONG 0x5000\n");
  917. printf ("#define CLASS_REGN0 0x8000\n");
  918. printf ("#define CLASS_PR 0x10000\n");
  919. printf ("#define CLASS_MASK 0x1fff0\n");
  920. printf ("#define OPC_adc 0\n");
  921. printf ("#define OPC_adcb 1\n");
  922. printf ("#define OPC_add 2\n");
  923. printf ("#define OPC_addb 3\n");
  924. printf ("#define OPC_addl 4\n");
  925. printf ("#define OPC_and 5\n");
  926. printf ("#define OPC_andb 6\n");
  927. printf ("#define OPC_bit 7\n");
  928. printf ("#define OPC_bitb 8\n");
  929. printf ("#define OPC_call 9\n");
  930. printf ("#define OPC_calr 10\n");
  931. printf ("#define OPC_clr 11\n");
  932. printf ("#define OPC_clrb 12\n");
  933. printf ("#define OPC_com 13\n");
  934. printf ("#define OPC_comb 14\n");
  935. printf ("#define OPC_comflg 15\n");
  936. printf ("#define OPC_cp 16\n");
  937. printf ("#define OPC_cpb 17\n");
  938. printf ("#define OPC_cpd 18\n");
  939. printf ("#define OPC_cpdb 19\n");
  940. printf ("#define OPC_cpdr 20\n");
  941. printf ("#define OPC_cpdrb 21\n");
  942. printf ("#define OPC_cpi 22\n");
  943. printf ("#define OPC_cpib 23\n");
  944. printf ("#define OPC_cpir 24\n");
  945. printf ("#define OPC_cpirb 25\n");
  946. printf ("#define OPC_cpl 26\n");
  947. printf ("#define OPC_cpsd 27\n");
  948. printf ("#define OPC_cpsdb 28\n");
  949. printf ("#define OPC_cpsdr 29\n");
  950. printf ("#define OPC_cpsdrb 30\n");
  951. printf ("#define OPC_cpsi 31\n");
  952. printf ("#define OPC_cpsib 32\n");
  953. printf ("#define OPC_cpsir 33\n");
  954. printf ("#define OPC_cpsirb 34\n");
  955. printf ("#define OPC_dab 35\n");
  956. printf ("#define OPC_dbjnz 36\n");
  957. printf ("#define OPC_dec 37\n");
  958. printf ("#define OPC_decb 38\n");
  959. printf ("#define OPC_di 39\n");
  960. printf ("#define OPC_div 40\n");
  961. printf ("#define OPC_divl 41\n");
  962. printf ("#define OPC_djnz 42\n");
  963. printf ("#define OPC_ei 43\n");
  964. printf ("#define OPC_ex 44\n");
  965. printf ("#define OPC_exb 45\n");
  966. printf ("#define OPC_exts 46\n");
  967. printf ("#define OPC_extsb 47\n");
  968. printf ("#define OPC_extsl 48\n");
  969. printf ("#define OPC_halt 49\n");
  970. printf ("#define OPC_in 50\n");
  971. printf ("#define OPC_inb 51\n");
  972. printf ("#define OPC_inc 52\n");
  973. printf ("#define OPC_incb 53\n");
  974. printf ("#define OPC_ind 54\n");
  975. printf ("#define OPC_indb 55\n");
  976. printf ("#define OPC_indr 56\n");
  977. printf ("#define OPC_indrb 57\n");
  978. printf ("#define OPC_ini 58\n");
  979. printf ("#define OPC_inib 59\n");
  980. printf ("#define OPC_inir 60\n");
  981. printf ("#define OPC_inirb 61\n");
  982. printf ("#define OPC_iret 62\n");
  983. printf ("#define OPC_jp 63\n");
  984. printf ("#define OPC_jr 64\n");
  985. printf ("#define OPC_ld 65\n");
  986. printf ("#define OPC_lda 66\n");
  987. printf ("#define OPC_ldar 67\n");
  988. printf ("#define OPC_ldb 68\n");
  989. printf ("#define OPC_ldctl 69\n");
  990. printf ("#define OPC_ldir 70\n");
  991. printf ("#define OPC_ldirb 71\n");
  992. printf ("#define OPC_ldk 72\n");
  993. printf ("#define OPC_ldl 73\n");
  994. printf ("#define OPC_ldm 74\n");
  995. printf ("#define OPC_ldps 75\n");
  996. printf ("#define OPC_ldr 76\n");
  997. printf ("#define OPC_ldrb 77\n");
  998. printf ("#define OPC_ldrl 78\n");
  999. printf ("#define OPC_mbit 79\n");
  1000. printf ("#define OPC_mreq 80\n");
  1001. printf ("#define OPC_mres 81\n");
  1002. printf ("#define OPC_mset 82\n");
  1003. printf ("#define OPC_mult 83\n");
  1004. printf ("#define OPC_multl 84\n");
  1005. printf ("#define OPC_neg 85\n");
  1006. printf ("#define OPC_negb 86\n");
  1007. printf ("#define OPC_nop 87\n");
  1008. printf ("#define OPC_or 88\n");
  1009. printf ("#define OPC_orb 89\n");
  1010. printf ("#define OPC_otdr 90\n");
  1011. printf ("#define OPC_otdrb 91\n");
  1012. printf ("#define OPC_otir 92\n");
  1013. printf ("#define OPC_otirb 93\n");
  1014. printf ("#define OPC_out 94\n");
  1015. printf ("#define OPC_outb 95\n");
  1016. printf ("#define OPC_outd 96\n");
  1017. printf ("#define OPC_outdb 97\n");
  1018. printf ("#define OPC_outi 98\n");
  1019. printf ("#define OPC_outib 99\n");
  1020. printf ("#define OPC_pop 100\n");
  1021. printf ("#define OPC_popl 101\n");
  1022. printf ("#define OPC_push 102\n");
  1023. printf ("#define OPC_pushl 103\n");
  1024. printf ("#define OPC_res 104\n");
  1025. printf ("#define OPC_resb 105\n");
  1026. printf ("#define OPC_resflg 106\n");
  1027. printf ("#define OPC_ret 107\n");
  1028. printf ("#define OPC_rl 108\n");
  1029. printf ("#define OPC_rlb 109\n");
  1030. printf ("#define OPC_rlc 110\n");
  1031. printf ("#define OPC_rlcb 111\n");
  1032. printf ("#define OPC_rldb 112\n");
  1033. printf ("#define OPC_rr 113\n");
  1034. printf ("#define OPC_rrb 114\n");
  1035. printf ("#define OPC_rrc 115\n");
  1036. printf ("#define OPC_rrcb 116\n");
  1037. printf ("#define OPC_rrdb 117\n");
  1038. printf ("#define OPC_sbc 118\n");
  1039. printf ("#define OPC_sbcb 119\n");
  1040. printf ("#define OPC_sda 120\n");
  1041. printf ("#define OPC_sdab 121\n");
  1042. printf ("#define OPC_sdal 122\n");
  1043. printf ("#define OPC_sdl 123\n");
  1044. printf ("#define OPC_sdlb 124\n");
  1045. printf ("#define OPC_sdll 125\n");
  1046. printf ("#define OPC_set 126\n");
  1047. printf ("#define OPC_setb 127\n");
  1048. printf ("#define OPC_setflg 128\n");
  1049. printf ("#define OPC_sin 129\n");
  1050. printf ("#define OPC_sinb 130\n");
  1051. printf ("#define OPC_sind 131\n");
  1052. printf ("#define OPC_sindb 132\n");
  1053. printf ("#define OPC_sindr 133\n");
  1054. printf ("#define OPC_sindrb 134\n");
  1055. printf ("#define OPC_sini 135\n");
  1056. printf ("#define OPC_sinib 136\n");
  1057. printf ("#define OPC_sinir 137\n");
  1058. printf ("#define OPC_sinirb 138\n");
  1059. printf ("#define OPC_sla 139\n");
  1060. printf ("#define OPC_slab 140\n");
  1061. printf ("#define OPC_slal 141\n");
  1062. printf ("#define OPC_sll 142\n");
  1063. printf ("#define OPC_sllb 143\n");
  1064. printf ("#define OPC_slll 144\n");
  1065. printf ("#define OPC_sotdr 145\n");
  1066. printf ("#define OPC_sotdrb 146\n");
  1067. printf ("#define OPC_sotir 147\n");
  1068. printf ("#define OPC_sotirb 148\n");
  1069. printf ("#define OPC_sout 149\n");
  1070. printf ("#define OPC_soutb 150\n");
  1071. printf ("#define OPC_soutd 151\n");
  1072. printf ("#define OPC_soutdb 152\n");
  1073. printf ("#define OPC_souti 153\n");
  1074. printf ("#define OPC_soutib 154\n");
  1075. printf ("#define OPC_sra 155\n");
  1076. printf ("#define OPC_srab 156\n");
  1077. printf ("#define OPC_sral 157\n");
  1078. printf ("#define OPC_srl 158\n");
  1079. printf ("#define OPC_srlb 159\n");
  1080. printf ("#define OPC_srll 160\n");
  1081. printf ("#define OPC_sub 161\n");
  1082. printf ("#define OPC_subb 162\n");
  1083. printf ("#define OPC_subl 163\n");
  1084. printf ("#define OPC_tcc 164\n");
  1085. printf ("#define OPC_tccb 165\n");
  1086. printf ("#define OPC_test 166\n");
  1087. printf ("#define OPC_testb 167\n");
  1088. printf ("#define OPC_testl 168\n");
  1089. printf ("#define OPC_trdb 169\n");
  1090. printf ("#define OPC_trdrb 170\n");
  1091. printf ("#define OPC_trib 171\n");
  1092. printf ("#define OPC_trirb 172\n");
  1093. printf ("#define OPC_trtdrb 173\n");
  1094. printf ("#define OPC_trtib 174\n");
  1095. printf ("#define OPC_trtirb 175\n");
  1096. printf ("#define OPC_trtrb 176\n");
  1097. printf ("#define OPC_tset 177\n");
  1098. printf ("#define OPC_tsetb 178\n");
  1099. printf ("#define OPC_xor 179\n");
  1100. printf ("#define OPC_xorb 180\n");
  1101. printf ("#define OPC_ldd 181\n");
  1102. printf ("#define OPC_lddb 182\n");
  1103. printf ("#define OPC_lddr 183\n");
  1104. printf ("#define OPC_lddrb 184\n");
  1105. printf ("#define OPC_ldi 185\n");
  1106. printf ("#define OPC_ldib 186\n");
  1107. printf ("#define OPC_sc 187\n");
  1108. printf ("#define OPC_bpt 188\n");
  1109. printf ("#define OPC_ext0e 188\n");
  1110. printf ("#define OPC_ext0f 188\n");
  1111. printf ("#define OPC_ext8e 188\n");
  1112. printf ("#define OPC_ext8f 188\n");
  1113. printf ("#define OPC_rsvd36 188\n");
  1114. printf ("#define OPC_rsvd38 188\n");
  1115. printf ("#define OPC_rsvd78 188\n");
  1116. printf ("#define OPC_rsvd7e 188\n");
  1117. printf ("#define OPC_rsvd9d 188\n");
  1118. printf ("#define OPC_rsvd9f 188\n");
  1119. printf ("#define OPC_rsvdb9 188\n");
  1120. printf ("#define OPC_rsvdbf 188\n");
  1121. printf ("#define OPC_ldctlb 189\n");
  1122. printf ("#define OPC_trtdb 190\n");
  1123. printf ("#define OPC_brk 191\n");
  1124. #if 0
  1125. for (i = 0; toks[i].token; i++)
  1126. printf ("#define %s\t0x%x\n", toks[i].token, i * 16);
  1127. #endif
  1128. printf ("\ntypedef struct {\n");
  1129. printf ("#ifdef NICENAMES\n");
  1130. printf (" const char *nicename;\n");
  1131. printf (" int type;\n");
  1132. printf (" int cycles;\n");
  1133. printf (" int flags;\n");
  1134. printf ("#endif\n");
  1135. printf (" const char *name;\n");
  1136. printf (" unsigned char opcode;\n");
  1137. printf (" void (*func) (void);\n");
  1138. printf (" unsigned int arg_info[4];\n");
  1139. printf (" unsigned int byte_info[%d];\n", BYTE_INFO_LEN);
  1140. printf (" int noperands;\n");
  1141. printf (" int length;\n");
  1142. printf (" int idx;\n");
  1143. printf ("} opcode_entry_type;\n\n");
  1144. printf ("#ifdef DEFINE_TABLE\n");
  1145. printf ("const opcode_entry_type z8k_table[] = {\n");
  1146. while (new_op->flags && new_op->flags[0] != '*')
  1147. {
  1148. int nargs;
  1149. int length;
  1150. printf ("\n/* %s *** %s */\n", new_op->bits, new_op->name);
  1151. printf ("{\n");
  1152. printf ("#ifdef NICENAMES\n");
  1153. printf ("\"%s\",%d,%d,", new_op->name, new_op->type, new_op->cycles);
  1154. {
  1155. int answer = 0;
  1156. char *p = new_op->flags;
  1157. while (*p)
  1158. {
  1159. answer <<= 1;
  1160. if (*p != '-')
  1161. answer |= 1;
  1162. p++;
  1163. }
  1164. printf ("0x%02x,\n", answer);
  1165. }
  1166. printf ("#endif\n");
  1167. nargs = chewname (&new_op->name);
  1168. printf ("\n\t");
  1169. chewbits (new_op->bits, &length);
  1170. length /= 2;
  1171. if (length & 1)
  1172. abort();
  1173. if (strcmp (oldname, new_op->name) != 0)
  1174. idx++;
  1175. printf (",%d,%d,%d", nargs, length, idx);
  1176. oldname = new_op->name;
  1177. printf ("},\n");
  1178. new_op++;
  1179. }
  1180. printf ("\n/* end marker */\n");
  1181. printf ("{\n#ifdef NICENAMES\nNULL,0,0,\n0,\n#endif\n");
  1182. printf ("NULL,0,0,{0,0,0,0},{0,0,0,0,0,0,0,0,0,0},0,0,0}\n};\n");
  1183. printf ("#endif\n");
  1184. }
  1185. int
  1186. main (int ac, char **av)
  1187. {
  1188. struct op *p = opt;
  1189. if (ac == 2 && strcmp (av[1], "-t") == 0)
  1190. {
  1191. internal ();
  1192. }
  1193. else if (ac == 2 && strcmp (av[1], "-h") == 0)
  1194. {
  1195. while (p->name)
  1196. {
  1197. printf ("%-25s\t%s\n", p->name, p->bits);
  1198. p++;
  1199. }
  1200. }
  1201. else if (ac == 2 && strcmp (av[1], "-a") == 0)
  1202. {
  1203. gas ();
  1204. }
  1205. else
  1206. {
  1207. printf ("Usage: %s -t\n", av[0]);
  1208. printf ("-t : generate new internal table\n");
  1209. printf ("-a : generate new table for gas\n");
  1210. printf ("-h : generate new table for humans\n");
  1211. }
  1212. return 0;
  1213. }