Revision | 4980f74cec7247aace6f8e12e32824aa7093771b (tree) |
---|---|
Time | 2019-01-19 01:22:44 |
Author | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
add disassembler
@@ -4,3 +4,4 @@ CONFIG_SERIAL=y | ||
4 | 4 | CONFIG_PTIMER=y |
5 | 5 | CONFIG_RX=y |
6 | 6 | CONFIG_RENESAS_SCI=y |
7 | +CONFIG_RX_DIS=y |
@@ -24,6 +24,7 @@ common-obj-$(CONFIG_SH4_DIS) += sh4.o | ||
24 | 24 | common-obj-$(CONFIG_SPARC_DIS) += sparc.o |
25 | 25 | common-obj-$(CONFIG_LM32_DIS) += lm32.o |
26 | 26 | common-obj-$(CONFIG_XTENSA_DIS) += xtensa.o |
27 | +common-obj-$(CONFIG_RX_DIS) += rx.o | |
27 | 28 | |
28 | 29 | # TODO: As long as the TCG interpreter and its generated code depend |
29 | 30 | # on the QEMU target, we cannot compile the disassembler here. |
@@ -0,0 +1,1268 @@ | ||
1 | +/* | |
2 | + * Renesas RX Disassembler | |
3 | + * | |
4 | + * Copyright (c) 2019 Yoshinori Sato <ysato@users.sourceforge.jp> | |
5 | + * | |
6 | + * This program is free software; you can redistribute it and/or modify it | |
7 | + * under the terms and conditions of the GNU General Public License, | |
8 | + * version 2 or later, as published by the Free Software Foundation. | |
9 | + * | |
10 | + * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | + * more details. | |
14 | + * | |
15 | + * You should have received a copy of the GNU General Public License along with | |
16 | + * this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | + */ | |
18 | + | |
19 | +#include "qemu/osdep.h" | |
20 | +#include "disas/bfd.h" | |
21 | + | |
22 | +struct opcode { | |
23 | + const char *nim; | |
24 | + int size; | |
25 | + int szwid; | |
26 | + int cond; | |
27 | + int len; | |
28 | +}; | |
29 | + | |
30 | +enum operand_type { | |
31 | + none, | |
32 | + imm135, | |
33 | + imm8, | |
34 | + uimm48, | |
35 | + uimm8_4, | |
36 | + imm, | |
37 | + float32, | |
38 | + incdec, | |
39 | + ind, | |
40 | + creg, | |
41 | + pcdsp, | |
42 | + memory, | |
43 | + dsp5, | |
44 | + regub, | |
45 | + psw, | |
46 | + reg, | |
47 | + reg8, | |
48 | + range, | |
49 | +}; | |
50 | + | |
51 | +struct operand { | |
52 | + enum operand_type type; | |
53 | + union { | |
54 | + struct { | |
55 | + int pos; | |
56 | + int sz; | |
57 | + } imm135; | |
58 | + struct { | |
59 | + int pos; | |
60 | + } imm8; | |
61 | + struct { | |
62 | + int pos; | |
63 | + int sz; | |
64 | + } uimm48; | |
65 | + struct { | |
66 | + int pos; | |
67 | + } uimm8_4; | |
68 | + struct { | |
69 | + int pos; | |
70 | + int li; | |
71 | + } imm; | |
72 | + struct { | |
73 | + int pos; | |
74 | + } float32; | |
75 | + struct { | |
76 | + int reg; | |
77 | + int incdec; | |
78 | + } incdec; | |
79 | + struct { | |
80 | + int base; | |
81 | + int offset; | |
82 | + } ind; | |
83 | + struct { | |
84 | + int creg; | |
85 | + } creg; | |
86 | + struct { | |
87 | + int pos; | |
88 | + int sz; | |
89 | + } pcdsp; | |
90 | + struct { | |
91 | + int reg; | |
92 | + int id; | |
93 | + int mi; | |
94 | + } memory; | |
95 | + struct { | |
96 | + int reg; | |
97 | + int id; | |
98 | + } regub; | |
99 | + struct { | |
100 | + int reg; | |
101 | + int offset1; | |
102 | + int offset1w; | |
103 | + int offset2; | |
104 | + } dsp5; | |
105 | + struct { | |
106 | + int b; | |
107 | + } psw; | |
108 | + struct { | |
109 | + int r; | |
110 | + } reg; | |
111 | + struct { | |
112 | + int r; | |
113 | + } reg8; | |
114 | + struct { | |
115 | + int start; | |
116 | + int end; | |
117 | + } range; | |
118 | + }; | |
119 | +}; | |
120 | + | |
121 | +#define opcode(_code, _mask, _nim, _size, _szwid, _cond, _len) \ | |
122 | + .code = _code, \ | |
123 | + .mask = _mask, \ | |
124 | + .opcode = { \ | |
125 | + .nim = _nim, .size = _size, .szwid = _szwid, \ | |
126 | + .cond = _cond, .len = _len, \ | |
127 | + }, | |
128 | +#define operand(no, _type, ...) \ | |
129 | + .operand[no] = { .type = _type, ._type = {__VA_ARGS__}, }, | |
130 | +#define NONE (-1) | |
131 | +#define PCRELB (-2) | |
132 | + | |
133 | +/* Instruction Tables */ | |
134 | +static struct instruction { | |
135 | + unsigned int code; | |
136 | + unsigned int mask; | |
137 | + struct opcode opcode; | |
138 | + struct operand operand[3]; | |
139 | +} const instructions[] = { | |
140 | + { | |
141 | + opcode(0xfd180000, 0xffffef00, "racw", NONE, NONE, NONE, 3) | |
142 | + operand(0, imm135, 19, 1) | |
143 | + }, | |
144 | + { | |
145 | + opcode(0xfd170000, 0xfffff000, "mvtachi", NONE, NONE, NONE, 3) | |
146 | + operand(0, reg, 20) | |
147 | + }, | |
148 | + { | |
149 | + opcode(0xfd171000, 0xfffff000, "mvtaclo", NONE, NONE, NONE, 3) | |
150 | + operand(0, reg, 20) | |
151 | + }, | |
152 | + { | |
153 | + opcode(0xfd722000, 0xfffff000, "fadd", NONE, NONE, NONE, 3) | |
154 | + operand(0, float32, 24) | |
155 | + operand(1, reg, 20) | |
156 | + }, | |
157 | + { | |
158 | + opcode(0xfd720000, 0xfffff000, "fsub", NONE, NONE, NONE, 3) | |
159 | + operand(0, float32, 24) | |
160 | + operand(1, reg, 20) | |
161 | + }, | |
162 | + { | |
163 | + opcode(0xfd723000, 0xfffff000, "fmul", NONE, NONE, NONE, 3) | |
164 | + operand(0, float32, 24) | |
165 | + operand(1, reg, 20) | |
166 | + }, | |
167 | + { | |
168 | + opcode(0xfd724000, 0xfffff000, "fdiv", NONE, NONE, NONE, 3) | |
169 | + operand(0, float32, 24) | |
170 | + operand(1, reg, 20) | |
171 | + }, | |
172 | + { | |
173 | + opcode(0xfd721000, 0xfffff000, "fcmp", NONE, NONE, NONE, 3) | |
174 | + operand(0, float32, 24) | |
175 | + operand(1, reg, 20) | |
176 | + }, | |
177 | + { | |
178 | + opcode(0x06200000, 0xff3cff00, "sbb", NONE, NONE, NONE, 4) | |
179 | + operand(0, memory, 24, 14, 8) | |
180 | + operand(1, reg, 28) | |
181 | + }, | |
182 | + { | |
183 | + opcode(0x06200200, 0xff3cff00, "adc", NONE, NONE, NONE, 4) | |
184 | + operand(0, memory, 24, 14, 8) | |
185 | + operand(1, reg, 28) | |
186 | + }, | |
187 | + { | |
188 | + opcode(0x06200400, 0xff3cff00, "max", NONE, NONE, NONE, 4) | |
189 | + operand(0, memory, 24, 14, 8) | |
190 | + operand(1, reg, 28) | |
191 | + }, | |
192 | + { | |
193 | + opcode(0x06200500, 0xff3cff00, "min", NONE, NONE, NONE, 4) | |
194 | + operand(0, memory, 24, 14, 8) | |
195 | + operand(1, reg, 28) | |
196 | + }, | |
197 | + { | |
198 | + opcode(0x06200600, 0xff3cff00, "emul", NONE, NONE, NONE, 4) | |
199 | + operand(0, memory, 24, 14, 8) | |
200 | + operand(1, reg, 28) | |
201 | + }, | |
202 | + { | |
203 | + opcode(0x06200700, 0xff3cff00, "emulu", NONE, NONE, NONE, 4) | |
204 | + operand(0, memory, 24, 14, 8) | |
205 | + operand(1, reg, 28) | |
206 | + }, | |
207 | + { | |
208 | + opcode(0x06200800, 0xff3cff00, "div", NONE, NONE, NONE, 4) | |
209 | + operand(0, memory, 24, 14, 8) | |
210 | + operand(1, reg, 28) | |
211 | + }, | |
212 | + { | |
213 | + opcode(0x06200900, 0xff3cff00, "divu", NONE, NONE, NONE, 4) | |
214 | + operand(0, memory, 24, 14, 8) | |
215 | + operand(1, reg, 28) | |
216 | + }, | |
217 | + { | |
218 | + opcode(0x06200c00, 0xff3cff00, "tst", NONE, NONE, NONE, 4) | |
219 | + operand(0, memory, 24, 14, 8) | |
220 | + operand(1, reg, 28) | |
221 | + }, | |
222 | + { | |
223 | + opcode(0x06200d00, 0xff3cff00, "xor", NONE, NONE, NONE, 4) | |
224 | + operand(0, memory, 24, 14, 8) | |
225 | + operand(1, reg, 28) | |
226 | + }, | |
227 | + { | |
228 | + opcode(0x06201000, 0xff3cff00, "xchg", NONE, NONE, NONE, 4) | |
229 | + operand(0, memory, 24, 14, 8) | |
230 | + operand(1, reg, 28) | |
231 | + }, | |
232 | + { | |
233 | + opcode(0x06201100, 0xff3cff00, "itof", NONE, NONE, NONE, 4) | |
234 | + operand(0, memory, 24, 14, 8) | |
235 | + operand(1, reg, 28) | |
236 | + }, | |
237 | + { | |
238 | + opcode(0xfd702000, 0xfff3f000, "adc", NONE, NONE, NONE, 3) | |
239 | + operand(0, imm, 24, 12) | |
240 | + operand(1, reg, 20) | |
241 | + }, | |
242 | + { | |
243 | + opcode(0xfd704000, 0xfff3f000, "max", NONE, NONE, NONE, 3) | |
244 | + operand(0, imm, 24, 12) | |
245 | + operand(1, reg, 20) | |
246 | + }, | |
247 | + { | |
248 | + opcode(0xfd705000, 0xfff3f000, "min", NONE, NONE, NONE, 3) | |
249 | + operand(0, imm, 24, 12) | |
250 | + operand(1, reg, 20) | |
251 | + }, | |
252 | + { | |
253 | + opcode(0xfd706000, 0xfff3f000, "emul", NONE, NONE, NONE, 3) | |
254 | + operand(0, imm, 24, 12) | |
255 | + operand(1, reg, 20) | |
256 | + }, | |
257 | + { | |
258 | + opcode(0xfd707000, 0xfff3f000, "emulu", NONE, NONE, NONE, 3) | |
259 | + operand(0, imm, 24, 12) | |
260 | + operand(1, reg, 20) | |
261 | + }, | |
262 | + { | |
263 | + opcode(0xfd708000, 0xfff3f000, "div", NONE, NONE, NONE, 3) | |
264 | + operand(0, imm, 24, 12) | |
265 | + operand(1, reg, 20) | |
266 | + }, | |
267 | + { | |
268 | + opcode(0xfd709000, 0xfff3f000, "divu", NONE, NONE, NONE, 3) | |
269 | + operand(0, imm, 24, 12) | |
270 | + operand(1, reg, 20) | |
271 | + }, | |
272 | + { | |
273 | + opcode(0xfd70c000, 0xfff3f000, "tst", NONE, NONE, NONE, 3) | |
274 | + operand(0, imm, 24, 12) | |
275 | + operand(1, reg, 20) | |
276 | + }, | |
277 | + { | |
278 | + opcode(0xfd70d000, 0xfff3f000, "xor", NONE, NONE, NONE, 3) | |
279 | + operand(0, imm, 24, 12) | |
280 | + operand(1, reg, 20) | |
281 | + }, | |
282 | + { | |
283 | + opcode(0xfd70e000, 0xfff3f000, "stz", NONE, NONE, NONE, 3) | |
284 | + operand(0, imm, 24, 12) | |
285 | + operand(1, reg, 20) | |
286 | + }, | |
287 | + { | |
288 | + opcode(0xfd70f000, 0xfff3f000, "stnz", NONE, NONE, NONE, 3) | |
289 | + operand(0, imm, 24, 12) | |
290 | + operand(1, reg, 20) | |
291 | + }, | |
292 | + { | |
293 | + opcode(0xfd6a0000, 0xffff0000, "mvfc", NONE, NONE, NONE, 3) | |
294 | + operand(0, creg, 16) | |
295 | + operand(1, reg, 20) | |
296 | + }, | |
297 | + { | |
298 | + opcode(0xfd670000, 0xffff0000, "revl", NONE, NONE, NONE, 3) | |
299 | + operand(0, reg, 16) | |
300 | + operand(1, reg, 20) | |
301 | + }, | |
302 | + { | |
303 | + opcode(0xfd660000, 0xffff0000, "rotl", NONE, NONE, NONE, 3) | |
304 | + operand(0, reg, 16) | |
305 | + operand(1, reg, 20) | |
306 | + }, | |
307 | + { | |
308 | + opcode(0xfd650000, 0xffff0000, "revl", NONE, NONE, NONE, 3) | |
309 | + operand(0, reg, 16) | |
310 | + operand(1, reg, 20) | |
311 | + }, | |
312 | + { | |
313 | + opcode(0xfd640000, 0xffff0000, "rotr", NONE, NONE, NONE, 3) | |
314 | + operand(0, reg, 16) | |
315 | + operand(1, reg, 20) | |
316 | + }, | |
317 | + { | |
318 | + opcode(0xfd620000, 0xffff0000, "shll", NONE, NONE, NONE, 3) | |
319 | + operand(0, reg, 16) | |
320 | + operand(1, reg, 20) | |
321 | + }, | |
322 | + { | |
323 | + opcode(0xfd610000, 0xffff0000, "shar", NONE, NONE, NONE, 3) | |
324 | + operand(0, reg, 16) | |
325 | + operand(1, reg, 20) | |
326 | + }, | |
327 | + { | |
328 | + opcode(0xfd600000, 0xffff0000, "shlr", NONE, NONE, NONE, 3) | |
329 | + operand(0, reg, 16) | |
330 | + operand(1, reg, 20) | |
331 | + }, | |
332 | + { | |
333 | + opcode(0xfd1f0000, 0xffff0000, "mvfachi", NONE, NONE, NONE, 3) | |
334 | + operand(0, reg, 20) | |
335 | + }, | |
336 | + { | |
337 | + opcode(0xfd1f2000, 0xffff0000, "mvfacmi", NONE, NONE, NONE, 3) | |
338 | + operand(0, reg, 20) | |
339 | + }, | |
340 | + { | |
341 | + opcode(0xfd050000, 0xffff0000, "maclo", NONE, NONE, NONE, 3) | |
342 | + operand(0, reg, 16) | |
343 | + operand(1, reg, 20) | |
344 | + }, | |
345 | + { | |
346 | + opcode(0xfd040000, 0xffff0000, "machi", NONE, NONE, NONE, 3) | |
347 | + operand(0, reg, 16) | |
348 | + operand(1, reg, 20) | |
349 | + }, | |
350 | + { | |
351 | + opcode(0xfd010000, 0xffff0000, "mullo", NONE, NONE, NONE, 3) | |
352 | + operand(0, reg, 16) | |
353 | + operand(1, reg, 20) | |
354 | + }, | |
355 | + { | |
356 | + opcode(0xfd000000, 0xffff0000, "mulhi", NONE, NONE, NONE, 3) | |
357 | + operand(0, reg, 16) | |
358 | + operand(1, reg, 20) | |
359 | + }, | |
360 | + { | |
361 | + opcode(0x7f960000, 0xffff0000, "wait", NONE, NONE, NONE, 2) | |
362 | + }, | |
363 | + { | |
364 | + opcode(0x7f950000, 0xffff0000, "rte", NONE, NONE, NONE, 2) | |
365 | + }, | |
366 | + { | |
367 | + opcode(0x7f940000, 0xffff0000, "rtfi", NONE, NONE, NONE, 2) | |
368 | + }, | |
369 | + { | |
370 | + opcode(0x7f930000, 0xffff0000, "satr", NONE, NONE, NONE, 2) | |
371 | + }, | |
372 | + { | |
373 | + opcode(0x7f8f0000, 0xffff0000, "smovf", NONE, NONE, NONE, 2) | |
374 | + }, | |
375 | + { | |
376 | + opcode(0x7f8b0000, 0xffff0000, "smovb", NONE, NONE, NONE, 2) | |
377 | + }, | |
378 | + { | |
379 | + opcode(0x7f870000, 0xffff0000, "smovu", NONE, NONE, NONE, 2) | |
380 | + }, | |
381 | + { | |
382 | + opcode(0x7f830000, 0xffff0000, "scmpu", NONE, NONE, NONE, 2) | |
383 | + }, | |
384 | + { | |
385 | + opcode(0x75700000, 0xffff0000, "mvtipl", NONE, NONE, NONE, 3) | |
386 | + operand(0, uimm48, 20, 4) | |
387 | + }, | |
388 | + { | |
389 | + opcode(0x75600000, 0xffff0000, "int", NONE, NONE, NONE, 3) | |
390 | + operand(0, uimm48, 16, 8) | |
391 | + }, | |
392 | + { | |
393 | + opcode(0xfc0f0000, 0xffff0000, "abs", NONE, NONE, NONE, 3) | |
394 | + operand(0, reg, 16) | |
395 | + operand(1, reg, 20) | |
396 | + }, | |
397 | + { | |
398 | + opcode(0xfc070000, 0xffff0000, "neg", NONE, NONE, NONE, 3) | |
399 | + operand(0, reg, 16) | |
400 | + operand(1, reg, 20) | |
401 | + }, | |
402 | + { | |
403 | + opcode(0xfc000000, 0xffff0000, "sbb", NONE, NONE, NONE, 3) | |
404 | + operand(0, reg, 16) | |
405 | + operand(1, reg, 20) | |
406 | + }, | |
407 | + { | |
408 | + opcode(0xfd6e0000, 0xfffe0000, "rotl", NONE, NONE, NONE, 3) | |
409 | + operand(0, imm135, 15, 5) | |
410 | + operand(1, reg, 20) | |
411 | + }, | |
412 | + { | |
413 | + opcode(0xfd6c0000, 0xfffe0000, "rotl", NONE, NONE, NONE, 3) | |
414 | + operand(0, reg, 16) | |
415 | + operand(1, reg, 20) | |
416 | + }, | |
417 | + { | |
418 | + opcode(0xfc980000, 0xfffc0000, "round", NONE, NONE, NONE, 3) | |
419 | + operand(0, regub, 16, 14) | |
420 | + operand(1, reg, 20) | |
421 | + }, | |
422 | + { | |
423 | + opcode(0xfc940000, 0xfffc0000, "ftoi", NONE, NONE, NONE, 3) | |
424 | + operand(0, regub, 16, 14) | |
425 | + operand(1, reg, 20) | |
426 | + }, | |
427 | + { | |
428 | + opcode(0xfc900000, 0xfffc0000, "fdiv", NONE, NONE, NONE, 3) | |
429 | + operand(0, regub, 16, 14) | |
430 | + operand(1, reg, 20) | |
431 | + }, | |
432 | + { | |
433 | + opcode(0xfc8c0000, 0xfffc0000, "fmul", NONE, NONE, NONE, 3) | |
434 | + operand(0, memory, 16, 14, NONE) | |
435 | + operand(1, reg, 20) | |
436 | + }, | |
437 | + { | |
438 | + opcode(0xfc880000, 0xfffc0000, "fadd", NONE, NONE, NONE, 3) | |
439 | + operand(0, memory, 16, 14, NONE) | |
440 | + operand(1, reg, 20) | |
441 | + }, | |
442 | + { | |
443 | + opcode(0xfc840000, 0xfffc0000, "fcmp", NONE, NONE, NONE, 3) | |
444 | + operand(0, memory, 16, 14, NONE) | |
445 | + operand(1, reg, 20) | |
446 | + }, | |
447 | + { | |
448 | + opcode(0xfc800000, 0xfffc0000, "fsub", NONE, NONE, NONE, 3) | |
449 | + operand(0, memory, 16, 14, NONE) | |
450 | + operand(1, reg, 20) | |
451 | + }, | |
452 | + { | |
453 | + opcode(0xfc6c0000, 0xfffc0000, "bnot", NONE, NONE, NONE, 3) | |
454 | + operand(0, reg, 20) | |
455 | + operand(1, memory, 16, 14, NONE) | |
456 | + }, | |
457 | + { | |
458 | + opcode(0xfc640000, 0xfffc0000, "btst", NONE, NONE, NONE, 3) | |
459 | + operand(0, reg, 20) | |
460 | + operand(1, memory, 16, 14, NONE) | |
461 | + }, | |
462 | + { | |
463 | + opcode(0xfc680000, 0xfffc0000, "bclr", NONE, NONE, NONE, 3) | |
464 | + operand(0, reg, 20) | |
465 | + operand(1, memory, 16, 14, NONE) | |
466 | + }, | |
467 | + { | |
468 | + opcode(0xfc600000, 0xfffc0000, "bset", NONE, NONE, NONE, 3) | |
469 | + operand(0, reg, 20) | |
470 | + operand(1, memory, 16, 14, NONE) | |
471 | + }, | |
472 | + { | |
473 | + opcode(0xfc440000, 0xfffc0000, "itof", NONE, NONE, NONE, 3) | |
474 | + operand(0, regub, 16, 14) | |
475 | + operand(1, reg, 20) | |
476 | + }, | |
477 | + { | |
478 | + opcode(0xfc340000, 0xfffc0000, "xor", NONE, NONE, NONE, 3) | |
479 | + operand(0, regub, 16, 14) | |
480 | + operand(1, reg, 20) | |
481 | + }, | |
482 | + { | |
483 | + opcode(0xfc300000, 0xfffc0000, "tst", NONE, NONE, NONE, 3) | |
484 | + operand(0, regub, 16, 14) | |
485 | + operand(1, reg, 20) | |
486 | + }, | |
487 | + { | |
488 | + opcode(0xfc380000, 0xfffc0000, "not", NONE, NONE, NONE, 3) | |
489 | + operand(0, regub, 16, 14) | |
490 | + operand(1, reg, 20) | |
491 | + }, | |
492 | + { | |
493 | + opcode(0x7f8c0000, 0xfffc0000, "rmpa", 14, 2, NONE, 2) | |
494 | + }, | |
495 | + { | |
496 | + opcode(0x7f880000, 0xfffc0000, "sstr", 14, 2, NONE, 2) | |
497 | + }, | |
498 | + { | |
499 | + opcode(0x7f840000, 0xfffc0000, "swhile", 14, 2, NONE, 2) | |
500 | + }, | |
501 | + { | |
502 | + opcode(0x7f800000, 0xfffc0000, "suntil", 14, 2, NONE, 2) | |
503 | + }, | |
504 | + { | |
505 | + opcode(0xfd680000, 0xfff80000, "mvtc", NONE, NONE, NONE, 3) | |
506 | + operand(0, reg, 16) | |
507 | + operand(1, creg, 20) | |
508 | + }, | |
509 | + { | |
510 | + opcode(0xfd280000, 0xfff80000, "mov", 14, 2, NONE, 3) | |
511 | + operand(0, incdec, 16, 13) | |
512 | + operand(1, reg, 20) | |
513 | + }, | |
514 | + { | |
515 | + opcode(0xfd200000, 0xfff80000, "mov", 14, 2, NONE, 3) | |
516 | + operand(0, reg, 20) | |
517 | + operand(1, incdec, 16, 13) | |
518 | + }, | |
519 | + { | |
520 | + opcode(0xfc200000, 0xfff80000, "div", NONE, NONE, NONE, 3) | |
521 | + operand(0, regub, 16, 14) | |
522 | + operand(1, reg, 20) | |
523 | + }, | |
524 | + { | |
525 | + opcode(0xfc180000, 0xfff80000, "emul", NONE, NONE, NONE, 3) | |
526 | + operand(0, regub, 16, 14) | |
527 | + operand(1, reg, 20) | |
528 | + }, | |
529 | + { | |
530 | + opcode(0xfc100000, 0xfff80000, "max", NONE, NONE, NONE, 3) | |
531 | + operand(0, regub, 16, 14) | |
532 | + operand(1, reg, 20) | |
533 | + }, | |
534 | + { | |
535 | + opcode(0xfc000000, 0xfff80000, "sbb", NONE, NONE, NONE, 3) | |
536 | + operand(0, regub, 16, 14) | |
537 | + operand(1, reg, 20) | |
538 | + }, | |
539 | + { | |
540 | + opcode(0xfc080000, 0xfff80000, "adb", NONE, NONE, NONE, 3) | |
541 | + operand(0, regub, 16, 14) | |
542 | + operand(1, reg, 20) | |
543 | + }, | |
544 | + { | |
545 | + opcode(0xfd730000, 0xfff30000, "mvtc", NONE, NONE, NONE, 3) | |
546 | + operand(0, imm, 24, 12) | |
547 | + operand(1, creg, 20) | |
548 | + }, | |
549 | + { | |
550 | + opcode(0xfd300000, 0xfff20000, "movu", 15, 1, NONE, 3) | |
551 | + operand(0, incdec, 16, 13) | |
552 | + operand(1, reg, 20) | |
553 | + }, | |
554 | + { | |
555 | + opcode(0xff500000, 0xfff00000, "or", NONE, NONE, NONE, 3) | |
556 | + operand(0, reg, 16) | |
557 | + operand(1, reg, 20) | |
558 | + operand(2, reg, 12) | |
559 | + }, | |
560 | + { | |
561 | + opcode(0xff400000, 0xfff00000, "or", NONE, NONE, NONE, 3) | |
562 | + operand(0, reg, 16) | |
563 | + operand(1, reg, 20) | |
564 | + operand(2, reg, 12) | |
565 | + }, | |
566 | + { | |
567 | + opcode(0xff300000, 0xfff00000, "mul", NONE, NONE, NONE, 3) | |
568 | + operand(0, reg, 16) | |
569 | + operand(1, reg, 20) | |
570 | + operand(2, reg, 12) | |
571 | + }, | |
572 | + { | |
573 | + opcode(0xff200000, 0xfff00000, "add", NONE, NONE, NONE, 3) | |
574 | + operand(0, reg, 16) | |
575 | + operand(1, reg, 20) | |
576 | + operand(2, reg, 12) | |
577 | + }, | |
578 | + { | |
579 | + opcode(0xff000000, 0xfff00000, "sub", NONE, NONE, NONE, 3) | |
580 | + operand(0, reg, 16) | |
581 | + operand(1, reg, 20) | |
582 | + operand(2, reg, 12) | |
583 | + }, | |
584 | + { | |
585 | + opcode(0xfcd00000, 0xfff00000, "sc", 12, 2, 20, 3) | |
586 | + operand(0, memory, 16, 14, NONE) | |
587 | + }, | |
588 | + { | |
589 | + opcode(0x7fb00000, 0xfff00000, "clrpsw", NONE, NONE, NONE, 2) | |
590 | + operand(0, psw, 12) | |
591 | + }, | |
592 | + { | |
593 | + opcode(0x7fa00000, 0xfff00000, "setpsw", NONE, NONE, NONE, 2) | |
594 | + operand(0, psw, 12) | |
595 | + }, | |
596 | + { | |
597 | + opcode(0x7f500000, 0xfff00000, "bsr.l", NONE, NONE, NONE, 2) | |
598 | + operand(0, reg, 12) | |
599 | + }, | |
600 | + { | |
601 | + opcode(0x7f400000, 0xfff00000, "bra.l", NONE, NONE, NONE, 2) | |
602 | + operand(0, reg, 12) | |
603 | + }, | |
604 | + { | |
605 | + opcode(0x7f100000, 0xfff00000, "jsr", NONE, NONE, NONE, 2) | |
606 | + operand(0, reg, 12) | |
607 | + }, | |
608 | + { | |
609 | + opcode(0x7f000000, 0xfff00000, "jmp", NONE, NONE, NONE, 2) | |
610 | + operand(0, reg, 12) | |
611 | + }, | |
612 | + { | |
613 | + opcode(0x7ee00000, 0xfff00000, "popc", NONE, NONE, NONE, 2) | |
614 | + operand(0, creg, 12) | |
615 | + }, | |
616 | + { | |
617 | + opcode(0x7ec00000, 0xfff00000, "pushc", NONE, NONE, NONE, 2) | |
618 | + operand(0, creg, 12) | |
619 | + }, | |
620 | + { | |
621 | + opcode(0x7eb00000, 0xfff00000, "pop", NONE, NONE, NONE, 2) | |
622 | + operand(0, reg, 12) | |
623 | + }, | |
624 | + { | |
625 | + opcode(0x7e300000, 0xfff00000, "sat", NONE, NONE, NONE, 2) | |
626 | + operand(0, reg, 12) | |
627 | + }, | |
628 | + { | |
629 | + opcode(0x75500000, 0xfff00000, "cmp", NONE, NONE, NONE, 3) | |
630 | + operand(0, uimm48, 16, 8) | |
631 | + operand(1, reg, 12) | |
632 | + }, | |
633 | + { | |
634 | + opcode(0x75400000, 0xfff00000, "mov.l", NONE, NONE, NONE, 3) | |
635 | + operand(0, uimm48, 16, 8) | |
636 | + operand(1, reg, 12) | |
637 | + }, | |
638 | + { | |
639 | + opcode(0x7e500000, 0xfff00000, "rolc", NONE, NONE, NONE, 2) | |
640 | + operand(0, reg, 12) | |
641 | + }, | |
642 | + { | |
643 | + opcode(0x7e400000, 0xfff00000, "rorc", NONE, NONE, NONE, 2) | |
644 | + operand(0, reg, 12) | |
645 | + }, | |
646 | + { | |
647 | + opcode(0x7e000000, 0xfff00000, "not", NONE, NONE, NONE, 2) | |
648 | + operand(0, reg, 12) | |
649 | + }, | |
650 | + { | |
651 | + opcode(0x7e100000, 0xfff00000, "neg", NONE, NONE, NONE, 2) | |
652 | + operand(0, reg, 12) | |
653 | + }, | |
654 | + { | |
655 | + opcode(0x7e200000, 0xfff00000, "abs", NONE, NONE, NONE, 2) | |
656 | + operand(0, reg, 12) | |
657 | + }, | |
658 | + { | |
659 | + opcode(0x06140000, 0xff3c0000, "or", NONE, NONE, NONE, 3) | |
660 | + operand(0, memory, 16, 14, 8) | |
661 | + operand(1, reg, 20) | |
662 | + }, | |
663 | + { | |
664 | + opcode(0x06100000, 0xff3c0000, "and", NONE, NONE, NONE, 3) | |
665 | + operand(0, memory, 16, 14, 8) | |
666 | + operand(1, reg, 20) | |
667 | + }, | |
668 | + { | |
669 | + opcode(0x060c0000, 0xff3c0000, "mul", NONE, NONE, NONE, 3) | |
670 | + operand(0, memory, 16, 14, 8) | |
671 | + operand(1, reg, 20) | |
672 | + }, | |
673 | + { | |
674 | + opcode(0x06080000, 0xff3c0000, "add", NONE, NONE, NONE, 3) | |
675 | + operand(0, memory, 16, 14, 8) | |
676 | + operand(1, reg, 20) | |
677 | + }, | |
678 | + { | |
679 | + opcode(0x06040000, 0xff3c0000, "cmp", NONE, NONE, NONE, 3) | |
680 | + operand(0, memory, 16, 14, 8) | |
681 | + operand(1, reg, 20) | |
682 | + }, | |
683 | + { | |
684 | + opcode(0x06000000, 0xff3c0000, "sub", NONE, NONE, NONE, 3) | |
685 | + operand(0, memory, 16, 14, 8) | |
686 | + operand(1, reg, 20) | |
687 | + }, | |
688 | + { | |
689 | + opcode(0xfde0f000, 0xffe0f000, "bnot", NONE, NONE, NONE, 3) | |
690 | + operand(0, imm135, 11, 5) | |
691 | + operand(1, reg, 20) | |
692 | + }, | |
693 | + { | |
694 | + opcode(0xfce00f00, 0xffe00f00, "bnot", NONE, NONE, NONE, 3) | |
695 | + operand(0, imm135, 11, 3) | |
696 | + operand(1, memory, 16, 14, NONE) | |
697 | + }, | |
698 | + { | |
699 | + opcode(0xfec00000, 0xffe00000, "movu.l", NONE, NONE, NONE, 3) | |
700 | + operand(0, uimm48, 16, 8) | |
701 | + operand(1, reg, 12) | |
702 | + }, | |
703 | + { | |
704 | + opcode(0xfde00000, 0xffe00000, "bm", NONE, NONE, 16, 3) | |
705 | + operand(0, imm135, 11, 5) | |
706 | + operand(1, reg, 20) | |
707 | + }, | |
708 | + { | |
709 | + opcode(0xfdc00000, 0xffe00000, "shll", NONE, NONE, NONE, 3) | |
710 | + operand(0, imm135, 11, 5) | |
711 | + operand(1, reg, 16) | |
712 | + operand(2, reg, 20) | |
713 | + }, | |
714 | + { | |
715 | + opcode(0xfda00000, 0xffe00000, "shar", NONE, NONE, NONE, 3) | |
716 | + operand(0, imm135, 11, 5) | |
717 | + operand(1, reg, 16) | |
718 | + operand(2, reg, 20) | |
719 | + }, | |
720 | + { | |
721 | + opcode(0xfd800000, 0xffe00000, "shlr", NONE, NONE, NONE, 3) | |
722 | + operand(0, imm135, 11, 5) | |
723 | + operand(1, reg, 16) | |
724 | + operand(2, reg, 20) | |
725 | + }, | |
726 | + { | |
727 | + opcode(0xfce00000, 0xffe00000, "bm", NONE, NONE, 20, 3) | |
728 | + operand(0, imm135, 11, 3) | |
729 | + operand(1, memory, 16, 14, NONE) | |
730 | + }, | |
731 | + { | |
732 | + opcode(0x7e800000, 0xffc00000, "push", 10, 2, NONE, 2) | |
733 | + operand(0, reg, 12) | |
734 | + }, | |
735 | + { | |
736 | + opcode(0xfe400000, 0xffc00000, "mov", 10, 2, NONE, 3) | |
737 | + operand(0, ind, 16, 12) | |
738 | + operand(1, reg, 20) | |
739 | + }, | |
740 | + { | |
741 | + opcode(0xfe000000, 0xffc00000, "mov", 10, 2, NONE, 3) | |
742 | + operand(0, reg, 20) | |
743 | + operand(1, ind, 16, 12) | |
744 | + }, | |
745 | + { | |
746 | + opcode(0xfc400000, 0xffc00000, "xchg", NONE, NONE, NONE, 3) | |
747 | + operand(0, regub, 16, 14) | |
748 | + operand(1, reg, 20) | |
749 | + }, | |
750 | + { | |
751 | + opcode(0x74300000, 0xfcf00000, "or", NONE, NONE, NONE, 2) | |
752 | + operand(0, imm, 16, 6) | |
753 | + operand(1, reg, 20) | |
754 | + }, | |
755 | + { | |
756 | + opcode(0x74200000, 0xfcf00000, "and", NONE, NONE, NONE, 2) | |
757 | + operand(0, imm, 16, 6) | |
758 | + operand(1, reg, 20) | |
759 | + }, | |
760 | + { | |
761 | + opcode(0x74100000, 0xfcf00000, "mul", NONE, NONE, NONE, 2) | |
762 | + operand(0, imm, 16, 6) | |
763 | + operand(1, reg, 20) | |
764 | + }, | |
765 | + { | |
766 | + opcode(0x74000000, 0xfcf00000, "cmp", NONE, NONE, NONE, 2) | |
767 | + operand(0, imm, 16, 6) | |
768 | + operand(1, reg, 20) | |
769 | + }, | |
770 | + { | |
771 | + opcode(0xfb020000, 0xff030000, "mov.l", NONE, NONE, NONE, 2) | |
772 | + operand(0, imm, 16, 12) | |
773 | + operand(1, reg, 8) | |
774 | + }, | |
775 | + { | |
776 | + opcode(0xf4080000, 0xfc0c0000, "push", NONE, NONE, NONE, 2) | |
777 | + operand(0, memory, 8, 6, NONE) | |
778 | + }, | |
779 | + { | |
780 | + opcode(0x6f000000, 0xff000000, "popm", NONE, NONE, NONE, 2) | |
781 | + operand(0, range, 8, 12) | |
782 | + }, | |
783 | + { | |
784 | + opcode(0x6e000000, 0xff000000, "pushm", NONE, NONE, NONE, 2) | |
785 | + operand(0, range, 8, 12) | |
786 | + }, | |
787 | + { | |
788 | + opcode(0x67000000, 0xff000000, "rtsd", NONE, NONE, NONE, 2) | |
789 | + operand(0, uimm8_4, 8) | |
790 | + }, | |
791 | + { | |
792 | + opcode(0x66000000, 0xff000000, "mov.l", NONE, NONE, NONE, 2) | |
793 | + operand(0, uimm48, 8, 4) | |
794 | + operand(1, reg, 12) | |
795 | + }, | |
796 | + { | |
797 | + opcode(0x65000000, 0xff000000, "or", NONE, NONE, NONE, 2) | |
798 | + operand(0, uimm48, 8, 4) | |
799 | + operand(1, reg, 12) | |
800 | + }, | |
801 | + { | |
802 | + opcode(0x64000000, 0xff000000, "and", NONE, NONE, NONE, 2) | |
803 | + operand(0, uimm48, 8, 4) | |
804 | + operand(1, reg, 12) | |
805 | + }, | |
806 | + { | |
807 | + opcode(0x63000000, 0xff000000, "mul", NONE, NONE, NONE, 2) | |
808 | + operand(0, uimm48, 8, 4) | |
809 | + operand(1, reg, 12) | |
810 | + }, | |
811 | + { | |
812 | + opcode(0x62000000, 0xff000000, "add", NONE, NONE, NONE, 2) | |
813 | + operand(0, uimm48, 8, 4) | |
814 | + operand(1, reg, 12) | |
815 | + }, | |
816 | + { | |
817 | + opcode(0x61000000, 0xff000000, "cmp", NONE, NONE, NONE, 2) | |
818 | + operand(0, uimm48, 8, 4) | |
819 | + operand(1, reg, 12) | |
820 | + }, | |
821 | + { | |
822 | + opcode(0x60000000, 0xff000000, "sub", NONE, NONE, NONE, 2) | |
823 | + operand(0, uimm48, 8, 4) | |
824 | + operand(1, reg, 12) | |
825 | + }, | |
826 | + { | |
827 | + opcode(0x3f000000, 0xff000000, "rtsd", NONE, NONE, NONE, 3) | |
828 | + operand(0, uimm8_4, 16) | |
829 | + operand(1, range, 8, 12) | |
830 | + }, | |
831 | + { | |
832 | + opcode(0x39000000, 0xff000000, "bsr.w", NONE, NONE, NONE, 3) | |
833 | + operand(0, pcdsp, 8, 16) | |
834 | + }, | |
835 | + { | |
836 | + opcode(0x38000000, 0xff000000, "bra.w", NONE, NONE, NONE, 3) | |
837 | + operand(0, pcdsp, 8, 16) | |
838 | + }, | |
839 | + { | |
840 | + opcode(0x2e000000, 0xff000000, "bra.b", NONE, NONE, NONE, 2) | |
841 | + operand(0, pcdsp, 8, 8) | |
842 | + }, | |
843 | + { | |
844 | + opcode(0x05000000, 0xff000000, "bsr.a", NONE, NONE, NONE, 4) | |
845 | + operand(0, pcdsp, 8, 24) | |
846 | + }, | |
847 | + { | |
848 | + opcode(0x04000000, 0xff000000, "bra.a", NONE, NONE, NONE, 4) | |
849 | + operand(0, pcdsp, 8, 24) | |
850 | + }, | |
851 | + { | |
852 | + opcode(0x03000000, 0xff000000, "nop", NONE, NONE, NONE, 1) | |
853 | + }, | |
854 | + { | |
855 | + opcode(0x02000000, 0xff000000, "rts", NONE, NONE, NONE, 1) | |
856 | + }, | |
857 | + { | |
858 | + opcode(0x00000000, 0xff000000, "brk", NONE, NONE, NONE, 1) | |
859 | + }, | |
860 | + { | |
861 | + opcode(0x3a000000, 0xff000000, "beq.w", NONE, NONE, NONE, 3) | |
862 | + operand(0, pcdsp, 8, 16) | |
863 | + }, | |
864 | + { | |
865 | + opcode(0x3b000000, 0xff000000, "bne.w", NONE, NONE, NONE, 3) | |
866 | + operand(0, pcdsp, 8, 16) | |
867 | + }, | |
868 | + { | |
869 | + opcode(0x7c000000, 0xfe000000, "btst", NONE, NONE, NONE, 2) | |
870 | + operand(0, imm135, 7, 5) | |
871 | + operand(1, reg, 12) | |
872 | + }, | |
873 | + { | |
874 | + opcode(0x7a000000, 0xfe000000, "bclr", NONE, NONE, NONE, 2) | |
875 | + operand(0, imm135, 7, 5) | |
876 | + operand(1, reg, 12) | |
877 | + }, | |
878 | + { | |
879 | + opcode(0x78000000, 0xfe000000, "bset", NONE, NONE, NONE, 2) | |
880 | + operand(0, imm135, 7, 5) | |
881 | + operand(1, reg, 12) | |
882 | + }, | |
883 | + { | |
884 | + opcode(0x6c000000, 0xfe000000, "shll", NONE, NONE, NONE, 2) | |
885 | + operand(0, imm135, 7, 5) | |
886 | + operand(1, reg, 12) | |
887 | + }, | |
888 | + { | |
889 | + opcode(0x6a000000, 0xfe000000, "shar", NONE, NONE, NONE, 2) | |
890 | + operand(0, imm135, 7, 5) | |
891 | + operand(1, reg, 12) | |
892 | + }, | |
893 | + { | |
894 | + opcode(0x68000000, 0xfe000000, "shlr", NONE, NONE, NONE, 2) | |
895 | + operand(0, imm135, 7, 5) | |
896 | + operand(1, reg, 12) | |
897 | + }, | |
898 | + { | |
899 | + opcode(0xf4000000, 0xfc000000, "btst", NONE, NONE, NONE, 2) | |
900 | + operand(0, imm135, 13, 3) | |
901 | + operand(1, memory, 8, 6, NONE) | |
902 | + }, | |
903 | + { | |
904 | + opcode(0xf0080000, 0xfc080000, "bclr", NONE, NONE, NONE, 2) | |
905 | + operand(0, imm135, 13, 3) | |
906 | + operand(1, memory, 8, 6, NONE) | |
907 | + }, | |
908 | + { | |
909 | + opcode(0xf0000000, 0xfc080000, "bset", NONE, NONE, NONE, 2) | |
910 | + operand(0, imm135, 13, 3) | |
911 | + operand(1, memory, 8, 6, NONE) | |
912 | + }, | |
913 | + { | |
914 | + opcode(0xf8000000, 0xfc000000, "mov", 14, 2, NONE, 2) | |
915 | + operand(0, imm, NONE, 12) | |
916 | + operand(1, memory, 8, 6, NONE) | |
917 | + }, | |
918 | + { | |
919 | + opcode(0x70000000, 0xfc000000, "add", NONE, NONE, NONE, 2) | |
920 | + operand(0, imm, NONE, 6) | |
921 | + operand(1, reg, 8) | |
922 | + operand(2, reg, 12) | |
923 | + }, | |
924 | + { | |
925 | + opcode(0x54000000, 0xfc000000, "or", NONE, NONE, NONE, 2) | |
926 | + operand(0, regub, 8, 6) | |
927 | + operand(1, reg, 12) | |
928 | + }, | |
929 | + { | |
930 | + opcode(0x50000000, 0xfc000000, "and", NONE, NONE, NONE, 2) | |
931 | + operand(0, regub, 8, 6) | |
932 | + operand(1, reg, 12) | |
933 | + }, | |
934 | + { | |
935 | + opcode(0x4c000000, 0xfc000000, "mul", NONE, NONE, NONE, 2) | |
936 | + operand(0, regub, 8, 6) | |
937 | + operand(1, reg, 12) | |
938 | + }, | |
939 | + { | |
940 | + opcode(0x48000000, 0xfc000000, "add", NONE, NONE, NONE, 2) | |
941 | + operand(0, regub, 8, 6) | |
942 | + operand(1, reg, 12) | |
943 | + }, | |
944 | + { | |
945 | + opcode(0x44000000, 0xfc000000, "cmp", NONE, NONE, NONE, 2) | |
946 | + operand(0, regub, 8, 6) | |
947 | + operand(1, reg, 12) | |
948 | + }, | |
949 | + { | |
950 | + opcode(0x40000000, 0xfc000000, "sub", NONE, NONE, NONE, 2) | |
951 | + operand(0, regub, 8, 6) | |
952 | + operand(1, reg, 12) | |
953 | + }, | |
954 | + { | |
955 | + opcode(0x3c000000, 0xfc000000, "mov", 6, 2, NONE, 3) | |
956 | + operand(0, uimm48, 16, 8) | |
957 | + operand(1, dsp5, 9, 8, 1, 12) | |
958 | + }, | |
959 | + { | |
960 | + opcode(0xcf000000, 0xcf000000, "mov", 2, 2, NONE, 2) | |
961 | + operand(0, reg, 8) | |
962 | + operand(1, reg, 12) | |
963 | + }, | |
964 | + { | |
965 | + opcode(0x58000000, 0xf8000000, "movu", 5, 1, NONE, 2) | |
966 | + operand(0, memory, 8, 6, NONE) | |
967 | + operand(1, reg, 12) | |
968 | + }, | |
969 | + { | |
970 | + opcode(0x08000000, 0xf8000000, "bra.s", NONE, NONE, NONE, 1) | |
971 | + operand(0, pcdsp, 5, 3) | |
972 | + }, | |
973 | + { | |
974 | + opcode(0x10000000, 0xf8000000, "beq.s", NONE, NONE, NONE, 1) | |
975 | + operand(0, pcdsp, 5, 3) | |
976 | + }, | |
977 | + { | |
978 | + opcode(0x18000000, 0xf8000000, "bne.s", NONE, NONE, NONE, 1) | |
979 | + operand(0, pcdsp, 5, 3) | |
980 | + }, | |
981 | + { | |
982 | + opcode(0xb0000000, 0xf0000000, "movu", 4, 1, NONE, 2) | |
983 | + operand(0, dsp5, 9, 8, 4, 12) | |
984 | + operand(1, reg8, 13) | |
985 | + }, | |
986 | + { | |
987 | + opcode(0x20000000, 0xf0000000, "b", PCRELB, NONE, 4, 2) | |
988 | + operand(0, pcdsp, 8, 8) | |
989 | + }, | |
990 | + { | |
991 | + opcode(0xcc000000, 0xcc000000, "mov", 2, 2, NONE, 2) | |
992 | + operand(0, memory, 8, 6, NONE) | |
993 | + operand(1, reg, 12) | |
994 | + }, | |
995 | + { | |
996 | + opcode(0x88000000, 0xc8000000, "mov", 2, 2, NONE, 2) | |
997 | + operand(0, dsp5, 9, 8, 4, 12) | |
998 | + operand(1, reg8, 13) | |
999 | + }, | |
1000 | + { | |
1001 | + opcode(0x80000000, 0xc8000000, "mov", 2, 2, NONE, 2) | |
1002 | + operand(0, reg8, 13) | |
1003 | + operand(1, dsp5, 9, 8, 4, 12) | |
1004 | + }, | |
1005 | + { | |
1006 | + opcode(0xc3000000, 0xc3000000, "mov", 2, 2, NONE, 2) | |
1007 | + operand(0, reg, 12) | |
1008 | + operand(1, memory, 8, 4, NONE) | |
1009 | + }, | |
1010 | + { | |
1011 | + opcode(0xc0000000, 0xc0000000, "mov", 2, 2, NONE, 2) | |
1012 | + operand(0, memory, 8, 6, NONE) | |
1013 | + operand(1, memory, 12, 4, NONE) | |
1014 | + }, | |
1015 | +}; | |
1016 | + | |
1017 | +static const char *cond[] = { | |
1018 | + "eq", "ne", "c", "nc", "gtu", "leu", "pz", "n", | |
1019 | + "ge", "lt", "gt", "le", "o", "no", "<inv>", "<inv>", | |
1020 | +}; | |
1021 | + | |
1022 | +static const char size[] = { 'b', 'w', 'l', '?' }; | |
1023 | + | |
1024 | +static const char *creg_name[] = { | |
1025 | + "psw", "pc", "usp", "fpsw", "<inv>", "<inv>", "<inv>", "<inv>", | |
1026 | + "bpsw", "bpc", "isp", "fintv", "intb", "<inv>", "<inv>", "<inv>", | |
1027 | +}; | |
1028 | + | |
1029 | +static const char *psw_bit[] = { | |
1030 | + "c", "s", "z", "o", "<inv>", "<inv>", "<inv>", "<inv>", | |
1031 | + "i", "u", "<inv>", "<inv>", "<inv>", "<inv>", "<inv>", "<inv>", | |
1032 | +}; | |
1033 | + | |
1034 | +static const char *memex[] = { | |
1035 | + "b", "w", "l", "uw", | |
1036 | +}; | |
1037 | + | |
1038 | +#define prt(...) dis->fprintf_func(dis->stream, __VA_ARGS__) | |
1039 | +#define opcval(pos, wid) (op >> (32 - insn->opcode.pos - (wid)) \ | |
1040 | + & ((1 << (wid)) - 1)) | |
1041 | +#define oprval(pos, wid) (op >> (32 - insn->operand[i].pos - (wid)) \ | |
1042 | + & ((1 << (wid)) - 1)) | |
1043 | +#define oplen() (insn->opcode.len) | |
1044 | +#define opr(type, field) (insn->operand[i].type.field) | |
1045 | + | |
1046 | +#define memdisp(offset, reg) \ | |
1047 | + do { \ | |
1048 | + bfd_byte dbuf[2]; \ | |
1049 | + uint16_t dsp; \ | |
1050 | + dis->read_memory_func (addr + oplen() + offset, \ | |
1051 | + dbuf, id, dis); \ | |
1052 | + dsp = (id == 1)?dbuf[0]:(dbuf[0] | dbuf[1] << 8); \ | |
1053 | + prt("%d[r%d]", dsp << scale, reg); \ | |
1054 | + append += id; \ | |
1055 | + } while(0) | |
1056 | + | |
1057 | +int print_insn_rx (bfd_vma addr, disassemble_info * dis) | |
1058 | +{ | |
1059 | + bfd_byte buf[4]; | |
1060 | + uint32_t op; | |
1061 | + unsigned int i; | |
1062 | + int append = 0; | |
1063 | + int32_t val; | |
1064 | + int scale = 0; | |
1065 | + struct instruction const *insn = NULL; | |
1066 | + | |
1067 | + memset(buf, 0, sizeof(buf)); | |
1068 | + for (i = 0; i < 4; i++) | |
1069 | + if (dis->read_memory_func (addr + i, &buf[i], 1, dis)) | |
1070 | + break; | |
1071 | + op = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; | |
1072 | + | |
1073 | + for (i = 0; i < sizeof(instructions) / sizeof(instructions[0]); i++) { | |
1074 | + if ((op & instructions[i].mask) == instructions[i].code) { | |
1075 | + insn = &instructions[i]; | |
1076 | + break; | |
1077 | + } | |
1078 | + } | |
1079 | + | |
1080 | + if (insn == NULL) { | |
1081 | + prt(".byte\t0x%02x", op >> 24); | |
1082 | + return 1; | |
1083 | + } | |
1084 | + | |
1085 | + prt("%s", insn->opcode.nim); | |
1086 | + if (insn->opcode.cond > 0) { | |
1087 | + prt("%s", cond[opcval(cond, 4)]); | |
1088 | + if (insn->opcode.size == PCRELB) | |
1089 | + prt(".b"); | |
1090 | + } | |
1091 | + if (insn->opcode.size > 0) { | |
1092 | + scale = opcval(size, insn->opcode.szwid); | |
1093 | + prt(".%c", size[scale]); | |
1094 | + } | |
1095 | + | |
1096 | + for (i = 0; i < 3; i++) { | |
1097 | + if (insn->operand[i].type) | |
1098 | + prt((i > 0)?", ":"\t"); | |
1099 | + switch (insn->operand[i].type) { | |
1100 | + case none: | |
1101 | + break; | |
1102 | + case imm135: | |
1103 | + prt("#%d", oprval(imm135.pos, opr(imm135, sz))); | |
1104 | + break; | |
1105 | + case imm8: | |
1106 | + val = (op >> (32 - opr(imm8, pos) - 8)) << 24; | |
1107 | + val >>= 24; | |
1108 | + prt("#%d", val); | |
1109 | + break; | |
1110 | + case uimm48: | |
1111 | + prt("#%d", oprval(uimm48.pos, opr(uimm48, sz))); | |
1112 | + break; | |
1113 | + case uimm8_4: | |
1114 | + prt("#%d", oprval(uimm8_4.pos, 8) << 2); | |
1115 | + break; | |
1116 | + case imm: { | |
1117 | + int li = oprval(imm.li, 2); | |
1118 | + bfd_byte ibuf[4]; | |
1119 | + int offset = append; | |
1120 | + | |
1121 | + /* special case | |
1122 | + "mov #imm, dsp[rd]" is destination first */ | |
1123 | + if ((op & 0xfc000000) == 0xf8000000) | |
1124 | + offset = oprval(memory.id, 2); | |
1125 | + | |
1126 | + if (li == 0) | |
1127 | + li = 4; | |
1128 | + dis->read_memory_func (addr + oplen() + offset, | |
1129 | + ibuf, li, dis); | |
1130 | + switch (li) { | |
1131 | + case 1: | |
1132 | + val = (signed char)ibuf[0]; | |
1133 | + break; | |
1134 | + case 2: | |
1135 | + val = (signed short)(ibuf[0] | ibuf[1] << 8); | |
1136 | + break; | |
1137 | + case 3: | |
1138 | + val = ibuf[0] | ibuf[1] << 8 | ibuf[2] << 16; | |
1139 | + /* sign extended */ | |
1140 | + val <<= 8; | |
1141 | + val >>= 8; | |
1142 | + break; | |
1143 | + case 4: | |
1144 | + val = ibuf[0] | ibuf[1] << 8 | ibuf[2] << 16 | ibuf[3] << 24; | |
1145 | + break; | |
1146 | + } | |
1147 | + append += li; | |
1148 | + if (abs(val) < 256) | |
1149 | + prt("#%d", val); | |
1150 | + else | |
1151 | + prt("#0x%08x", val); | |
1152 | + break; | |
1153 | + } | |
1154 | + case float32: { | |
1155 | + float f; | |
1156 | + dis->read_memory_func (addr + oplen() + append, | |
1157 | + (bfd_byte *)&f, 4, dis); | |
1158 | + append += 4; | |
1159 | + prt("#%f", f); | |
1160 | + break; | |
1161 | + } | |
1162 | + case incdec: | |
1163 | + if (oprval(incdec.incdec, 1) & 1) | |
1164 | + prt("[-r%d]", oprval(incdec.reg, 4)); | |
1165 | + else | |
1166 | + prt("[r%d+]", oprval(incdec.reg, 4)); | |
1167 | + break; | |
1168 | + case ind: | |
1169 | + prt("[r%d,r%d]", oprval(ind.offset, 4), oprval(ind.base, 4)); | |
1170 | + break; | |
1171 | + case creg: | |
1172 | + prt("%s", creg_name[oprval(creg.creg, 4)]); | |
1173 | + break; | |
1174 | + case pcdsp: | |
1175 | + val = oprval(pcdsp.pos, opr(pcdsp, sz)); | |
1176 | + switch (opr(pcdsp, sz)) { | |
1177 | + case 3: | |
1178 | + if (val < 3) | |
1179 | + val += 8; | |
1180 | + break; | |
1181 | + case 8: | |
1182 | + if (val >= 0x80) | |
1183 | + val = -(~val & 0xff) - 1; | |
1184 | + break; | |
1185 | + case 16: | |
1186 | + val = ((val >> 8) & 0xff) | (val << 8); | |
1187 | + val &= 0xffff; | |
1188 | + if (val >= 0x8000) | |
1189 | + val = -(~val & 0xffff) - 1; | |
1190 | + break; | |
1191 | + case 24: | |
1192 | + val = ((val >> 16) & 0xff) | (val << 16) | (val & 0x00ff00); | |
1193 | + val &= 0xffffff; | |
1194 | + if (val >= 0x800000) | |
1195 | + val = -(~val & 0xffffff) - 1; | |
1196 | + break; | |
1197 | + } | |
1198 | + dis->print_address_func (addr + val, dis); | |
1199 | + break; | |
1200 | + case memory: { | |
1201 | + int id = oprval(memory.id, 2); | |
1202 | + int mi = NONE; | |
1203 | + int offset = append; | |
1204 | + | |
1205 | + /* special case | |
1206 | + "mov #imm, dsp[rd]" is destination first */ | |
1207 | + if ((op & 0xfc000000) == 0xf8000000) | |
1208 | + offset = 0; | |
1209 | + | |
1210 | + if (opr(memory, mi) >= 0) { | |
1211 | + mi = oprval(memory.mi, 2); | |
1212 | + scale = mi; | |
1213 | + } | |
1214 | + | |
1215 | + switch (id) { | |
1216 | + case 0: | |
1217 | + prt("[r%d]", oprval(memory.reg, 4)); | |
1218 | + break; | |
1219 | + case 1 ... 2: | |
1220 | + memdisp(offset, oprval(memory.reg, 4)); | |
1221 | + break; | |
1222 | + case 3: | |
1223 | + prt("r%d", oprval(memory.reg, 4)); | |
1224 | + break; | |
1225 | + } | |
1226 | + if (id < 3 && mi >= 0) | |
1227 | + prt(".%s", memex[mi]); | |
1228 | + break; | |
1229 | + } | |
1230 | + case dsp5: | |
1231 | + val = oprval(dsp5.offset1, opr(dsp5, offset1w)); | |
1232 | + val |= oprval(dsp5.offset2, (5 - opr(dsp5, offset1w))); | |
1233 | + prt("%d[r%d]", val, oprval(memory.reg, 4)); | |
1234 | + break; | |
1235 | + case regub: { | |
1236 | + int id = oprval(regub.id, 2); | |
1237 | + switch (id) { | |
1238 | + case 0: | |
1239 | + prt("[r%d].ub", oprval(regub.reg, 4)); | |
1240 | + break; | |
1241 | + case 1 ... 2: | |
1242 | + memdisp(append, oprval(regub.reg, 4)); | |
1243 | + prt(".ub"); | |
1244 | + append += id; | |
1245 | + break; | |
1246 | + case 3: | |
1247 | + prt("r%d", oprval(regub.reg, 4)); | |
1248 | + break; | |
1249 | + } | |
1250 | + break; | |
1251 | + } | |
1252 | + case psw: | |
1253 | + prt("%s", psw_bit[oprval(psw.b, 4)]); | |
1254 | + break; | |
1255 | + case reg: | |
1256 | + prt("r%d", oprval(reg.r, 4)); | |
1257 | + break; | |
1258 | + case reg8: | |
1259 | + prt("r%d", oprval(reg8.r, 3)); | |
1260 | + break; | |
1261 | + case range: | |
1262 | + prt("r%d-r%d", oprval(range.start,4), oprval(range.end, 4)); | |
1263 | + break; | |
1264 | + | |
1265 | + } | |
1266 | + } | |
1267 | + return oplen() + append; | |
1268 | +} |
@@ -228,6 +228,10 @@ enum bfd_architecture | ||
228 | 228 | #define bfd_mach_nios2r2 2 |
229 | 229 | bfd_arch_lm32, /* Lattice Mico32 */ |
230 | 230 | #define bfd_mach_lm32 1 |
231 | + bfd_arch_rx, /* Renesas RX */ | |
232 | +#define bfd_mach_rx 0x75 | |
233 | +#define bfd_mach_rx_v2 0x76 | |
234 | +#define bfd_mach_rx_v3 0x77 | |
231 | 235 | bfd_arch_last |
232 | 236 | }; |
233 | 237 | #define bfd_mach_s390_31 31 |
@@ -432,6 +436,7 @@ int print_insn_little_nios2 (bfd_vma, disassemble_info*); | ||
432 | 436 | int print_insn_xtensa (bfd_vma, disassemble_info*); |
433 | 437 | int print_insn_riscv32 (bfd_vma, disassemble_info*); |
434 | 438 | int print_insn_riscv64 (bfd_vma, disassemble_info*); |
439 | +int print_insn_rx (bfd_vma, disassemble_info*); | |
435 | 440 | |
436 | 441 | #if 0 |
437 | 442 | /* Fetch the disassembler for a given BFD, if that support is available. */ |
@@ -140,6 +140,11 @@ static void rxcpu_set_irq(void *opaque, int no, int request) | ||
140 | 140 | cpu_reset_interrupt(cs, mask[no]); |
141 | 141 | } |
142 | 142 | |
143 | +static void rx_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) | |
144 | +{ | |
145 | + info->mach = bfd_mach_rx; | |
146 | + info->print_insn = print_insn_rx; | |
147 | +} | |
143 | 148 | |
144 | 149 | static void rx_cpu_init(Object *obj) |
145 | 150 | { |
@@ -173,7 +178,7 @@ static void rxcpu_class_init(ObjectClass *klass, void *data) | ||
173 | 178 | cc->gdb_read_register = rx_cpu_gdb_read_register; |
174 | 179 | cc->gdb_write_register = rx_cpu_gdb_write_register; |
175 | 180 | cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; |
176 | - /*cc->disas_set_info = rx_cpu_disas_set_info;*/ | |
181 | + cc->disas_set_info = rx_cpu_disas_set_info; | |
177 | 182 | cc->tcg_initialize = rx_translate_init; |
178 | 183 | |
179 | 184 | cc->gdb_num_core_regs = 26; |