* i386b-nat.c: Comment changes.
[deliverable/binutils-gdb.git] / gdb / m68k-pinsn.c
CommitLineData
7d9884b9 1/* Print Motorola 68k instructions for GDB, the GNU debugger.
8970a55e 2 Copyright 1986, 1987, 1989, 1991, 1992 Free Software Foundation, Inc.
dd3b648e
RP
3
4This file is part of GDB.
5
99a7de40 6This program is free software; you can redistribute it and/or modify
dd3b648e 7it under the terms of the GNU General Public License as published by
99a7de40
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
dd3b648e 10
99a7de40 11This program is distributed in the hope that it will be useful,
dd3b648e
RP
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
99a7de40
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
dd3b648e 19
dd3b648e 20#include "defs.h"
dd3b648e 21#include "symtab.h"
7e258d18 22#include "opcode/m68k.h"
dd3b648e 23#include "gdbcore.h"
8970a55e 24#include "ieee-float.h"
dd3b648e 25
1ab3bf1b
JG
26/* Local function prototypes */
27
28static int
29fetch_arg PARAMS ((unsigned char *, int, int));
30
31static void
32print_base PARAMS ((int, int, FILE *));
33
34static unsigned char *
35print_indexed PARAMS ((int, unsigned char *, CORE_ADDR, FILE *));
36
37static unsigned char *
38print_insn_arg PARAMS ((char *, unsigned char *, unsigned char *, CORE_ADDR,
39 FILE *));
40
dd3b648e
RP
41/* 68k instructions are never longer than this many bytes. */
42#define MAXLEN 22
43
44/* Number of elements in the opcode table. */
45#define NOPCODES (sizeof m68k_opcodes / sizeof m68k_opcodes[0])
46
609f87d4
JG
47const char * const fpcr_names[] = {
48 "", "fpiar", "fpsr", "fpiar/fpsr", "fpcr",
d6b38bfb 49 "fpiar/fpcr", "fpsr/fpcr", "fpiar/fpsr/fpcr"};
dd3b648e 50
8970a55e
JG
51/* Define accessors for 68K's 1, 2, and 4-byte signed quantities.
52 The _SHIFT values move the quantity to the high order end of an
53 `int' value, so it will sign-extend. Probably a few more casts
54 are needed to make it compile without warnings on finicky systems. */
55#define BITS_PER_BYTE 8
56#define BYTE_SHIFT (BITS_PER_BYTE * ((sizeof (int)) - 1))
57#define WORD_SHIFT (BITS_PER_BYTE * ((sizeof (int)) - 2))
58#define LONG_SHIFT (BITS_PER_BYTE * ((sizeof (int)) - 4))
dd3b648e 59
8970a55e 60#define NEXTBYTE(p) (p += 2, ((int)(p[-1]) << BYTE_SHIFT) >> BYTE_SHIFT)
dd3b648e
RP
61
62#define NEXTWORD(p) \
8970a55e 63 (p += 2, (((int)((p[-2] << 8) + p[-1])) << WORD_SHIFT) >> WORD_SHIFT)
dd3b648e
RP
64
65#define NEXTLONG(p) \
8970a55e
JG
66 (p += 4, (((int)((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1])) \
67 << LONG_SHIFT) >> LONG_SHIFT)
dd3b648e 68
8970a55e 69/* Ecch -- assumes host == target float formats. FIXME. */
dd3b648e
RP
70#define NEXTSINGLE(p) \
71 (p += 4, *((float *)(p - 4)))
72
73#define NEXTDOUBLE(p) \
74 (p += 8, *((double *)(p - 8)))
dd3b648e
RP
75\f
76/* Print the m68k instruction at address MEMADDR in debugged memory,
77 on STREAM. Returns length of the instruction, in bytes. */
78
79int
80print_insn (memaddr, stream)
81 CORE_ADDR memaddr;
82 FILE *stream;
83{
84 unsigned char buffer[MAXLEN];
85 register int i;
86 register unsigned char *p;
87 register char *d;
88 register int bestmask;
89 int best;
90
1ab3bf1b 91 read_memory (memaddr, (char *) buffer, MAXLEN);
dd3b648e
RP
92
93 bestmask = 0;
94 best = -1;
95 for (i = 0; i < NOPCODES; i++)
96 {
97 register unsigned int opcode = m68k_opcodes[i].opcode;
98 register unsigned int match = m68k_opcodes[i].match;
99 if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
100 && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
101 && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
102 && ((0xff & buffer[3] & match) == (0xff & opcode)))
103 {
104 /* Don't use for printout the variants of divul and divsl
105 that have the same register number in two places.
106 The more general variants will match instead. */
107 for (d = m68k_opcodes[i].args; *d; d += 2)
108 if (d[1] == 'D')
109 break;
110
111 /* Don't use for printout the variants of most floating
112 point coprocessor instructions which use the same
113 register number in two places, as above. */
114 if (*d == 0)
115 for (d = m68k_opcodes[i].args; *d; d += 2)
116 if (d[1] == 't')
117 break;
118
119 if (*d == 0 && match > bestmask)
120 {
121 best = i;
122 bestmask = match;
123 }
124 }
125 }
126
127 /* Handle undefined instructions. */
128 if (best < 0)
129 {
130 fprintf_filtered (stream, "0%o", (buffer[0] << 8) + buffer[1]);
131 return 2;
132 }
133
134 fprintf_filtered (stream, "%s", m68k_opcodes[best].name);
135
136 /* Point at first word of argument data,
137 and at descriptor for first argument. */
138 p = buffer + 2;
139
140 /* Why do this this way? -MelloN */
141 for (d = m68k_opcodes[best].args; *d; d += 2)
142 {
143 if (d[0] == '#')
144 {
145 if (d[1] == 'l' && p - buffer < 6)
146 p = buffer + 6;
147 else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' )
148 p = buffer + 4;
149 }
150 if (d[1] >= '1' && d[1] <= '3' && p - buffer < 4)
151 p = buffer + 4;
152 if (d[1] >= '4' && d[1] <= '6' && p - buffer < 6)
153 p = buffer + 6;
154 if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
155 p = buffer + 4;
156 }
157
158 d = m68k_opcodes[best].args;
159
160 if (*d)
161 fputs_filtered (" ", stream);
162
163 while (*d)
164 {
165 p = print_insn_arg (d, buffer, p, memaddr + p - buffer, stream);
166 d += 2;
167 if (*d && *(d - 2) != 'I' && *d != 'k')
168 fputs_filtered (",", stream);
169 }
170 return p - buffer;
171}
172
173static unsigned char *
174print_insn_arg (d, buffer, p, addr, stream)
175 char *d;
176 unsigned char *buffer;
177 register unsigned char *p;
178 CORE_ADDR addr; /* PC for this arg to be relative to */
179 FILE *stream;
180{
181 register int val;
182 register int place = d[1];
183 int regno;
2304d9a5 184 register const char *regname;
dd3b648e 185 register unsigned char *p1;
8970a55e 186 double flval;
dd3b648e
RP
187 int flt_p;
188
189 switch (*d)
190 {
8f61b5e4
ILT
191 case 'c': /* cache identifier */
192 {
193 static char *cacheFieldName[] = { "NOP", "dc", "ic", "bc" };
194 val = fetch_arg (buffer, place, 2);
195 fprintf_filtered (stream, cacheFieldName[val]);
196 break;
197 }
198
199 case 'a': /* address register indirect only. Cf. case '+'. */
200 {
201 fprintf_filtered (stream,
202 "%s@",
203 reg_names [fetch_arg (buffer, place, 3) + 8]);
204 break;
205 }
206
207 case '_': /* 32-bit absolute address for move16. */
208 {
209 val = NEXTLONG (p);
210 fprintf_filtered (stream, "@#");
211 print_address (val, stream);
212 break;
213 }
214
dd3b648e
RP
215 case 'C':
216 fprintf_filtered (stream, "ccr");
217 break;
218
219 case 'S':
220 fprintf_filtered (stream, "sr");
221 break;
222
223 case 'U':
224 fprintf_filtered (stream, "usp");
225 break;
226
227 case 'J':
228 {
229 static struct { char *name; int value; } names[]
230 = {{"sfc", 0x000}, {"dfc", 0x001}, {"cacr", 0x002},
8f61b5e4
ILT
231 {"tc", 0x003}, {"itt0",0x004}, {"itt1", 0x005},
232 {"dtt0",0x006}, {"dtt1",0x007},
dd3b648e 233 {"usp", 0x800}, {"vbr", 0x801}, {"caar", 0x802},
8f61b5e4
ILT
234 {"msp", 0x803}, {"isp", 0x804}, {"mmusr",0x805},
235 {"urp", 0x806}, {"srp", 0x807}};
dd3b648e
RP
236
237 val = fetch_arg (buffer, place, 12);
238 for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--)
239 if (names[regno].value == val)
240 {
241 fprintf_filtered (stream, names[regno].name);
242 break;
243 }
244 if (regno < 0)
245 fprintf_filtered (stream, "%d", val);
246 }
247 break;
248
249 case 'Q':
250 val = fetch_arg (buffer, place, 3);
251 /* 0 means 8, except for the bkpt instruction... */
252 if (val == 0 && d[1] != 's')
253 val = 8;
254 fprintf_filtered (stream, "#%d", val);
255 break;
256
257 case 'M':
258 val = fetch_arg (buffer, place, 8);
259 if (val & 0x80)
260 val = val - 0x100;
261 fprintf_filtered (stream, "#%d", val);
262 break;
263
264 case 'T':
265 val = fetch_arg (buffer, place, 4);
266 fprintf_filtered (stream, "#%d", val);
267 break;
268
269 case 'D':
270 fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 3)]);
271 break;
272
273 case 'A':
274 fprintf_filtered (stream, "%s",
275 reg_names[fetch_arg (buffer, place, 3) + 010]);
276 break;
277
278 case 'R':
279 fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 4)]);
280 break;
281
664cf438
ILT
282 case 'r':
283 fprintf_filtered (stream, "%s@", reg_names[fetch_arg (buffer, place, 4)]);
284 break;
285
dd3b648e
RP
286 case 'F':
287 fprintf_filtered (stream, "fp%d", fetch_arg (buffer, place, 3));
288 break;
289
290 case 'O':
291 val = fetch_arg (buffer, place, 6);
292 if (val & 0x20)
293 fprintf_filtered (stream, "%s", reg_names [val & 7]);
294 else
295 fprintf_filtered (stream, "%d", val);
296 break;
297
298 case '+':
299 fprintf_filtered (stream, "%s@+",
300 reg_names[fetch_arg (buffer, place, 3) + 8]);
301 break;
302
303 case '-':
304 fprintf_filtered (stream, "%s@-",
305 reg_names[fetch_arg (buffer, place, 3) + 8]);
306 break;
307
308 case 'k':
309 if (place == 'k')
310 fprintf_filtered (stream, "{%s}", reg_names[fetch_arg (buffer, place, 3)]);
311 else if (place == 'C')
312 {
313 val = fetch_arg (buffer, place, 7);
314 if ( val > 63 ) /* This is a signed constant. */
315 val -= 128;
316 fprintf_filtered (stream, "{#%d}", val);
317 }
318 else
319 error ("Invalid arg format in opcode table: \"%c%c\".",
320 *d, place);
321 break;
322
323 case '#':
324 case '^':
325 p1 = buffer + (*d == '#' ? 2 : 4);
326 if (place == 's')
327 val = fetch_arg (buffer, place, 4);
328 else if (place == 'C')
329 val = fetch_arg (buffer, place, 7);
330 else if (place == '8')
331 val = fetch_arg (buffer, place, 3);
332 else if (place == '3')
333 val = fetch_arg (buffer, place, 8);
334 else if (place == 'b')
335 val = NEXTBYTE (p1);
336 else if (place == 'w')
337 val = NEXTWORD (p1);
338 else if (place == 'l')
339 val = NEXTLONG (p1);
340 else
341 error ("Invalid arg format in opcode table: \"%c%c\".",
342 *d, place);
343 fprintf_filtered (stream, "#%d", val);
344 break;
345
346 case 'B':
347 if (place == 'b')
348 val = NEXTBYTE (p);
abefb1f1 349 else if (place == 'B')
8970a55e 350 val = NEXTBYTE (buffer); /* from the opcode word */
abefb1f1 351 else if (place == 'w' || place == 'W')
dd3b648e 352 val = NEXTWORD (p);
abefb1f1 353 else if (place == 'l' || place == 'L')
dd3b648e
RP
354 val = NEXTLONG (p);
355 else if (place == 'g')
356 {
8970a55e 357 val = NEXTBYTE (buffer);
dd3b648e
RP
358 if (val == 0)
359 val = NEXTWORD (p);
360 else if (val == -1)
361 val = NEXTLONG (p);
362 }
363 else if (place == 'c')
364 {
365 if (buffer[1] & 0x40) /* If bit six is one, long offset */
366 val = NEXTLONG (p);
367 else
368 val = NEXTWORD (p);
369 }
370 else
371 error ("Invalid arg format in opcode table: \"%c%c\".",
372 *d, place);
373
374 print_address (addr + val, stream);
375 break;
376
377 case 'd':
378 val = NEXTWORD (p);
379 fprintf_filtered (stream, "%s@(%d)",
380 reg_names[fetch_arg (buffer, place, 3)], val);
381 break;
382
383 case 's':
384 fprintf_filtered (stream, "%s",
385 fpcr_names[fetch_arg (buffer, place, 3)]);
386 break;
387
388 case 'I':
389 val = fetch_arg (buffer, 'd', 3); /* Get coprocessor ID... */
390 if (val != 1) /* Unusual coprocessor ID? */
391 fprintf_filtered (stream, "(cpid=%d) ", val);
392 if (place == 'i')
393 p += 2; /* Skip coprocessor extended operands */
394 break;
395
396 case '*':
397 case '~':
398 case '%':
399 case ';':
400 case '@':
401 case '!':
402 case '$':
403 case '?':
404 case '/':
405 case '&':
6a1f93f6 406 case '`':
dd3b648e
RP
407
408 if (place == 'd')
409 {
410 val = fetch_arg (buffer, 'x', 6);
411 val = ((val & 7) << 3) + ((val >> 3) & 7);
412 }
413 else
414 val = fetch_arg (buffer, 's', 6);
415
416 /* Get register number assuming address register. */
417 regno = (val & 7) + 8;
418 regname = reg_names[regno];
419 switch (val >> 3)
420 {
421 case 0:
422 fprintf_filtered (stream, "%s", reg_names[val]);
423 break;
424
425 case 1:
426 fprintf_filtered (stream, "%s", regname);
427 break;
428
429 case 2:
430 fprintf_filtered (stream, "%s@", regname);
431 break;
432
433 case 3:
434 fprintf_filtered (stream, "%s@+", regname);
435 break;
436
437 case 4:
438 fprintf_filtered (stream, "%s@-", regname);
439 break;
440
441 case 5:
442 val = NEXTWORD (p);
443 fprintf_filtered (stream, "%s@(%d)", regname, val);
444 break;
445
446 case 6:
447 p = print_indexed (regno, p, addr, stream);
448 break;
449
450 case 7:
451 switch (val & 7)
452 {
453 case 0:
454 val = NEXTWORD (p);
455 fprintf_filtered (stream, "@#");
456 print_address (val, stream);
457 break;
458
459 case 1:
460 val = NEXTLONG (p);
461 fprintf_filtered (stream, "@#");
462 print_address (val, stream);
463 break;
464
465 case 2:
466 val = NEXTWORD (p);
467 print_address (addr + val, stream);
468 break;
469
470 case 3:
471 p = print_indexed (-1, p, addr, stream);
472 break;
473
474 case 4:
475 flt_p = 1; /* Assume it's a float... */
476 switch( place )
477 {
478 case 'b':
479 val = NEXTBYTE (p);
480 flt_p = 0;
481 break;
482
483 case 'w':
484 val = NEXTWORD (p);
485 flt_p = 0;
486 break;
487
488 case 'l':
489 val = NEXTLONG (p);
490 flt_p = 0;
491 break;
492
493 case 'f':
494 flval = NEXTSINGLE(p);
495 break;
496
497 case 'F':
498 flval = NEXTDOUBLE(p);
499 break;
500
67c9f54c 501#ifdef HAVE_68881
dd3b648e 502 case 'x':
48079d66 503 ieee_extended_to_double (&ext_format_68881, p, &flval);
8970a55e 504 p += 12;
dd3b648e 505 break;
67c9f54c 506#endif
dd3b648e
RP
507
508 case 'p':
8970a55e
JG
509 p += 12;
510 flval = 0; /* FIXME, handle packed decimal someday. */
dd3b648e
RP
511 break;
512
513 default:
514 error ("Invalid arg format in opcode table: \"%c%c\".",
515 *d, place);
516 }
517 if ( flt_p ) /* Print a float? */
518 fprintf_filtered (stream, "#%g", flval);
519 else
520 fprintf_filtered (stream, "#%d", val);
521 break;
522
523 default:
524 fprintf_filtered (stream, "<invalid address mode 0%o>", val);
525 }
526 }
527 break;
528
529 case 'L':
530 case 'l':
531 if (place == 'w')
532 {
533 char doneany;
534 p1 = buffer + 2;
535 val = NEXTWORD (p1);
536 /* Move the pointer ahead if this point is farther ahead
537 than the last. */
538 p = p1 > p ? p1 : p;
539 if (val == 0)
540 {
541 fputs_filtered ("#0", stream);
542 break;
543 }
544 if (*d == 'l')
545 {
546 register int newval = 0;
547 for (regno = 0; regno < 16; ++regno)
548 if (val & (0x8000 >> regno))
549 newval |= 1 << regno;
550 val = newval;
551 }
552 val &= 0xffff;
553 doneany = 0;
554 for (regno = 0; regno < 16; ++regno)
555 if (val & (1 << regno))
556 {
557 int first_regno;
558 if (doneany)
559 fputs_filtered ("/", stream);
560 doneany = 1;
561 fprintf_filtered (stream, "%s", reg_names[regno]);
562 first_regno = regno;
563 while (val & (1 << (regno + 1)))
564 ++regno;
565 if (regno > first_regno)
566 fprintf_filtered (stream, "-%s", reg_names[regno]);
567 }
568 }
569 else if (place == '3')
570 {
571 /* `fmovem' insn. */
572 char doneany;
573 val = fetch_arg (buffer, place, 8);
574 if (val == 0)
575 {
576 fputs_filtered ("#0", stream);
577 break;
578 }
579 if (*d == 'l')
580 {
581 register int newval = 0;
582 for (regno = 0; regno < 8; ++regno)
583 if (val & (0x80 >> regno))
584 newval |= 1 << regno;
585 val = newval;
586 }
587 val &= 0xff;
588 doneany = 0;
589 for (regno = 0; regno < 8; ++regno)
590 if (val & (1 << regno))
591 {
592 int first_regno;
593 if (doneany)
594 fputs_filtered ("/", stream);
595 doneany = 1;
596 fprintf_filtered (stream, "fp%d", regno);
597 first_regno = regno;
598 while (val & (1 << (regno + 1)))
599 ++regno;
600 if (regno > first_regno)
601 fprintf_filtered (stream, "-fp%d", regno);
602 }
603 }
604 else
8970a55e 605 goto de_fault;
dd3b648e
RP
606 break;
607
8970a55e 608 default: de_fault:
dd3b648e
RP
609 error ("Invalid arg format in opcode table: \"%c\".", *d);
610 }
611
612 return (unsigned char *) p;
613}
614
615/* Fetch BITS bits from a position in the instruction specified by CODE.
616 CODE is a "place to put an argument", or 'x' for a destination
617 that is a general address (mode and register).
618 BUFFER contains the instruction. */
619
620static int
621fetch_arg (buffer, code, bits)
622 unsigned char *buffer;
1ab3bf1b 623 int code;
dd3b648e
RP
624 int bits;
625{
626 register int val;
627 switch (code)
628 {
629 case 's':
630 val = buffer[1];
631 break;
632
633 case 'd': /* Destination, for register or quick. */
634 val = (buffer[0] << 8) + buffer[1];
635 val >>= 9;
636 break;
637
638 case 'x': /* Destination, for general arg */
639 val = (buffer[0] << 8) + buffer[1];
640 val >>= 6;
641 break;
642
643 case 'k':
644 val = (buffer[3] >> 4);
645 break;
646
647 case 'C':
648 val = buffer[3];
649 break;
650
651 case '1':
652 val = (buffer[2] << 8) + buffer[3];
653 val >>= 12;
654 break;
655
656 case '2':
657 val = (buffer[2] << 8) + buffer[3];
658 val >>= 6;
659 break;
660
661 case '3':
662 case 'j':
663 val = (buffer[2] << 8) + buffer[3];
664 break;
665
666 case '4':
667 val = (buffer[4] << 8) + buffer[5];
668 val >>= 12;
669 break;
670
671 case '5':
672 val = (buffer[4] << 8) + buffer[5];
673 val >>= 6;
674 break;
675
676 case '6':
677 val = (buffer[4] << 8) + buffer[5];
678 break;
679
680 case '7':
681 val = (buffer[2] << 8) + buffer[3];
682 val >>= 7;
683 break;
684
685 case '8':
686 val = (buffer[2] << 8) + buffer[3];
687 val >>= 10;
688 break;
689
8f61b5e4
ILT
690 case 'e':
691 val = (buffer[1] >> 6);
692 break;
693
dd3b648e
RP
694 default:
695 abort ();
696 }
697
698 switch (bits)
699 {
8f61b5e4
ILT
700 case 2:
701 return val & 3;
dd3b648e
RP
702 case 3:
703 return val & 7;
704 case 4:
705 return val & 017;
706 case 5:
707 return val & 037;
708 case 6:
709 return val & 077;
710 case 7:
711 return val & 0177;
712 case 8:
713 return val & 0377;
714 case 12:
715 return val & 07777;
716 default:
717 abort ();
718 }
719}
720
721/* Print an indexed argument. The base register is BASEREG (-1 for pc).
722 P points to extension word, in buffer.
723 ADDR is the nominal core address of that extension word. */
724
725static unsigned char *
726print_indexed (basereg, p, addr, stream)
727 int basereg;
728 unsigned char *p;
dd3b648e 729 CORE_ADDR addr;
1ab3bf1b 730 FILE *stream;
dd3b648e
RP
731{
732 register int word;
733 static char *scales[] = {"", "*2", "*4", "*8"};
734 register int base_disp;
735 register int outer_disp;
736 char buf[40];
737
738 word = NEXTWORD (p);
739
740 /* Generate the text for the index register.
741 Where this will be output is not yet determined. */
742 sprintf (buf, "[%s.%c%s]",
743 reg_names[(word >> 12) & 0xf],
744 (word & 0x800) ? 'l' : 'w',
745 scales[(word >> 9) & 3]);
746
747 /* Handle the 68000 style of indexing. */
748
749 if ((word & 0x100) == 0)
750 {
751 print_base (basereg,
752 ((word & 0x80) ? word | 0xff00 : word & 0xff)
753 + ((basereg == -1) ? addr : 0),
754 stream);
755 fputs_filtered (buf, stream);
756 return p;
757 }
758
759 /* Handle the generalized kind. */
760 /* First, compute the displacement to add to the base register. */
761
762 if (word & 0200)
763 basereg = -2;
764 if (word & 0100)
765 buf[0] = 0;
766 base_disp = 0;
767 switch ((word >> 4) & 3)
768 {
769 case 2:
770 base_disp = NEXTWORD (p);
771 break;
772 case 3:
773 base_disp = NEXTLONG (p);
774 }
775 if (basereg == -1)
776 base_disp += addr;
777
778 /* Handle single-level case (not indirect) */
779
780 if ((word & 7) == 0)
781 {
782 print_base (basereg, base_disp, stream);
783 fputs_filtered (buf, stream);
784 return p;
785 }
786
787 /* Two level. Compute displacement to add after indirection. */
788
789 outer_disp = 0;
790 switch (word & 3)
791 {
792 case 2:
793 outer_disp = NEXTWORD (p);
794 break;
795 case 3:
796 outer_disp = NEXTLONG (p);
797 }
798
799 fprintf_filtered (stream, "%d(", outer_disp);
800 print_base (basereg, base_disp, stream);
801
802 /* If postindexed, print the closeparen before the index. */
803 if (word & 4)
804 fprintf_filtered (stream, ")%s", buf);
805 /* If preindexed, print the closeparen after the index. */
806 else
807 fprintf_filtered (stream, "%s)", buf);
808
809 return p;
810}
811
812/* Print a base register REGNO and displacement DISP, on STREAM.
813 REGNO = -1 for pc, -2 for none (suppressed). */
814
815static void
816print_base (regno, disp, stream)
817 int regno;
818 int disp;
819 FILE *stream;
820{
821 if (regno == -2)
822 fprintf_filtered (stream, "%d", disp);
823 else if (regno == -1)
824 fprintf_filtered (stream, "0x%x", disp);
825 else
826 fprintf_filtered (stream, "%d(%s)", disp, reg_names[regno]);
827}
This page took 0.10017 seconds and 4 git commands to generate.