9549425b63cd876132bbda088c9b3b7e374a9a46
2 #define BYTE_INFO_LEN 10
3 /*#include "z8opcode.h"*/
8 #define iswhite(x) ((x) == ' ' || (x) == '\t')
11 "1011 0101 ssss dddd","adc rd,rs",
12 "1011 0100 ssss dddd","adcb rbd,rbs",
13 "0000 0001 ssN0 dddd","add rd,@rs",
14 "0100 0001 0000 dddd address","add rd,address",
15 "0100 0001 ssN0 dddd address","add rd,address(rs)",
16 "0000 0001 0000 dddd imm16","add rd,imm16",
17 "1000 0001 ssss dddd","add rd,rs",
18 "0000 0000 ssN0 dddd","addb rbd,@rs",
19 "0100 0000 0000 dddd address","addb rbd,address",
20 "0100 0000 ssN0 dddd address","addb rbd,address(rs)",
21 "0000 0000 0000 dddd imm8 imm8","addb rbd,imm8",
22 "1000 0000 ssss dddd","addb rbd,rbs",
23 "0001 0110 ssN0 dddd","addl rrd,@rs",
24 "0101 0110 0000 dddd address","addl rrd,address",
25 "0101 0110 ssN0 dddd address","addl rrd,address(rs)",
26 "0001 0110 0000 dddd imm32","addl rrd,imm32",
27 "1001 0110 ssss dddd","addl rrd,rrs",
28 "0000 0111 ssN0 dddd","and rd,@rs",
29 "0100 0111 0000 dddd address","and rd,address",
30 "0100 0111 ssN0 dddd address","and rd,address(rs)",
31 "0000 0111 0000 dddd imm16","and rd,imm16",
32 "1000 0111 ssss dddd","and rd,rs",
33 "0000 0110 ssN0 dddd","andb rbd,@rs",
34 "0100 0110 0000 dddd address","andb rbd,address",
35 "0100 0110 ssN0 dddd address","andb rbd,address(rs)",
36 "0000 0110 0000 dddd imm8 imm8","andb rbd,imm8",
37 "1000 0110 ssss dddd","andb rbd,rbs",
38 "0010 0111 ddN0 imm4","bit @rd,imm4",
39 "0110 0111 ddN0 imm4 address","bit address(rd),imm4",
40 "0110 0111 0000 imm4 address","bit address,imm4",
41 "1010 0111 dddd imm4","bit rd,imm4",
42 "0010 0111 0000 ssss 0000 dddd 0000 0000","bit rd,rs",
43 "0010 0110 ddN0 imm4","bitb @rd,imm4",
44 "0110 0110 ddN0 imm4 address","bitb address(rd),imm4",
45 "0110 0110 0000 imm4 address","bitb address,imm4",
46 "1010 0110 dddd imm4","bitb rbd,imm4",
47 "0010 0110 0000 ssss 0000 dddd 0000 0000","bitb rbd,rs",
48 "0001 1111 ddN0 0000","call @rd",
49 "0101 1111 0000 0000 address","call address",
50 "0101 1111 ddN0 0000 address","call address(rd)",
51 "1101 disp12","calr disp12",
52 "0000 1101 ddN0 1000","clr @rd",
53 "0100 1101 0000 1000 address","clr address",
54 "0100 1101 ddN0 1000 address","clr address(rd)",
55 "1000 1101 dddd 1000","clr rd",
56 "0000 1100 ddN0 1000","clrb @rd",
57 "0100 1100 0000 1000 address","clrb address",
58 "0100 1100 ddN0 1000 address","clrb address(rd)",
59 "1000 1100 dddd 1000","clrb rbd",
60 "1011 1011 ssN0 1010 0000 rrrr ddN0 cccc","cpsd @rd,@rs,rr,cc",
61 "1011 1010 ssN0 1010 0000 rrrr ddN0 cccc","cpsdb @rd,@rs,rr,cc",
62 "1011 1011 ssN0 1110 0000 rrrr ddN0 cccc","cpsdr @rd,@rs,rr,cc",
63 "1011 1010 ssN0 1110 0000 rrrr ddN0 cccc","cpsdrb @rd,@rs,rr,cc",
64 "1011 1011 ssN0 0010 0000 rrrr ddN0 cccc","cpsi @rd,@rs,rr,cc",
65 "1011 1010 ssN0 0010 0000 rrrr ddN0 cccc","cpsib @rd,@rs,rr,cc",
66 "1011 1011 ssN0 0110 0000 rrrr ddN0 cccc","cpsir @rd,@rs,rr,cc",
67 "1011 1010 ssN0 0110 0000 rrrr ddN0 cccc","cpsirb @rd,@rs,rr,cc",
68 "0000 1101 ddN0 0000","com @rd",
69 "0100 1101 0000 0000 address","com address",
70 "0100 1101 ddN0 0000 address","com address(rd)",
71 "1000 1101 dddd 0000","com rd",
72 "0000 1100 ddN0 0000","comb @rd",
73 "0100 1100 0000 0000 address","comb address",
74 "0100 1100 ddN0 0000 address","comb address(rd)",
75 "1000 1100 dddd 0000","comb rbd",
76 "1000 1101 imm4 0101","comflg flags",
77 "0000 1101 ddN0 0001 imm16","cp @rd,imm16",
78 "0100 1101 ddN0 0001 address imm16","cp address(rd),imm16",
79 "0100 1101 0000 0001 address imm16","cp address,imm16",
80 "0000 1011 ssN0 dddd","cp rd,@rs",
81 "0100 1011 0000 dddd address","cp rd,address",
82 "0100 1011 ssN0 dddd address","cp rd,address(rs)",
83 "0000 1011 0000 dddd imm16","cp rd,imm16",
84 "1000 1011 ssss dddd","cp rd,rs",
85 "0000 1100 ddN0 0001 imm8 imm8","cpb @rd,imm8",
86 "0100 1100 ddN0 0001 address imm8 imm8","cpb address(rd),imm8",
87 "0100 1100 0000 0001 address imm8 imm8","cpb address,imm8",
88 "0000 1010 ssN0 dddd","cpb rbd,@rs",
89 "0100 1010 0000 dddd address","cpb rbd,address",
90 "0100 1010 ssN0 dddd address","cpb rbd,address(rs)",
91 "0000 1010 0000 dddd imm8 imm8","cpb rbd,imm8",
92 "1000 1010 ssss dddd","cpb rbd,rbs",
93 "1011 1011 ssN0 1000 0000 rrrr dddd cccc","cpd rd,@rs,rr,cc",
94 "1011 1010 ssN0 1000 0000 rrrr dddd cccc","cpdb rbd,@rs,rr,cc",
95 "1011 1011 ssN0 1100 0000 rrrr dddd cccc","cpdr rd,@rs,rr,cc",
96 "1011 1010 ssN0 1100 0000 rrrr dddd cccc","cpdrb rbd,@rs,rr,cc",
97 "1011 1011 ssN0 0000 0000 rrrr dddd cccc","cpi rbd,@rs,rr,cc",
98 "1011 1010 ssN0 0000 0000 rrrr dddd cccc","cpib rd,@rs,rr,cc",
99 "1011 1011 ssN0 0100 0000 rrrr dddd cccc","cpir rbd,@rs,rr,cc",
100 "1011 1010 ssN0 0100 0000 rrrr dddd cccc","cpirb rd,@rs,rr,cc",
101 "0001 0000 ssN0 dddd","cpl rrd,@rs",
102 "0101 0000 0000 dddd address","cpl rrd,address",
103 "0101 0000 ssN0 dddd address","cpl rrd,address(rs)",
104 "0001 0000 0000 dddd imm32","cpl rrd,imm32",
105 "1001 0000 ssss dddd","cpl rrd,rrs",
106 "1011 0000 dddd 0000","dab rbd",
107 "1111 dddd 1disp7","dbjnz rbd,disp7",
108 "0010 1011 ddN0 imm4","dec @rd,imm4",
109 "0110 1011 ddN0 imm4 address","dec address(rd),imm4",
110 "0110 1011 0000 imm4 address","dec address,imm4",
111 "1010 1011 dddd imm4","dec rd,imm4",
112 "0010 1010 ddN0 imm4","decb @rd,imm4",
113 "0110 1010 ddN0 imm4 address","decb address(rd),imm4",
114 "0110 1010 0000 imm4 address","decb address,imm4",
115 "1010 1010 dddd imm4","decb rbd,imm4",
116 "0111 1100 0000 00ii","di i2",
117 "0001 1011 ssN0 dddd","div rrd,@rs",
118 "0101 1011 0000 dddd address","div rrd,address",
119 "0101 1011 ssN0 dddd address","div rrd,address(rs)",
120 "0001 1011 0000 dddd imm16","div rrd,imm16",
121 "1001 1011 ssss dddd","div rrd,rs",
122 "0001 1010 ssN0 dddd","divl rqd,@rs",
123 "0101 1010 0000 dddd address","divl rqd,address",
124 "0101 1010 ssN0 dddd address","divl rqd,address(rs)",
125 "0001 1010 0000 dddd imm32","divl rqd,imm32",
126 "1001 1010 ssss dddd","divl rqd,rrs",
127 "1111 dddd 0disp7","djnz rd,disp7",
128 "0111 1100 0000 01ii","ei i2",
129 "1010 1101 ssss dddd","ex rbd,rbs",
130 "0010 1101 ssN0 dddd","ex rd,@rs",
131 "0110 1101 0000 dddd address","ex rd,address",
132 "0110 1101 ssN0 dddd address","ex rd,address(rs)",
133 "0010 1100 ssN0 dddd","exb rbd,@rs",
134 "0110 1100 0000 dddd address","exb rbd,address",
135 "0110 1100 ssN0 dddd address","exb rbd,address(rs)",
136 "1010 1100 ssss dddd","exb rbd,rbs",
137 "1011 0001 dddd 1010","exts rrd",
138 "1011 0001 dddd 0000","extsb rd",
139 "1011 0001 dddd 0111","extsl rqd",
140 "0111 1010 0000 0000","halt",
141 "0011 1101 ssN0 dddd","in rd,@rs",
142 "0011 1101 dddd 0100 imm16","in rd,imm16",
143 "0011 1100 ssN0 dddd","inb rbd,@rs",
144 "0011 1100 dddd 0100 imm16","inb rbd,imm16",
145 "0010 1001 ddN0 imm4","inc @rd,imm4",
146 "0110 1001 ddN0 imm4 address","inc address(rd),imm4",
147 "0110 1001 0000 imm4 address","inc address,imm4",
148 "1010 1001 dddd imm4","inc rd,imm4",
149 "0010 1000 ddN0 imm4","incb @rd,imm4",
150 "0110 1000 ddN0 imm4 address","incb address(rd),imm4",
151 "0110 1000 0000 imm4 address","incb address,imm4",
152 "1010 1000 dddd imm4","incb rbd,imm4",
153 "0011 1011 ssN0 1000 0000 aaaa ddN0 1000","ind @rd,@rs,ra",
154 "0011 1010 ssN0 1000 0000 aaaa ddN0 1000","indb @rd,@rs,rba",
155 "0011 1100 ssN0 0000 0000 aaaa ddN0 1000","inib @rd,@rs,ra",
156 "0011 1100 ssN0 0000 0000 aaaa ddN0 0000","inibr @rd,@rs,ra",
157 "0111 1011 0000 0000","iret",
158 "0001 1110 ddN0 cccc","jp cc,@rd",
159 "0101 1110 0000 cccc address","jp cc,address",
160 "0101 1110 ddN0 cccc address","jp cc,address(rd)",
161 "1110 cccc disp8","jr cc,disp8",
162 "0000 1101 ddN0 0101 imm16","ld @rd,imm16",
163 "0010 1111 ddN0 ssss","ld @rd,rs",
164 "0100 1101 ddN0 0101 address imm16","ld address(rd),imm16",
165 "0110 1111 ddN0 ssss address","ld address(rd),rs",
166 "0100 1101 0000 0101 address imm16","ld address,imm16",
167 "0110 1111 0000 ssss address","ld address,rs",
168 "0011 0011 ddN0 ssss disp16","ld rd(disp16),rs",
169 "0111 0011 ddN0 ssss 0000 xxxx 0000 0000","ld rd(rx),rs",
170 "0010 0001 ssN0 dddd","ld rd,@rs",
171 "0110 0001 0000 dddd address","ld rd,address",
172 "0110 0001 ssN0 dddd address","ld rd,address(rs)",
173 "0010 0001 0000 dddd imm16","ld rd,imm16",
174 "1010 0001 ssss dddd","ld rd,rs",
175 "0011 0001 ssN0 dddd disp16","ld rd,rs(disp16)",
176 "0111 0001 ssN0 dddd 0000 xxxx 0000 0000","ld rd,rs(rx)",
177 "0111 0110 0000 dddd address","lda rd,address",
178 "0111 0110 ssN0 dddd address","lda rd,address(rs)",
179 "0011 0100 ssN0 dddd disp16","lda rd,rs(disp16)",
180 "0111 0100 ssN0 dddd 0000 xxxx 0000 0000","lda rd,rs(rx)",
181 "0011 0100 0000 dddd disp16","ldar rd,disp16",
182 "0000 1100 ddN0 0101 imm8 imm8","ldb @rd,imm8",
183 "0010 1110 ddN0 ssss","ldb @rd,rbs",
184 "0100 1100 ddN0 0101 address imm8 imm8","ldb address(rd),imm8",
185 "0100 1110 ddN0 ssss address","ldb address(rd),rbs",
186 "0100 1100 0000 0101 address imm8 imm8","ldb address,imm8",
187 "0110 1110 0000 ssss address","ldb address,rbs",
188 "0010 0000 ssN0 dddd","ldb rbd,@rs",
189 "0110 0000 0000 dddd address","ldb rbd,address",
190 "0110 0000 ssN0 dddd address","ldb rbd,address(rs)",
191 "1100 dddd imm8","ldb rbd,imm8",
192 "0010 0000 0000 dddd imm8 imm8","ldb rbd,imm8",
193 "1010 0000 ssss dddd","ldb rbd,rbs",
194 "0011 0000 ssN0 dddd disp16","ldb rbd,rs(disp16)",
195 "0111 0000 ssN0 dddd 0000 xxxx 0000 0000","ldb rbd,rs(rx)",
196 "0011 0010 ddN0 ssss disp16","ldb rd(disp16),rbs",
197 "0111 0010 ddN0 ssss 0000 xxxx 0000 0000","ldb rd(rx),rbs",
198 "0111 1101 ssss 1ccc","ldctl ctrl,rs",
199 "0111 1101 dddd 0ccc","ldctl rd,ctrl",
200 "0001 1101 ddN0 ssss","ldl @rd,rrs",
201 "0101 1101 ddN0 ssss address","ldl address(rd),rrs",
202 "0101 1101 0000 ssss address","ldl address,rrs",
203 "0011 0111 ddN0 ssss disp16","ldl rd(disp16),rrs",
204 "0111 0111 ddN0 ssss 0000 xxxx 0000 0000","ldl rd(rx),rrs",
205 "0001 0100 ssN0 dddd","ldl rrd,@rs",
206 "0101 0100 0000 dddd address","ldl rrd,address",
207 "0101 0100 ssN0 dddd address","ldl rrd,address(rs)",
208 "0001 0100 0000 dddd imm32","ldl rrd,imm32",
209 "1001 0100 ssss dddd","ldl rrd,rrs",
210 "0011 0101 ssN0 dddd disp16","ldl rrd,rs(disp16)",
211 "0111 0101 ssN0 dddd 0000 xxxx 0000 0000","ldl rrd,rs(rx)",
212 "0001 1100 ddN0 1001 0000 ssss 0000 nminus1","ldm @rd,rs,n",
213 "0101 1100 ddN0 1001 0000 ssN0 0000 nminus1 address","ldm address(rd),rs,n",
214 "0101 1100 0000 1001 0000 ssss 0000 nminus1 address","ldm address,rs,n",
215 "0001 1100 ssN0 0001 0000 dddd 0000 nminus1","ldm rd,@rs,n",
216 "0101 1100 ssN0 0001 0000 dddd 0000 nminus1 address","ldm rd,address(rs),n",
217 "0101 1100 0000 0001 0000 dddd 0000 nminus1 address","ldm rd,address,n",
218 "0011 1001 ssN0 0000","ldps @rs",
219 "1011 1101 dddd imm4","ldk rd,imm4",
220 "1011 1010 ssN0 0001 0000 rrrr ddN0 0000","ldirb @rd,@rs,rr",
221 "1011 1011 ssN0 0001 0000 rrrr ddN0 0000","ldir @rd,@rs,rr",
223 "0111 1001 0000 0000 address","ldps address",
224 "0111 1001 ssN0 0000 address","ldps address(rs)",
225 "0011 0011 0000 ssss disp16","ldr disp16,rs",
226 "0011 0001 0000 dddd disp16","ldr rd,disp16",
227 "0011 0010 0000 ssss disp16","ldrb disp16,rbs",
228 "0011 0000 0000 dddd disp16","ldrb rbd,disp16",
229 "0011 0111 0000 ssss disp16","ldrl disp16,rrs",
230 "0011 0101 0000 dddd disp16","ldrl rrd,disp16",
231 "0111 1011 0000 1010","mbit",
232 "0111 1011 dddd 1101","mreq rd",
233 "0111 1011 0000 1001","mres",
234 "0111 1011 0000 1000","mset",
235 "0001 1001 ssN0 dddd","mult rrd,@rs",
236 "0101 1001 0000 dddd address","mult rrd,address",
237 "0101 1001 ssN0 dddd address","mult rrd,address(rs)",
238 "0001 1001 0000 dddd imm16","mult rrd,imm16",
239 "1001 1001 ssss dddd","mult rrd,rs",
240 "0001 1000 ssN0 dddd","multl rqd,@rs",
241 "0101 1000 0000 dddd address","multl rqd,address",
242 "0101 1000 ssN0 dddd address","multl rqd,address(rs)",
243 "0001 1000 0000 dddd imm32","multl rqd,imm32",
244 "1001 1000 ssss dddd","multl rqd,rrs",
245 "0000 1101 ddN0 0010","neg @rd",
246 "0100 1101 0000 0010 address","neg address",
247 "0100 1101 ddN0 0010 address","neg address(rd)",
248 "1000 1101 dddd 0010","neg rd",
249 "0000 1100 ddN0 0010","negb @rd",
250 "0100 1100 0000 0010 address","negb address",
251 "0100 1100 ddN0 0010 address","negb address(rd)",
252 "1000 1100 dddd 0010","negb rbd",
253 "1000 1101 0000 0111","nop",
254 "0000 0101 ssN0 dddd","or rd,@rs",
255 "0100 0101 0000 dddd address","or rd,address",
256 "0100 0101 ssN0 dddd address","or rd,address(rs)",
257 "0000 0101 0000 dddd imm16","or rd,imm16",
258 "1000 0101 ssss dddd","or rd,rs",
259 "0000 0100 ssN0 dddd","orb rbd,@rs",
260 "0100 0100 0000 dddd address","orb rbd,address",
261 "0100 0100 ssN0 dddd address","orb rbd,address(rs)",
262 "0000 0100 0000 dddd imm8 imm8","orb rbd,imm8",
263 "1000 0100 ssss dddd","orb rbd,rbs",
264 "0011 1111 ddN0 ssss","out @rd,rs",
265 "0011 1011 ssss 0110 imm16","out imm16,rs",
266 "0011 1110 ddN0 ssss","outb @rd,rbs",
267 "0011 1010 ssss 0110 imm16","outb imm16,rbs",
268 "0011 1011 ssN0 1010 0000 aaaa ddN0 1000","outd @rd,@rs,ra",
269 "0011 1010 ssN0 1010 0000 aaaa ddN0 1000","outdb @rd,@rs,rba",
270 "0011 1100 ssN0 0010 0000 aaaa ddN0 1000","outib @rd,@rs,ra",
271 "0011 1100 ssN0 0010 0000 aaaa ddN0 0000","outibr @rd,@rs,ra",
272 "0001 0111 ssN0 ddN0","pop @rd,@rs",
273 "0101 0111 ssN0 ddN0 address","pop address(rd),@rs",
274 "0101 0111 ssN0 0000 address","pop address,@rs",
275 "1001 0111 ssN0 dddd","pop rd,@rs",
276 "0001 0101 ssN0 ddN0","popl @rd,@rs",
277 "0101 0101 ssN0 ddN0 address","popl address(rd),@rs",
278 "0101 0101 ssN0 0000 address","popl address,@rs",
279 "1001 0101 ssN0 dddd","popl rrd,@rs",
280 "0001 0011 ddN0 ssN0","push @rd,@rs",
281 "0101 0011 ddN0 0000 address","push @rd,address",
282 "0000 1101 ddN0 1001 imm16","push @rd,imm16",
283 "1001 0011 ddN0 ssss","push @rd,rs",
284 "0101 0011 ddN0 ssN0 address","push @rd,address(rs)",
285 "0001 0001 ddN0 ssN0","pushl @rd,@rs",
286 "0101 0001 ddN0 0000 address","push @rd,address",
287 "1001 0001 ddN0 ssss","pushl @rd,rrs",
288 "0101 0001 ddN0 ssN0 address","pushl @rd,address(rs)",
289 "0010 0011 ddN0 imm4","res @rd,imm4",
290 "0110 0011 ddN0 imm4 address","res address(rd),imm4",
291 "0110 0011 0000 imm4 address","res address,imm4",
292 "1010 0011 dddd imm4","res rd,imm4",
293 "0010 0011 0000 ssss 0000 dddd 0000 0000","res rd,rs",
294 "0010 0010 ddN0 imm4","resb @rd,imm4",
295 "0110 0010 ddN0 imm4 address","resb address(rd),imm4",
296 "0110 0010 0000 imm4 address","resb address,imm4",
297 "1010 0010 dddd imm4","resb rbd,imm4",
298 "0010 0010 0000 ssss 0000 dddd 0000 0000","resb rbd,rs",
299 "1000 1101 imm4 0011","resflg imm4",
300 "1001 1110 0000 cccc","ret cc",
301 "1011 0011 dddd 0000","rl rd,1",
302 "1011 0011 dddd 0010","rl rd,2",
303 "1011 0010 dddd 0000","rlb rbd,1",
304 "1011 0010 dddd 0010","rlb rbd,2",
305 "1011 0011 dddd 1000","rlc rd,1",
306 "1011 0011 dddd 1010","rlc rd,2",
307 "1011 0010 dddd 1000","rlcb rbd,1",
308 "1011 0010 dddd 1010","rlcb rbd,2",
309 "1011 1110 aaaa bbbb","rldb rbb,rba",
310 "1011 0011 dddd 0100","rr rd,1",
311 "1011 0011 dddd 0110","rr rd,2",
312 "1011 0010 dddd 0100","rrb rbd,1",
313 "1011 0010 dddd 0110","rrb rbd,2",
314 "1011 0011 dddd 1100","rrc rd,1",
315 "1011 0011 dddd 1110","rrc rd,2",
316 "1011 0010 dddd 1100","rrcb rbd,1",
317 "1011 0010 dddd 1110","rrcb rbd,2",
318 "1011 1100 aaaa bbbb","rrdb rbb,rba",
319 "1011 0111 ssss dddd","sbc rd,rs",
320 "1011 0110 ssss dddd","sbcb rbd,rbs",
321 "1011 0011 dddd 1011 0000 ssss 0000 0000","sda rd,rs",
322 "1011 0010 dddd 1011 0000 ssss 0000 0000","sdab rbd,rs",
323 "1011 0011 dddd 1111 0000 ssss 0000 0000","sdal rrd,rs",
324 "1011 0011 dddd 0011 0000 ssss 0000 0000","sdl rd,rs",
325 "1011 0010 dddd 0011 0000 ssss 0000 0000","sdlb rbd,rs",
326 "1011 0011 dddd 0111 0000 ssss 0000 0000","sdll rrd,rs",
327 "0010 0101 ddN0 imm4","set @rd,imm4",
328 "0110 0101 ddN0 imm4 address","set address(rd),imm4",
329 "0110 0101 0000 imm4 address","set address,imm4",
330 "1010 0101 dddd imm4","set rd,imm4",
331 "0010 0101 0000 ssss 0000 dddd 0000 0000","set rd,rs",
332 "0010 0100 ddN0 imm4","setb @rd,imm4",
333 "0110 0100 ddN0 imm4 address","setb address(rd),imm4",
334 "0110 0100 0000 imm4 address","setb address,imm4",
335 "1010 0100 dddd imm4","setb rbd,imm4",
336 "0010 0100 0000 ssss 0000 dddd 0000 0000","setb rbd,rs",
337 "1000 1101 imm4 0001","setflg imm4",
338 "0011 1100 dddd 0101 imm16","sinb rbd,imm16",
339 "0011 1101 dddd 0101 imm16","sinb rd,imm16",
340 "0011 1011 ssN0 1000 0001 aaaa ddN0 1000","sind @rd,@rs,ra",
341 "0011 1010 ssN0 1000 0001 aaaa ddN0 1000","sindb @rd,@rs,rba",
342 "0011 1100 ssN0 0001 0000 aaaa ddN0 1000","sinib @rd,@rs,ra",
343 "0011 1100 ssN0 0001 0000 aaaa ddN0 0000","sinibr @rd,@rs,ra",
344 "1011 0011 dddd 1001 imm16","sla rd,imm16",
345 "1011 0010 dddd 1001 imm16","slab rbd,imm16",
346 "1011 0011 dddd 1101 imm16","slal rrd,imm16",
347 "1011 0011 dddd 0001 imm16","sll rd,imm16",
348 "1011 0010 dddd 0001 imm16","sllb rbd,imm16",
349 "1011 0011 dddd 0101 imm16","slll rrd,imm16",
350 "0011 1011 ssss 0111 imm16","sout imm16,rs",
351 "0011 1010 ssss 0111 imm16","soutb imm16,rbs",
352 "0011 1011 ssN0 1011 0000 aaaa ddN0 1000","soutd @rd,@rs,ra",
353 "0011 1010 ssN0 1011 0000 aaaa ddN0 1000","soutdb @rd,@rs,rba",
354 "0011 1100 ssN0 0011 0000 aaaa ddN0 1000","soutib @rd,@rs,ra",
355 "0011 1100 ssN0 0011 0000 aaaa ddN0 0000","soutibr @rd,@rs,ra",
356 "1011 0011 dddd 1001 nim16","sra rd,imm16",
357 "1011 0010 dddd 1001 nim16","srab rbd,imm16",
358 "1011 0011 dddd 1101 nim16","sral rrd,imm16",
359 "1011 0011 dddd 0001 nim16","srl rd,imm16",
360 "1011 0010 dddd 0001 nim16","srlb rbd,imm16",
361 "1011 0011 dddd 0101 nim16","srll rrd,imm16",
362 "0000 0011 ssN0 dddd","sub rd,@rs",
363 "0100 0011 0000 dddd address","sub rd,address",
364 "0100 0011 ssN0 dddd address","sub rd,address(rs)",
365 "0000 0010 0000 dddd imm16","sub rd,imm16",
366 "1000 0011 ssss dddd","sub rd,rs",
367 "0000 0010 ssN0 dddd","subb rbd,@rs",
368 "0100 0010 0000 dddd address","subb rbd,address",
369 "0100 0010 ssN0 dddd address","subb rbd,address(rs)",
370 "0000 0010 0000 dddd imm8 imm8","subb rbd,imm8",
371 "1000 0010 ssss dddd","subb rbd,rbs",
372 "0001 0010 ssN0 dddd","subl rrd,@rs",
373 "0101 0010 0000 dddd address","subl rrd,address",
374 "0101 0010 ssN0 dddd address","subl rrd,address(rs)",
375 "0001 0010 0000 dddd imm32","subl rrd,imm32",
376 "1001 0010 ssss dddd","subl rrd,rrs",
377 "1010 1111 dddd cccc","tcc cc,rd",
378 "1010 1110 dddd cccc","tccb cc,rbd",
379 "0000 1101 ddN0 0100","test @rd",
380 "0100 1101 0000 0100 address","test address",
381 "0100 1101 ddN0 0100 address","test address(rd)",
382 "1000 1101 dddd 0100","test rd",
383 "0000 1100 ddN0 0100","testb @rd",
384 "0100 1100 0000 0100 address","testb address",
385 "0100 1100 ddN0 0100 address","testb address(rd)",
386 "1000 1100 dddd 0100","testb rbd",
387 "0001 1100 ddN0 1000","testl @rd",
388 "0101 1100 0000 1000 address","testl address",
389 "1001 1100 dddd 1000","testl rrd",
390 "1011 1000 ddN0 1000 0000 aaaa ssN0 0000","trdb @rd,@rs,rba",
391 "1011 1000 ddN0 1100 0000 aaaa ssN0 0000","trdrb @rd,@rs,rba",
392 "1011 1000 ddN0 0000 0000 rrrr ssN0 0000","trib @rd,@rs,rbr",
393 "1011 1000 ddN0 0100 0000 rrrr ssN0 0000","trirb @rd,@rs,rbr",
394 "1011 1000 aaN0 1110 0000 rrrr bbN0 1110","trtdrb @ra,@rb,rbr",
395 "1011 1000 aaN0 0010 0000 rrrr bbN0 0000","trtib @ra,@rb,rr",
396 "1011 1000 aaN0 0110 0000 rrrr bbN0 1110","trtirb @ra,@rb,rbr",
397 "1011 1000 aaN0 1010 0000 rrrr bbN0 0000","trtrb @ra,@rb,rbr",
398 "0000 1101 ddN0 0110","tset @rd",
399 "0100 1101 0000 0110 address","tset address",
400 "0100 1101 ddN0 0110 address","tset address(rd)",
401 "1000 1101 dddd 0110","tset rd",
402 "0000 1100 ddN0 0110","tsetb @rd",
403 "0100 1100 0000 0110 address","tsetb address",
404 "0100 1100 ddN0 0110 address","tsetb address(rd)",
405 "1000 1100 dddd 0110","tsetb rbd",
406 "0000 1001 ssN0 dddd","xor rd,@rs",
407 "0100 1001 0000 dddd address","xor rd,address",
408 "0100 1001 ssN0 dddd address","xor rd,address(rs)",
409 "0000 1001 0000 dddd imm16","xor rd,imm16",
410 "1000 1001 ssss dddd","xor rd,rs",
411 "0000 1000 ssN0 dddd","xorb rbd,@rs",
412 "0100 1000 0000 dddd address","xorb rbd,address",
413 "0100 1000 ssN0 dddd address","xorb rbd,address(rs)",
414 "0000 1000 0000 dddd imm8 imm8","xorb rbd,imm8",
415 "1000 1000 ssss dddd","xorb rbd,rbs",
438 return strcmp((a
)->name
, (b
)->name
);
447 return strcmp((a
)->bits
, (b
)->bits
);
454 literal 0000 nnnn insert nnn into stream
455 operand 0001 nnnn insert operand reg nnn into stream
458 typedef struct tok_struct
468 struct tok_struct args
[] =
471 { "address(rs)", "CLASS_X+(ARG_RS)",},
472 { "address(rd)", "CLASS_X+(ARG_RD)",},
474 { "rs(disp16)","CLASS_BA+(ARG_RS)",},
475 { "rd(disp16)","CLASS_BA+(ARG_RD)",},
477 { "address", "CLASS_DA",},
478 { "rd(rx)", "CLASS_BX+(ARG_RD)",},
479 { "rs(rx)","CLASS_BX+(ARG_RS)",},
480 { "disp16", "CLASS_DISP",},
481 { "disp12", "CLASS_DISP",},
482 { "disp7", "CLASS_DISP",},
483 { "disp8", "CLASS_DISP",},
484 { "flags","CLASS_FLAGS",},
485 { "imm16", "CLASS_IMM+(ARG_IMM16)",},
486 { "imm32", "CLASS_IMM+(ARG_IMM32)",},
487 { "imm4", "CLASS_IMM +(ARG_IMM4)",},
488 { "n", "CLASS_IMM + (ARG_IMMN)",},
489 { "ctrl", "CLASS_CTRL",},
490 { "rba", "CLASS_REG_BYTE+(ARG_RA)",},
491 { "rbb", "CLASS_REG_BYTE+(ARG_RB)",},
492 { "rbd", "CLASS_REG_BYTE+(ARG_RD)",},
493 { "rbs", "CLASS_REG_BYTE+(ARG_RS)",},
494 { "rbr", "CLASS_REG_BYTE+(ARG_RR)",},
496 { "rrd","CLASS_REG_LONG+(ARG_RD)",},
497 { "rrs","CLASS_REG_LONG+(ARG_RS)",},
499 { "rqd", "CLASS_REG_QUAD+(ARG_RD)",},
501 { "rd", "CLASS_REG_WORD+(ARG_RD)",},
502 { "rs", "CLASS_REG_WORD+(ARG_RS)",},
504 { "@rd", "CLASS_IR+(ARG_RD)",},
505 { "@ra", "CLASS_IR+(ARG_RA)",},
506 { "@rb", "CLASS_IR+(ARG_RB)",},
507 { "@rs", "CLASS_IR+(ARG_RS)",},
509 { "imm8", "CLASS_IMM+(ARG_IMM8)",},
510 { "i2", "CLASS_IMM+(ARG_IMM2)",},
511 { "cc", "CLASS_CC",},
513 { "rr", "CLASS_REG_WORD+(ARG_RR)",},
514 { "ra", "CLASS_REG_WORD+(ARG_RA)",},
515 { "rs", "CLASS_REG_WORD+(ARG_RS)",},
517 { "1", "CLASS_IMM+(ARG_IMM_1)",},
518 { "2", "CLASS_IMM+(ARG_IMM_2)",},
523 struct tok_struct toks
[] =
525 "0000", "CLASS_BIT+0",1,
526 "0001", "CLASS_BIT+1",1,
527 "0010", "CLASS_BIT+2",1,
528 "0011", "CLASS_BIT+3",1,
529 "0100", "CLASS_BIT+4",1,
530 "0101", "CLASS_BIT+5",1,
531 "0110", "CLASS_BIT+6",1,
532 "0111", "CLASS_BIT+7",1,
533 "1000", "CLASS_BIT+8",1,
534 "1001", "CLASS_BIT+9",1,
535 "1010", "CLASS_BIT+10",1,
536 "1011", "CLASS_BIT+11",1,
537 "1100", "CLASS_BIT+12",1,
538 "1101", "CLASS_BIT+13",1,
539 "1110", "CLASS_BIT+14",1,
540 "1111", "CLASS_BIT+15",1,
542 "ssss", "CLASS_REG+(ARG_RS)",1,
543 "dddd", "CLASS_REG+(ARG_RD)",1,
544 "aaaa", "CLASS_REG+(ARG_RA)",1,
545 "bbbb", "CLASS_REG+(ARG_RB)",1,
546 "rrrr", "CLASS_REG+(ARG_RR)",1,
548 "ssN0", "CLASS_REGN0+(ARG_RS)",1,
549 "ddN0", "CLASS_REGN0+(ARG_RD)",1,
550 "aaN0", "CLASS_REGN0+(ARG_RA)",1,
551 "bbN0", "CLASS_REGN0+(ARG_RB)",1,
552 "rrN0", "CLASS_REGN0+(ARG_RR)",1,
554 "cccc", "CLASS_CC",1,
555 "nnnn", "CLASS_IMM+(ARG_IMMN)",1,
556 "xxxx", "CLASS_REG+(ARG_RX)",1,
557 "xxN0", "CLASS_REGN0+(ARG_RX)",1,
558 "nminus1", "CLASS_IMM+(ARG_IMMNMINUS1)",1,
560 "disp16", "CLASS_DISP+(ARG_DISP16)",4,
561 "disp12", "CLASS_DISP+(ARG_DISP12)",3,
562 "flags", "CLASS_FLAGS",1,
563 "address", "CLASS_ADDRESS",4,
564 "imm4", "CLASS_IMM+(ARG_IMM4)",1,
565 "imm8", "CLASS_IMM+(ARG_IMM8)",2,
566 "imm16", "CLASS_IMM+(ARG_IMM16)",4,
567 "imm32", "CLASS_IMM+(ARG_IMM32)",8,
568 "nim16", "CLASS_IMM+(ARG_NIM16)",4,
569 "0ccc", "CLASS_0CCC",1,
570 "1ccc", "CLASS_1CCC",1,
571 "disp8", "CLASS_DISP8",2,
572 "0disp7", "CLASS_0DISP7",2,
573 "1disp7", "CLASS_1DISP7",2,
574 "01ii", "CLASS_01II",1,
575 "00ii", "CLASS_00II",1,
581 char *translate(table
, x
, length
)
582 struct tok_struct
*table
;
591 int l
= strlen(table
->match
);
592 if (strncmp(table
->match
, x
, l
) == 0)
595 printf("%s", table
->token
);
596 *length
+= table
->length
;
602 fprintf(stderr
,"Can't find %s\n", x
);
610 chewbits(bits
, length
)
626 bits
= translate(toks
, bits
, length
);
631 while (n
< BYTE_INFO_LEN
-1) {
641 printf("REGH %c ", x
[0]);
652 while (*n
&& !iswhite(*n
)) {
657 /* Scan the operands and make entires for them -remember indirect things */
660 while (*n
== ',' || iswhite(*n
))
663 n
= translate(args
, n
, &d
);
691 struct op
*new = malloc(sizeof(struct op
) * c
);
693 memcpy(new, p
, c
* sizeof(struct op
));
695 /* sort all names in table alphabetically */
696 qsort(new, c
, sizeof(struct op
), func
);
699 /* If there are any @rs, sub the ssss into a ssn0,
709 /* skip the r and sub the string */
714 if (s
[0] == '(' && s
[3] == ')')
727 printf("\"%s\",\"%s\",\n", p
->bits
, p
->name
);
739 struct op
*new = malloc(sizeof(struct op
) * c
);
741 memcpy(new, p
, c
* sizeof(struct op
));
743 /* sort all names in table alphabetically */
744 qsort(new, c
, sizeof(struct op
), func
);
746 printf(" /* THIS FILE IS AUTOMAGICALLY GENERATED, DON'T EDIT IT */\n");
748 printf("#define ARG_MASK 0x0f\n");
749 printf("#define ARG_RS 0x01\n");
750 printf("#define ARG_RD 0x02\n");
751 printf("#define ARG_RA 0x03\n");
752 printf("#define ARG_RB 0x04\n");
753 printf("#define ARG_RR 0x05\n");
754 printf("#define ARG_RX 0x06\n");
755 printf("#define ARG_IMM4 0x01\n");
756 printf("#define ARG_IMM8 0x02\n");
757 printf("#define ARG_IMM16 0x03\n");
758 printf("#define ARG_IMM32 0x04\n");
759 printf("#define ARG_IMMN 0x05\n");
760 printf("#define ARG_IMMNMINUS1 0x05\n");
761 printf("#define ARG_IMM_1 0x06\n");
762 printf("#define ARG_IMM_2 0x07\n");
763 printf("#define ARG_DISP16 0x08\n");
764 printf("#define ARG_NIM16 0x09\n");
765 printf("#define ARG_IMM2 0x0a\n");
766 printf("#define ARG_DISP12 0x0b\n");
767 printf("#define ARG_DISP8 0x0c\n");
769 printf("#define CLASS_MASK 0xfff0\n");
770 printf("#define CLASS_X 0x10\n");
771 printf("#define CLASS_BA 0x20\n");
772 printf("#define CLASS_DA 0x30\n");
773 printf("#define CLASS_BX 0x40\n");
774 printf("#define CLASS_DISP 0x50\n");
775 printf("#define CLASS_IMM 0x60\n");
776 printf("#define CLASS_CC 0x70\n");
777 printf("#define CLASS_CTRL 0x80\n");
778 printf("#define CLASS_ADDRESS 0xd0\n");
779 printf("#define CLASS_0CCC 0xe0\n");
780 printf("#define CLASS_1CCC 0xf0\n");
781 printf("#define CLASS_0DISP7 0x100\n");
782 printf("#define CLASS_1DISP7 0x200\n");
783 printf("#define CLASS_01II 0x300\n");
784 printf("#define CLASS_00II 0x400\n");
785 printf("#define CLASS_BIT 0x500\n");
786 printf("#define CLASS_FLAGS 0x600\n");
787 printf("#define CLASS_IR 0x700\n");
788 printf("#define CLASS_DISP8 0x800\n");
791 printf("#define CLASS_REG 0x7000\n");
792 printf("#define CLASS_REG_BYTE 0x2000\n");
793 printf("#define CLASS_REG_WORD 0x3000\n");
794 printf("#define CLASS_REG_QUAD 0x4000\n");
795 printf("#define CLASS_REG_LONG 0x5000\n");
796 printf("#define CLASS_REGN0 0x8000\n");
801 for (i
= 0; toks
[i
].token
; i
++)
802 printf("#define %s\t0x%x\n",toks
[i
].token
,i
*16);
804 printf("typedef struct {\n");
805 printf("char *name;\n");
806 printf("unsigned short arg_info[4];\n");
807 printf("unsigned short byte_info[%d];\n", BYTE_INFO_LEN
);
808 printf("int noperands;\n");
809 printf("int length;\n");
810 printf("int idx;\n");
811 printf("} opcode_entry_type;\n");
812 printf("#ifdef DEFINE_TABLE\n");
813 printf("opcode_entry_type z8k_table[] = {\n");
819 nargs
= chewname(new->name
);
822 chewbits(new->bits
, &length
);
824 if (length
&1) fail();
826 printf(",%d,%d,%d", nargs
, length
, idx
);
827 if(strcmp(oldname
, new->name
))
844 if (ac
== 2 && strcmp(av
[1],"-t")==0)
848 else if (ac
== 2 && strcmp(av
[1],"-h")==0)
851 printf("%-25s\t%s\n", p
->name
, p
->bits
);
856 else if (ac
== 2 && strcmp(av
[1], "-a") == 0)
860 else if (ac
== 2 && strcmp(av
[1], "-d") == 0)
865 printf("Usage: %s -t\n", av
[0]);
866 printf("-t : generate new z8.c internal table\n");
867 printf("-a : generate new table for gas\n");
868 printf("-d : generate new table for disassemble\n");
869 printf("-h : generate new table for humans\n");
This page took 0.054675 seconds and 4 git commands to generate.