Fix typos in last change
[deliverable/binutils-gdb.git] / opcodes / h8300-dis.c
CommitLineData
252b5132 1/* Disassemble h8300 instructions.
20dc5b5a 2 Copyright 1993, 1994, 1996, 1998, 2000, 2001, 2002, 2003
56da5fed 3 Free Software Foundation, Inc.
252b5132
RH
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19#define DEFINE_TABLE
20
0d8dfecf 21#include "sysdep.h"
252b5132
RH
22#define h8_opcodes h8ops
23#include "opcode/h8300.h"
24#include "dis-asm.h"
25#include "opintl.h"
a3e64b75
KD
26#include "libiberty.h"
27
28struct h8_instruction
29{
30 int length;
31 const struct h8_opcode *opcode;
32};
33
34struct h8_instruction *h8_instructions;
252b5132 35
d83c6548 36static void bfd_h8_disassemble_init PARAMS ((void));
20dc5b5a
MS
37static void print_one_arg PARAMS ((disassemble_info *, bfd_vma, op_type,
38 int, int, int, int, const char **, int));
39static unsigned int bfd_h8_disassemble PARAMS ((bfd_vma,
40 disassemble_info *,
41 int));
42static void extract_immediate PARAMS ((FILE *,
43 op_type, int,
44 unsigned char *,
45 int *, int *,
46 const struct h8_opcode *));
47
48static void print_colon_thingie PARAMS ((op_type *));
49
50static void
51print_colon_thingie (op_type *nib)
52{
53 switch (*nib & SIZE) {
54 case L_2: fprintf (stdout, "2"); break;
55 case L_3:
56 case L_3NZ: fprintf (stdout, "3"); break;
57 case L_4: fprintf (stdout, "4"); break;
58 case L_5: fprintf (stdout, "5"); break;
59 case L_8: fprintf (stdout, "8"); break;
60 case L_16:
61 case L_16U: fprintf (stdout, "16"); break;
62 case L_24: fprintf (stdout, "24"); break;
63 case L_32: fprintf (stdout, "32"); break;
64 }
65}
d83c6548 66
252b5132 67/* Run through the opcodes and sort them into order to make them easy
3903e627 68 to disassemble. */
20dc5b5a 69
252b5132
RH
70static void
71bfd_h8_disassemble_init ()
72{
73 unsigned int i;
a3e64b75
KD
74 unsigned int nopcodes;
75 const struct h8_opcode *p;
76 struct h8_instruction *pi;
252b5132 77
a3e64b75 78 nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
b34976b6 79
a3e64b75
KD
80 h8_instructions = (struct h8_instruction *)
81 xmalloc (nopcodes * sizeof (struct h8_instruction));
82
83 for (p = h8_opcodes, pi = h8_instructions; p->name; p++, pi++)
252b5132
RH
84 {
85 int n1 = 0;
86 int n2 = 0;
87
88 if ((int) p->data.nib[0] < 16)
5fec0fc5 89 n1 = (int) p->data.nib[0];
252b5132
RH
90 else
91 n1 = 0;
53d388d1 92
252b5132 93 if ((int) p->data.nib[1] < 16)
5fec0fc5 94 n2 = (int) p->data.nib[1];
252b5132
RH
95 else
96 n2 = 0;
97
98 /* Just make sure there are an even number of nibbles in it, and
3903e627 99 that the count is the same as the length. */
20dc5b5a 100 for (i = 0; p->data.nib[i] != (op_type) E; i++)
53d388d1
JL
101 ;
102
252b5132 103 if (i & 1)
20dc5b5a
MS
104 {
105 fprintf (stderr, "Internal error, h8_disassemble_init.\n");
106 abort ();
107 }
53d388d1 108
a3e64b75
KD
109 pi->length = i / 2;
110 pi->opcode = p;
252b5132 111 }
a3e64b75
KD
112
113 /* Add entry for the NULL vector terminator. */
114 pi->length = 0;
115 pi->opcode = p;
252b5132
RH
116}
117
20dc5b5a
MS
118static void
119extract_immediate (stream, looking_for, thisnib, data, cst, len, q)
120 FILE *stream;
121 op_type looking_for;
122 int thisnib;
123 unsigned char *data;
124 int *cst, *len;
125 const struct h8_opcode *q;
126{
127 switch (looking_for & SIZE)
128 {
129 case L_2:
130 *len = 2;
131 *cst = thisnib & 3;
132
133 /* DISP2 special treatment. */
134 if ((looking_for & MODE) == DISP)
135 {
136 if (OP_KIND (q->how) == O_MOVAB ||
137 OP_KIND (q->how) == O_MOVAW ||
138 OP_KIND (q->how) == O_MOVAL)
139 {
140 /* Handling for mova insn. */
141 switch (q->args.nib[0] & MODE) {
142 case INDEXB:
143 default:
144 break;
145 case INDEXW:
146 *cst *= 2;
147 break;
148 case INDEXL:
149 *cst *= 4;
150 break;
151 }
152 }
153 else
154 {
155 /* Handling for non-mova insn. */
156 switch (OP_SIZE (q->how)) {
157 default: break;
158 case SW:
159 *cst *= 2;
160 break;
161 case SL:
162 *cst *= 4;
163 break;
164 }
165 }
166 }
167 break;
168 case L_8:
169 *len = 8;
170 *cst = data[0];
171 break;
172 case L_16:
173 case L_16U:
174 *len = 16;
175 *cst = (data[0] << 8) + data [1];
176#if 0
177 if ((looking_for & SIZE) == L_16)
178 *cst = (short) *cst; /* sign extend */
179#endif
180 break;
181 case L_32:
182 *len = 32;
183 *cst = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
184 break;
185 default:
186 *len = 0;
187 *cst = 0;
188 fprintf (stream, "DISP bad size\n");
189 break;
190 }
191}
192
193static const char *regnames[] =
194{
195 "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
196 "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"
197};
198static const char *wregnames[] =
199{
200 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
201 "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7"
202};
203static const char *lregnames[] =
204{
205 "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7",
206 "er0", "er1", "er2", "er3", "er4", "er5", "er6", "er7"
207};
208static const char *cregnames[] =
209{
210 "ccr", "exr", "mach", "macl", "", "", "vbr", "sbr"
211};
212
213static void
214print_one_arg (info, addr, x, cst, cstlen, rdisp_n, rn, pregnames, len)
252b5132 215 disassemble_info *info;
20dc5b5a
MS
216 bfd_vma addr;
217 op_type x;
218 int cst, cstlen, rdisp_n, rn;
219 const char **pregnames;
220 int len;
252b5132 221{
20dc5b5a
MS
222 void *stream = info->stream;
223 fprintf_ftype outfn = info->fprintf_func;
224
225 if ((x & SIZE) == L_3 ||
226 (x & SIZE) == L_3NZ)
227 {
228 outfn (stream, "#0x%x", (unsigned) cst);
229 }
230 else if ((x & MODE) == IMM)
231 {
232 outfn (stream, "#0x%x", (unsigned) cst);
233 }
234 else if ((x & MODE) == DBIT ||
235 (x & MODE) == KBIT)
236 {
237 outfn (stream, "#%d", (unsigned) cst);
238 }
239 else if ((x & MODE) == CONST_2)
240 outfn (stream, "#2");
241 else if ((x & MODE) == CONST_4)
242 outfn (stream, "#4");
243 else if ((x & MODE) == CONST_8)
244 outfn (stream, "#8");
245 else if ((x & MODE) == CONST_16)
246 outfn (stream, "#16");
247 else if ((x & MODE) == REG)
248 {
249 switch (x & SIZE)
250 {
251 case L_8:
252 outfn (stream, "%s", regnames[rn]);
253 break;
254 case L_16:
255 case L_16U:
256 outfn (stream, "%s", wregnames[rn]);
257 break;
258 case L_P:
259 case L_32:
260 outfn (stream, "%s", lregnames[rn]);
261 break;
262 }
263 }
264 else if ((x & MODE) == LOWREG)
265 {
266 switch (x & SIZE)
267 {
268 case L_8:
269 /* Always take low half of reg. */
270 outfn (stream, "%s.b", regnames[rn < 8 ? rn + 8 : rn]);
271 break;
272 case L_16:
273 case L_16U:
274 /* Always take low half of reg. */
275 outfn (stream, "%s.w", wregnames[rn < 8 ? rn : rn - 8]);
276 break;
277 case L_P:
278 case L_32:
279 outfn (stream, "%s.l", lregnames[rn]);
280 break;
281 }
282 }
283 else if ((x & MODE) == POSTINC)
284 {
285 outfn (stream, "@%s+", pregnames[rn]);
286 }
287 else if ((x & MODE) == POSTDEC)
288 {
289 outfn (stream, "@%s-", pregnames[rn]);
290 }
291 else if ((x & MODE) == PREINC)
292 {
293 outfn (stream, "@+%s", pregnames[rn]);
294 }
295 else if ((x & MODE) == PREDEC)
296 {
297 outfn (stream, "@-%s", pregnames[rn]);
298 }
299 else if ((x & MODE) == IND)
300 {
301 outfn (stream, "@%s", pregnames[rn]);
302 }
303 else if ((x & MODE) == ABS || (x & ABSJMP))
304 {
305 outfn (stream, "@0x%x:%d", (unsigned) cst, cstlen);
306 }
307 else if ((x & MODE) == MEMIND)
308 {
309 outfn (stream, "@@%d (0x%x)", cst, cst);
310 }
311 else if ((x & MODE) == VECIND)
312 {
313 /* FIXME Multiplier should be 2 or 4, depending on processor mode,
314 by which is meant "normal" vs. "middle", "advanced", "maximum". */
315
316 int offset = (cst + 0x80) * 4;
317 outfn (stream, "@@%d (0x%x)", offset, offset);
318 }
319 else if ((x & MODE) == PCREL)
320 {
321 if ((x & SIZE) == L_16 ||
322 (x & SIZE) == L_16U)
323 {
324 outfn (stream, ".%s%d (0x%x)",
325 (short) cst > 0 ? "+" : "",
326 (short) cst,
327 addr + (short) cst + len);
328 }
329 else
330 {
331 outfn (stream, ".%s%d (0x%x)",
332 (char) cst > 0 ? "+" : "",
333 (char) cst,
334 addr + (char) cst + len);
335 }
336 }
337 else if ((x & MODE) == DISP)
338 {
339 outfn (stream, "@(0x%x:%d,%s)", cst, cstlen,
340 pregnames[rdisp_n]);
341 }
342 else if ((x & MODE) == INDEXB)
343 {
344 /* Always take low half of reg. */
345 outfn (stream, "@(0x%x:%d,%s.b)", cst, cstlen,
346 regnames[rdisp_n < 8 ? rdisp_n + 8 : rdisp_n]);
347 }
348 else if ((x & MODE) == INDEXW)
252b5132 349 {
20dc5b5a
MS
350 /* Always take low half of reg. */
351 outfn (stream, "@(0x%x:%d,%s.w)", cst, cstlen,
352 wregnames[rdisp_n < 8 ? rdisp_n : rdisp_n - 8]);
353 }
354 else if ((x & MODE) == INDEXL)
252b5132 355 {
20dc5b5a
MS
356 outfn (stream, "@(0x%x:%d,%s.l)", cst, cstlen,
357 lregnames[rdisp_n]);
358 }
359 else if (x & CTRL)
252b5132 360 {
20dc5b5a
MS
361 outfn (stream, cregnames[rn]);
362 }
363 else if ((x & MODE) == CCR)
364 {
365 outfn (stream, "ccr");
366 }
367 else if ((x & MODE) == EXR)
368 {
369 outfn (stream, "exr");
370 }
371 else if ((x & MODE) == MACREG)
372 {
373 outfn (stream, "mac%c", cst ? 'l' : 'h');
374 }
375 else
376 /* xgettext:c-format */
377 outfn (stream, _("Hmmmm 0x%x"), x);
378}
379
380static unsigned int
381bfd_h8_disassemble (addr, info, mach)
382 bfd_vma addr;
383 disassemble_info *info;
384 int mach;
385{
386 /* Find the first entry in the table for this opcode. */
387 int regno[3] = { 0, 0, 0 };
388 int dispregno[3] = { 0, 0, 0 };
389 int cst[3] = { 0, 0, 0 };
390 int cstlen[3] = { 0, 0, 0 };
b34976b6 391 static bfd_boolean init = 0;
a3e64b75 392 const struct h8_instruction *qi;
20dc5b5a 393 char const **pregnames = mach != 0 ? lregnames : wregnames;
252b5132 394 int status;
20dc5b5a
MS
395 unsigned int l;
396 unsigned char data[MAX_CODE_NIBBLES];
252b5132 397 void *stream = info->stream;
20dc5b5a 398 fprintf_ftype outfn = info->fprintf_func;
252b5132
RH
399
400 if (!init)
401 {
402 bfd_h8_disassemble_init ();
403 init = 1;
404 }
405
3903e627 406 status = info->read_memory_func (addr, data, 2, info);
5fec0fc5 407 if (status != 0)
252b5132 408 {
3903e627 409 info->memory_error_func (status, addr, info);
252b5132
RH
410 return -1;
411 }
53d388d1 412
20dc5b5a 413 for (l = 2; status == 0 && l < sizeof (data) / 2; l += 2)
53d388d1 414 status = info->read_memory_func (addr + l, data + l, 2, info);
252b5132 415
3903e627 416 /* Find the exact opcode/arg combo. */
a3e64b75 417 for (qi = h8_instructions; qi->opcode->name; qi++)
252b5132 418 {
a3e64b75 419 const struct h8_opcode *q = qi->opcode;
c07ab2ec 420 op_type *nib = q->data.nib;
252b5132
RH
421 unsigned int len = 0;
422
252b5132
RH
423 while (1)
424 {
425 op_type looking_for = *nib;
20dc5b5a
MS
426 int thisnib = data[len / 2];
427 int opnr;
53d388d1 428
20dc5b5a
MS
429 thisnib = (len & 1) ? (thisnib & 0xf) : ((thisnib / 16) & 0xf);
430 opnr = ((looking_for & OP3) == OP3 ? 2
431 : (looking_for & DST) == DST ? 1 : 0);
53d388d1 432
5fec0fc5 433 if (looking_for < 16 && looking_for >= 0)
252b5132 434 {
5fec0fc5 435 if (looking_for != thisnib)
252b5132
RH
436 goto fail;
437 }
5fec0fc5 438 else
252b5132 439 {
252b5132
RH
440 if ((int) looking_for & (int) B31)
441 {
20dc5b5a 442 if (!((thisnib & 0x8) != 0))
252b5132 443 goto fail;
53d388d1 444
252b5132 445 looking_for = (op_type) ((int) looking_for & ~(int) B31);
20dc5b5a 446 thisnib &= 0x7;
252b5132 447 }
20dc5b5a 448 else if ((int) looking_for & (int) B30)
252b5132 449 {
20dc5b5a 450 if (!((thisnib & 0x8) == 0))
252b5132 451 goto fail;
53d388d1 452
252b5132
RH
453 looking_for = (op_type) ((int) looking_for & ~(int) B30);
454 }
455
20dc5b5a
MS
456 if ((int) looking_for & (int) B21)
457 {
458 if (!((thisnib & 0x4) != 0))
459 goto fail;
460
461 looking_for = (op_type) ((int) looking_for & ~(int) B21);
462 thisnib &= 0xb;
463 }
464 else if ((int) looking_for & (int) B20)
465 {
466 if (!((thisnib & 0x4) == 0))
467 goto fail;
468
469 looking_for = (op_type) ((int) looking_for & ~(int) B20);
470 }
471 if ((int) looking_for & (int) B11)
472 {
473 if (!((thisnib & 0x2) != 0))
474 goto fail;
475
476 looking_for = (op_type) ((int) looking_for & ~(int) B11);
477 thisnib &= 0xd;
478 }
479 else if ((int) looking_for & (int) B10)
480 {
481 if (!((thisnib & 0x2) == 0))
482 goto fail;
483
484 looking_for = (op_type) ((int) looking_for & ~(int) B10);
485 }
486
487 if ((int) looking_for & (int) B01)
488 {
489 if (!((thisnib & 0x1) != 0))
490 goto fail;
491
492 looking_for = (op_type) ((int) looking_for & ~(int) B01);
493 thisnib &= 0xe;
494 }
495 else if ((int) looking_for & (int) B00)
496 {
497 if (!((thisnib & 0x1) == 0))
498 goto fail;
499
500 looking_for = (op_type) ((int) looking_for & ~(int) B00);
501 }
502
503 if (looking_for & IGNORE)
504 {
505 /* Hitachi has declared that IGNORE must be zero. */
506 if (thisnib != 0)
507 goto fail;
508 }
509 else if ((looking_for & MODE) == DATA)
510 {
511 ; /* Skip embedded data. */
512 }
513 else if ((looking_for & MODE) == DBIT)
252b5132 514 {
53d388d1
JL
515 /* Exclude adds/subs by looking at bit 0 and 2, and
516 make sure the operand size, either w or l,
517 matches by looking at bit 1. */
518 if ((looking_for & 7) != (thisnib & 7))
3903e627 519 goto fail;
53d388d1 520
20dc5b5a 521 cst[opnr] = (thisnib & 0x8) ? 2 : 1;
5fec0fc5 522 }
20dc5b5a
MS
523 else if ((looking_for & MODE) == DISP ||
524 (looking_for & MODE) == ABS ||
525 (looking_for & MODE) == PCREL ||
526 (looking_for & MODE) == INDEXB ||
527 (looking_for & MODE) == INDEXW ||
528 (looking_for & MODE) == INDEXL)
252b5132 529 {
20dc5b5a
MS
530 extract_immediate (stream, looking_for, thisnib,
531 data + len / 2, cst + opnr,
532 cstlen + opnr, q);
533 /* Even address == bra, odd == bra/s. */
534 if (q->how == O (O_BRAS, SB))
535 cst[opnr] -= 1;
252b5132 536 }
20dc5b5a
MS
537 else if ((looking_for & MODE) == REG ||
538 (looking_for & MODE) == LOWREG ||
539 (looking_for & MODE) == IND ||
540 (looking_for & MODE) == PREINC ||
541 (looking_for & MODE) == POSTINC ||
542 (looking_for & MODE) == PREDEC ||
543 (looking_for & MODE) == POSTDEC)
252b5132 544 {
20dc5b5a 545 regno[opnr] = thisnib;
252b5132 546 }
20dc5b5a 547 else if (looking_for & CTRL) /* Control Register */
252b5132 548 {
20dc5b5a
MS
549 thisnib &= 7;
550 if (((looking_for & MODE) == CCR && (thisnib != C_CCR)) ||
551 ((looking_for & MODE) == EXR && (thisnib != C_EXR)) ||
552 ((looking_for & MODE) == MACH && (thisnib != C_MACH)) ||
553 ((looking_for & MODE) == MACL && (thisnib != C_MACL)) ||
554 ((looking_for & MODE) == VBR && (thisnib != C_VBR)) ||
555 ((looking_for & MODE) == SBR && (thisnib != C_SBR)))
556 goto fail;
557 if (((looking_for & MODE) == CCR_EXR &&
558 (thisnib != C_CCR && thisnib != C_EXR)) ||
559 ((looking_for & MODE) == VBR_SBR &&
560 (thisnib != C_VBR && thisnib != C_SBR)) ||
561 ((looking_for & MODE) == MACREG &&
562 (thisnib != C_MACH && thisnib != C_MACL)))
563 goto fail;
564 if (((looking_for & MODE) == CC_EX_VB_SB &&
565 (thisnib != C_CCR && thisnib != C_EXR &&
566 thisnib != C_VBR && thisnib != C_SBR)))
567 goto fail;
568
569 regno[opnr] = thisnib;
570 }
571 else if ((looking_for & SIZE) == L_5)
572 {
573 cst[opnr] = data[len / 2] & 31;
574 cstlen[opnr] = 5;
575 }
576 else if ((looking_for & SIZE) == L_4)
577 {
578 cst[opnr] = thisnib;
579 cstlen[opnr] = 4;
580 }
581 else if ((looking_for & SIZE) == L_16 ||
582 (looking_for & SIZE) == L_16U)
583 {
584 cst[opnr] = (data[len / 2]) * 256 + data[(len + 2) / 2];
585 cstlen[opnr] = 16;
586 }
587 else if ((looking_for & MODE) == MEMIND)
588 {
589 cst[opnr] = data[1];
252b5132 590 }
20dc5b5a 591 else if ((looking_for & MODE) == VECIND)
252b5132 592 {
20dc5b5a 593 cst[opnr] = data[1] & 0x7f;
252b5132 594 }
20dc5b5a 595 else if ((looking_for & SIZE) == L_32)
252b5132 596 {
20dc5b5a 597 int i = len / 2;
53d388d1 598
20dc5b5a
MS
599 cst[opnr] = ((data[i] << 24)
600 | (data[i + 1] << 16)
601 | (data[i + 2] << 8)
602 | (data[i + 3]));
252b5132 603
20dc5b5a 604 cstlen[opnr] = 32;
252b5132 605 }
20dc5b5a 606 else if ((looking_for & SIZE) == L_24)
252b5132 607 {
20dc5b5a 608 int i = len / 2;
53d388d1 609
20dc5b5a
MS
610 cst[opnr] =
611 (data[i] << 16) | (data[i + 1] << 8) | (data[i + 2]);
612 cstlen[opnr] = 24;
252b5132
RH
613 }
614 else if (looking_for & IGNORE)
615 {
3903e627 616 ;
252b5132
RH
617 }
618 else if (looking_for & DISPREG)
619 {
20dc5b5a 620 dispregno[opnr] = thisnib & 7;
252b5132 621 }
20dc5b5a 622 else if ((looking_for & MODE) == KBIT)
252b5132 623 {
5fec0fc5 624 switch (thisnib)
252b5132
RH
625 {
626 case 9:
20dc5b5a 627 cst[opnr] = 4;
252b5132
RH
628 break;
629 case 8:
20dc5b5a 630 cst[opnr] = 2;
252b5132
RH
631 break;
632 case 0:
20dc5b5a 633 cst[opnr] = 1;
252b5132
RH
634 break;
635 default:
636 goto fail;
637 }
638 }
20dc5b5a 639 else if ((looking_for & SIZE) == L_8)
252b5132 640 {
20dc5b5a
MS
641 cstlen[opnr] = 8;
642 cst[opnr] = data[len / 2];
252b5132 643 }
20dc5b5a
MS
644 else if ((looking_for & SIZE) == L_3 ||
645 (looking_for & SIZE) == L_3NZ)
252b5132 646 {
20dc5b5a
MS
647 cst[opnr] = thisnib & 0x7;
648 if (cst[opnr] == 0 && (looking_for & SIZE) == L_3NZ)
649 goto fail;
252b5132 650 }
20dc5b5a 651 else if ((looking_for & SIZE) == L_2)
252b5132 652 {
20dc5b5a
MS
653 cstlen[opnr] = 2;
654 cst[opnr] = thisnib & 0x3;
252b5132 655 }
20dc5b5a 656 else if ((looking_for & MODE) == MACREG)
252b5132 657 {
20dc5b5a 658 cst[opnr] = (thisnib == 3);
252b5132 659 }
20dc5b5a 660 else if (looking_for == (op_type) E)
252b5132 661 {
3903e627 662 int i;
252b5132 663
a3e64b75 664 for (i = 0; i < qi->length; i++)
20dc5b5a 665 outfn (stream, "%02x ", data[i]);
53d388d1 666
3903e627 667 for (; i < 6; i++)
20dc5b5a 668 outfn (stream, " ");
53d388d1 669
20dc5b5a 670 outfn (stream, "%s\t", q->name);
252b5132
RH
671
672 /* Gross. Disgusting. */
673 if (strcmp (q->name, "ldm.l") == 0)
674 {
675 int count, high;
676
20dc5b5a
MS
677 count = (data[1] / 16) & 0x3;
678 high = regno[1];
252b5132 679
20dc5b5a 680 outfn (stream, "@sp+,er%d-er%d", high - count, high);
a3e64b75 681 return qi->length;
252b5132
RH
682 }
683
684 if (strcmp (q->name, "stm.l") == 0)
685 {
686 int count, low;
687
20dc5b5a
MS
688 count = (data[1] / 16) & 0x3;
689 low = regno[0];
252b5132 690
20dc5b5a
MS
691 outfn (stream, "er%d-er%d,@-sp", low, low + count);
692 return qi->length;
693 }
694 if (strcmp (q->name, "rte/l") == 0
695 || strcmp (q->name, "rts/l") == 0)
696 {
697 if (regno[0] == 0)
698 outfn (stream, "er%d", regno[1]);
699 else
700 {
0613284f 701 outfn (stream, "er%d-er%d", regno[1] - regno[0],
20dc5b5a
MS
702 regno[1]);
703 }
704 return qi->length;
705 }
706 if (strncmp (q->name, "mova", 4) == 0)
707 {
708 op_type *args = q->args.nib;
709
710 if (args[1] == (op_type) E)
711 {
712 /* Short form. */
713 print_one_arg (info, addr, args[0], cst[0],
714 cstlen[0], dispregno[0], regno[0],
715 pregnames, qi->length);
716 outfn (stream, ",er%d", dispregno[0]);
717 }
718 else
719 {
720 outfn (stream, "@(0x%x:%d,", cst[0], cstlen[0]);
721 print_one_arg (info, addr, args[1], cst[1],
722 cstlen[1], dispregno[1], regno[1],
723 pregnames, qi->length);
724 outfn (stream, ".%c),",
725 (args[0] & MODE) == INDEXB ? 'b' : 'w');
726 print_one_arg (info, addr, args[2], cst[2],
727 cstlen[2], dispregno[2], regno[2],
728 pregnames, qi->length);
729 }
a3e64b75 730 return qi->length;
252b5132 731 }
3903e627 732 /* Fill in the args. */
252b5132
RH
733 {
734 op_type *args = q->args.nib;
735 int hadone = 0;
20dc5b5a 736 int nargs;
252b5132 737
20dc5b5a
MS
738 for (nargs = 0;
739 nargs < 3 && args[nargs] != (op_type) E;
740 nargs++)
252b5132 741 {
20dc5b5a 742 int x = args[nargs];
53d388d1 743
252b5132 744 if (hadone)
20dc5b5a
MS
745 outfn (stream, ",");
746
747 print_one_arg (info, addr, x,
748 cst[nargs], cstlen[nargs],
749 dispregno[nargs], regno[nargs],
750 pregnames, qi->length);
53d388d1 751
252b5132 752 hadone = 1;
252b5132
RH
753 }
754 }
53d388d1 755
a3e64b75 756 return qi->length;
252b5132 757 }
252b5132 758 else
5fec0fc5 759 /* xgettext:c-format */
20dc5b5a 760 outfn (stream, _("Don't understand 0x%x \n"), looking_for);
252b5132 761 }
53d388d1 762
252b5132
RH
763 len++;
764 nib++;
765 }
53d388d1 766
252b5132 767 fail:
c07ab2ec 768 ;
252b5132
RH
769 }
770
5fec0fc5 771 /* Fell off the end. */
20dc5b5a 772 outfn (stream, "%02x %02x .word\tH'%x,H'%x",
252b5132
RH
773 data[0], data[1],
774 data[0], data[1]);
775 return 2;
776}
777
5fec0fc5 778int
252b5132 779print_insn_h8300 (addr, info)
5fec0fc5 780 bfd_vma addr;
3903e627 781 disassemble_info *info;
252b5132 782{
5fec0fc5 783 return bfd_h8_disassemble (addr, info, 0);
252b5132
RH
784}
785
5fec0fc5 786int
252b5132 787print_insn_h8300h (addr, info)
3903e627
NC
788 bfd_vma addr;
789 disassemble_info *info;
252b5132 790{
5fec0fc5 791 return bfd_h8_disassemble (addr, info, 1);
252b5132
RH
792}
793
5fec0fc5 794int
252b5132 795print_insn_h8300s (addr, info)
3903e627
NC
796 bfd_vma addr;
797 disassemble_info *info;
252b5132 798{
5fec0fc5 799 return bfd_h8_disassemble (addr, info, 2);
252b5132 800}
This page took 0.222599 seconds and 4 git commands to generate.