1 /* Print Motorola 68k instructions.
2 Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
3 Free Software Foundation, Inc.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #include "floatformat.h"
22 #include <libiberty.h>
25 #include "opcode/m68k.h"
27 /* Local function prototypes */
30 fetch_data PARAMS ((struct disassemble_info *, bfd_byte *));
33 dummy_print_address PARAMS ((bfd_vma, struct disassemble_info *));
36 fetch_arg PARAMS ((unsigned char *, int, int, disassemble_info *));
39 print_base PARAMS ((int, bfd_vma, disassemble_info*));
41 static unsigned char *
42 print_indexed PARAMS ((int, unsigned char *, bfd_vma, disassemble_info *));
45 print_insn_arg PARAMS ((const char *, unsigned char *, unsigned char *,
46 bfd_vma, disassemble_info *));
48 CONST char * CONST fpcr_names[] = {
49 "", "%fpiar", "%fpsr", "%fpiar/%fpsr", "%fpcr",
50 "%fpiar/%fpcr", "%fpsr/%fpcr", "%fpiar/%fpsr/%fpcr"};
52 static char *const reg_names[] = {
53 "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
54 "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp",
57 /* Sign-extend an (unsigned char). */
59 #define COERCE_SIGNED_CHAR(ch) ((signed char)(ch))
61 #define COERCE_SIGNED_CHAR(ch) ((int)(((ch) ^ 0x80) & 0xFF) - 128)
64 /* Get a 1 byte signed integer. */
65 #define NEXTBYTE(p) (p += 2, FETCH_DATA (info, p), COERCE_SIGNED_CHAR(p[-1]))
67 /* Get a 2 byte signed integer. */
68 #define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
70 (p += 2, FETCH_DATA (info, p), \
71 COERCE16 ((p[-2] << 8) + p[-1]))
73 /* Get a 4 byte signed integer. */
74 #define COERCE32(x) ((bfd_signed_vma) ((x) ^ 0x80000000) - 0x80000000)
76 (p += 4, FETCH_DATA (info, p), \
77 (COERCE32 ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1])))
79 /* Get a 4 byte unsigned integer. */
80 #define NEXTULONG(p) \
81 (p += 4, FETCH_DATA (info, p), \
82 (unsigned int) ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]))
84 /* Get a single precision float. */
85 #define NEXTSINGLE(val, p) \
86 (p += 4, FETCH_DATA (info, p), \
87 floatformat_to_double (&floatformat_ieee_single_big, (char *) p - 4, &val))
89 /* Get a double precision float. */
90 #define NEXTDOUBLE(val, p) \
91 (p += 8, FETCH_DATA (info, p), \
92 floatformat_to_double (&floatformat_ieee_double_big, (char *) p - 8, &val))
94 /* Get an extended precision float. */
95 #define NEXTEXTEND(val, p) \
96 (p += 12, FETCH_DATA (info, p), \
97 floatformat_to_double (&floatformat_m68881_ext, (char *) p - 12, &val))
99 /* Need a function to convert from packed to double
100 precision. Actually, it's easier to print a
101 packed number than a double anyway, so maybe
102 there should be a special case to handle this... */
103 #define NEXTPACKED(p) \
104 (p += 12, FETCH_DATA (info, p), 0.0)
107 /* Maximum length of an instruction. */
114 /* Points to first byte not fetched. */
115 bfd_byte *max_fetched;
116 bfd_byte the_buffer[MAXLEN];
121 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
122 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
124 #define FETCH_DATA(info, addr) \
125 ((addr) <= ((struct private *)(info->private_data))->max_fetched \
126 ? 1 : fetch_data ((info), (addr)))
129 fetch_data (info, addr)
130 struct disassemble_info *info;
134 struct private *priv = (struct private *)info->private_data;
135 bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
137 status = (*info->read_memory_func) (start,
139 addr - priv->max_fetched,
143 (*info->memory_error_func) (status, start, info);
144 longjmp (priv->bailout, 1);
147 priv->max_fetched = addr;
151 /* This function is used to print to the bit-bucket. */
154 dummy_printer (FILE * file ATTRIBUTE_UNUSED,
155 const char * format ATTRIBUTE_UNUSED, ...)
157 dummy_printer (file) FILE *file ATTRIBUTE_UNUSED;
162 dummy_print_address (vma, info)
163 bfd_vma vma ATTRIBUTE_UNUSED;
164 struct disassemble_info *info ATTRIBUTE_UNUSED;
168 /* Print the m68k instruction at address MEMADDR in debugged memory,
169 on INFO->STREAM. Returns length of the instruction, in bytes. */
172 print_insn_m68k (memaddr, info)
174 disassemble_info *info;
177 register unsigned char *p;
178 unsigned char *save_p;
179 register const char *d;
180 register unsigned long bestmask;
181 const struct m68k_opcode *best = 0;
182 unsigned int arch_mask;
184 bfd_byte *buffer = priv.the_buffer;
185 fprintf_ftype save_printer = info->fprintf_func;
186 void (*save_print_address) PARAMS((bfd_vma, struct disassemble_info*))
187 = info->print_address_func;
189 static int numopcodes[16];
190 static const struct m68k_opcode **opcodes[16];
194 /* Speed up the matching by sorting the opcode table on the upper
195 four bits of the opcode. */
196 const struct m68k_opcode **opc_pointer[16];
198 /* First count how many opcodes are in each of the sixteen buckets. */
199 for (i = 0; i < m68k_numopcodes; i++)
200 numopcodes[(m68k_opcodes[i].opcode >> 28) & 15]++;
202 /* Then create a sorted table of pointers that point into the
204 opc_pointer[0] = ((const struct m68k_opcode **)
205 xmalloc (sizeof (struct m68k_opcode *)
207 opcodes[0] = opc_pointer[0];
208 for (i = 1; i < 16; i++)
210 opc_pointer[i] = opc_pointer[i - 1] + numopcodes[i - 1];
211 opcodes[i] = opc_pointer[i];
214 for (i = 0; i < m68k_numopcodes; i++)
215 *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i];
219 info->private_data = (PTR) &priv;
220 /* Tell objdump to use two bytes per chunk and six bytes per line for
221 displaying raw data. */
222 info->bytes_per_chunk = 2;
223 info->bytes_per_line = 6;
224 info->display_endian = BFD_ENDIAN_BIG;
225 priv.max_fetched = priv.the_buffer;
226 priv.insn_start = memaddr;
227 if (setjmp (priv.bailout) != 0)
235 arch_mask = (unsigned int) -1;
237 case bfd_mach_m68000:
240 case bfd_mach_m68008:
243 case bfd_mach_m68010:
246 case bfd_mach_m68020:
249 case bfd_mach_m68030:
252 case bfd_mach_m68040:
255 case bfd_mach_m68060:
260 arch_mask |= m68881 | m68851;
263 FETCH_DATA (info, buffer + 2);
264 major_opcode = (buffer[0] >> 4) & 15;
265 for (i = 0; i < numopcodes[major_opcode]; i++)
267 const struct m68k_opcode *opc = opcodes[major_opcode][i];
268 unsigned long opcode = opc->opcode;
269 unsigned long match = opc->match;
271 if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
272 && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
273 /* Only fetch the next two bytes if we need to. */
274 && (((0xffff & match) == 0)
276 (FETCH_DATA (info, buffer + 4)
277 && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
278 && ((0xff & buffer[3] & match) == (0xff & opcode)))
280 && (opc->arch & arch_mask) != 0)
282 /* Don't use for printout the variants of divul and divsl
283 that have the same register number in two places.
284 The more general variants will match instead. */
285 for (d = opc->args; *d; d += 2)
289 /* Don't use for printout the variants of most floating
290 point coprocessor instructions which use the same
291 register number in two places, as above. */
293 for (d = opc->args; *d; d += 2)
297 /* Don't match fmovel with more than one register; wait for
301 for (d = opc->args; *d; d += 2)
303 if (d[0] == 's' && d[1] == '8')
307 val = fetch_arg (buffer, d[1], 3, info);
308 if ((val & (val - 1)) != 0)
314 if (*d == '\0' && match > bestmask)
325 /* Point at first word of argument data,
326 and at descriptor for first argument. */
329 /* Figure out how long the fixed-size portion of the instruction is.
330 The only place this is stored in the opcode table is
331 in the arguments--look for arguments which specify fields in the 2nd
332 or 3rd words of the instruction. */
333 for (d = best->args; *d; d += 2)
335 /* I don't think it is necessary to be checking d[0] here; I suspect
336 all this could be moved to the case statement below. */
339 if (d[1] == 'l' && p - buffer < 6)
341 else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' )
344 if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
369 /* pflusha is an exceptions. It takes no arguments but is two words
370 long. Recognize it by looking at the lower 16 bits of the mask. */
371 if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
374 /* lpstop is another exception. It takes a one word argument but is
377 && (best->match & 0xffff) == 0xffff
378 && best->args[0] == '#'
379 && best->args[1] == 'w')
381 /* Copy the one word argument into the usual location for a one
382 word argument, to simplify printing it. We can get away with
383 this because we know exactly what the second word is, and we
384 aren't going to print anything based on it. */
386 FETCH_DATA (info, p);
387 buffer[2] = buffer[4];
388 buffer[3] = buffer[5];
391 FETCH_DATA (info, p);
395 /* We can the operands twice. The first time we don't print anything,
396 but look for errors. */
399 info->print_address_func = dummy_print_address;
400 info->fprintf_func = (fprintf_ftype)dummy_printer;
403 int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
406 else if (eaten == -1)
410 (*info->fprintf_func)(info->stream,
411 /* xgettext:c-format */
412 _("<internal error in opcode table: %s %s>\n"),
420 info->fprintf_func = save_printer;
421 info->print_address_func = save_print_address;
425 (*info->fprintf_func) (info->stream, "%s", best->name);
428 (*info->fprintf_func) (info->stream, " ");
432 p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
434 if (*d && *(d - 2) != 'I' && *d != 'k')
435 (*info->fprintf_func) (info->stream, ",");
440 /* Handle undefined instructions. */
441 info->fprintf_func = save_printer;
442 info->print_address_func = save_print_address;
443 (*info->fprintf_func) (info->stream, "0%o",
444 (buffer[0] << 8) + buffer[1]);
448 /* Returns number of bytes "eaten" by the operand, or
449 return -1 if an invalid operand was found, or -2 if
450 an opcode tabe error was found. */
453 print_insn_arg (d, buffer, p0, addr, info)
455 unsigned char *buffer;
457 bfd_vma addr; /* PC for this arg to be relative to */
458 disassemble_info *info;
460 register int val = 0;
461 register int place = d[1];
462 register unsigned char *p = p0;
464 register CONST char *regname;
465 register unsigned char *p1;
473 case 'c': /* cache identifier */
475 static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
476 val = fetch_arg (buffer, place, 2, info);
477 (*info->fprintf_func) (info->stream, cacheFieldName[val]);
481 case 'a': /* address register indirect only. Cf. case '+'. */
483 (*info->fprintf_func)
486 reg_names [fetch_arg (buffer, place, 3, info) + 8]);
490 case '_': /* 32-bit absolute address for move16. */
492 uval = NEXTULONG (p);
493 (*info->print_address_func) (uval, info);
498 (*info->fprintf_func) (info->stream, "%%ccr");
502 (*info->fprintf_func) (info->stream, "%%sr");
506 (*info->fprintf_func) (info->stream, "%%usp");
510 (*info->fprintf_func) (info->stream, "%%acc");
514 (*info->fprintf_func) (info->stream, "%%macsr");
518 (*info->fprintf_func) (info->stream, "%%mask");
523 static const struct { char *name; int value; } names[]
524 = {{"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
525 {"%tc", 0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
526 {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
527 {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
528 {"%msp", 0x803}, {"%isp", 0x804},
530 /* Should we be calling this psr like we do in case 'Y'? */
533 {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808}};
535 val = fetch_arg (buffer, place, 12, info);
536 for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--)
537 if (names[regno].value == val)
539 (*info->fprintf_func) (info->stream, "%s", names[regno].name);
543 (*info->fprintf_func) (info->stream, "%d", val);
548 val = fetch_arg (buffer, place, 3, info);
549 /* 0 means 8, except for the bkpt instruction... */
550 if (val == 0 && d[1] != 's')
552 (*info->fprintf_func) (info->stream, "#%d", val);
558 static char *const scalefactor_name[] = { "<<", ">>" };
559 val = fetch_arg (buffer, place, 1, info);
560 (*info->fprintf_func) (info->stream, scalefactor_name[val]);
564 val = fetch_arg (buffer, place, 8, info);
567 (*info->fprintf_func) (info->stream, "#%d", val);
572 val = fetch_arg (buffer, place, 4, info);
573 (*info->fprintf_func) (info->stream, "#%d", val);
577 (*info->fprintf_func) (info->stream, "%s",
578 reg_names[fetch_arg (buffer, place, 3, info)]);
582 (*info->fprintf_func)
584 reg_names[fetch_arg (buffer, place, 3, info) + 010]);
588 (*info->fprintf_func)
590 reg_names[fetch_arg (buffer, place, 4, info)]);
594 regno = fetch_arg (buffer, place, 4, info);
596 (*info->fprintf_func) (info->stream, "%s@", reg_names[regno]);
598 (*info->fprintf_func) (info->stream, "@(%s)", reg_names[regno]);
602 (*info->fprintf_func)
603 (info->stream, "%%fp%d",
604 fetch_arg (buffer, place, 3, info));
608 val = fetch_arg (buffer, place, 6, info);
610 (*info->fprintf_func) (info->stream, "%s", reg_names [val & 7]);
612 (*info->fprintf_func) (info->stream, "%d", val);
616 (*info->fprintf_func)
617 (info->stream, "%s@+",
618 reg_names[fetch_arg (buffer, place, 3, info) + 8]);
622 (*info->fprintf_func)
623 (info->stream, "%s@-",
624 reg_names[fetch_arg (buffer, place, 3, info) + 8]);
629 (*info->fprintf_func)
630 (info->stream, "{%s}",
631 reg_names[fetch_arg (buffer, place, 3, info)]);
632 else if (place == 'C')
634 val = fetch_arg (buffer, place, 7, info);
635 if ( val > 63 ) /* This is a signed constant. */
637 (*info->fprintf_func) (info->stream, "{#%d}", val);
645 p1 = buffer + (*d == '#' ? 2 : 4);
647 val = fetch_arg (buffer, place, 4, info);
648 else if (place == 'C')
649 val = fetch_arg (buffer, place, 7, info);
650 else if (place == '8')
651 val = fetch_arg (buffer, place, 3, info);
652 else if (place == '3')
653 val = fetch_arg (buffer, place, 8, info);
654 else if (place == 'b')
656 else if (place == 'w' || place == 'W')
658 else if (place == 'l')
662 (*info->fprintf_func) (info->stream, "#%d", val);
668 else if (place == 'B')
669 disp = COERCE_SIGNED_CHAR(buffer[1]);
670 else if (place == 'w' || place == 'W')
672 else if (place == 'l' || place == 'L' || place == 'C')
674 else if (place == 'g')
676 disp = NEXTBYTE (buffer);
682 else if (place == 'c')
684 if (buffer[1] & 0x40) /* If bit six is one, long offset */
692 (*info->print_address_func) (addr + disp, info);
697 (*info->fprintf_func)
698 (info->stream, "%s@(%d)",
699 reg_names[fetch_arg (buffer, place, 3, info) + 8], val);
703 (*info->fprintf_func) (info->stream, "%s",
704 fpcr_names[fetch_arg (buffer, place, 3, info)]);
708 /* Get coprocessor ID... */
709 val = fetch_arg (buffer, 'd', 3, info);
711 if (val != 1) /* Unusual coprocessor ID? */
712 (*info->fprintf_func) (info->stream, "(cpid=%d) ", val);
737 val = fetch_arg (buffer, 'x', 6, info);
738 val = ((val & 7) << 3) + ((val >> 3) & 7);
741 val = fetch_arg (buffer, 's', 6, info);
743 /* Get register number assuming address register. */
744 regno = (val & 7) + 8;
745 regname = reg_names[regno];
749 (*info->fprintf_func) (info->stream, "%s", reg_names[val]);
753 (*info->fprintf_func) (info->stream, "%s", regname);
757 (*info->fprintf_func) (info->stream, "%s@", regname);
761 (*info->fprintf_func) (info->stream, "%s@+", regname);
765 (*info->fprintf_func) (info->stream, "%s@-", regname);
770 (*info->fprintf_func) (info->stream, "%s@(%d)", regname, val);
774 p = print_indexed (regno, p, addr, info);
782 (*info->print_address_func) (val, info);
786 uval = NEXTULONG (p);
787 (*info->print_address_func) (uval, info);
792 (*info->fprintf_func) (info->stream, "%%pc@(");
793 (*info->print_address_func) (addr + val, info);
794 (*info->fprintf_func) (info->stream, ")");
798 p = print_indexed (-1, p, addr, info);
802 flt_p = 1; /* Assume it's a float... */
821 NEXTSINGLE(flval, p);
825 NEXTDOUBLE(flval, p);
829 NEXTEXTEND(flval, p);
833 flval = NEXTPACKED(p);
839 if ( flt_p ) /* Print a float? */
840 (*info->fprintf_func) (info->stream, "#%g", flval);
842 (*info->fprintf_func) (info->stream, "#%d", val);
858 /* Move the pointer ahead if this point is farther ahead
863 (*info->fprintf_func) (info->stream, "#0");
868 register int newval = 0;
869 for (regno = 0; regno < 16; ++regno)
870 if (val & (0x8000 >> regno))
871 newval |= 1 << regno;
876 for (regno = 0; regno < 16; ++regno)
877 if (val & (1 << regno))
881 (*info->fprintf_func) (info->stream, "/");
883 (*info->fprintf_func) (info->stream, "%s", reg_names[regno]);
885 while (val & (1 << (regno + 1)))
887 if (regno > first_regno)
888 (*info->fprintf_func) (info->stream, "-%s",
892 else if (place == '3')
896 val = fetch_arg (buffer, place, 8, info);
899 (*info->fprintf_func) (info->stream, "#0");
904 register int newval = 0;
905 for (regno = 0; regno < 8; ++regno)
906 if (val & (0x80 >> regno))
907 newval |= 1 << regno;
912 for (regno = 0; regno < 8; ++regno)
913 if (val & (1 << regno))
917 (*info->fprintf_func) (info->stream, "/");
919 (*info->fprintf_func) (info->stream, "%%fp%d", regno);
921 while (val & (1 << (regno + 1)))
923 if (regno > first_regno)
924 (*info->fprintf_func) (info->stream, "-%%fp%d", regno);
927 else if (place == '8')
929 /* fmoveml for FP status registers */
930 (*info->fprintf_func) (info->stream, "%s",
931 fpcr_names[fetch_arg (buffer, place, 3,
948 int val = fetch_arg (buffer, place, 5, info);
952 case 2: name = "%tt0"; break;
953 case 3: name = "%tt1"; break;
954 case 0x10: name = "%tc"; break;
955 case 0x11: name = "%drp"; break;
956 case 0x12: name = "%srp"; break;
957 case 0x13: name = "%crp"; break;
958 case 0x14: name = "%cal"; break;
959 case 0x15: name = "%val"; break;
960 case 0x16: name = "%scc"; break;
961 case 0x17: name = "%ac"; break;
962 case 0x18: name = "%psr"; break;
963 case 0x19: name = "%pcsr"; break;
967 int break_reg = ((buffer[3] >> 2) & 7);
968 (*info->fprintf_func)
969 (info->stream, val == 0x1c ? "%%bad%d" : "%%bac%d",
974 (*info->fprintf_func) (info->stream, "<mmu register %d>", val);
977 (*info->fprintf_func) (info->stream, "%s", name);
983 int fc = fetch_arg (buffer, place, 5, info);
985 (*info->fprintf_func) (info->stream, "%%dfc");
987 (*info->fprintf_func) (info->stream, "%%sfc");
989 /* xgettext:c-format */
990 (*info->fprintf_func) (info->stream, _("<function code %d>"), fc);
995 (*info->fprintf_func) (info->stream, "%%val");
1000 int level = fetch_arg (buffer, place, 3, info);
1001 (*info->fprintf_func) (info->stream, "%d", level);
1008 int reg = fetch_arg (buffer, place, 5, info);
1015 (*info->fprintf_func) (info->stream, "%s%s",
1017 is_upper ? "u" : "l");
1028 /* Fetch BITS bits from a position in the instruction specified by CODE.
1029 CODE is a "place to put an argument", or 'x' for a destination
1030 that is a general address (mode and register).
1031 BUFFER contains the instruction. */
1034 fetch_arg (buffer, code, bits, info)
1035 unsigned char *buffer;
1038 disassemble_info *info;
1040 register int val = 0;
1047 case 'd': /* Destination, for register or quick. */
1048 val = (buffer[0] << 8) + buffer[1];
1052 case 'x': /* Destination, for general arg */
1053 val = (buffer[0] << 8) + buffer[1];
1058 FETCH_DATA (info, buffer + 3);
1059 val = (buffer[3] >> 4);
1063 FETCH_DATA (info, buffer + 3);
1068 FETCH_DATA (info, buffer + 3);
1069 val = (buffer[2] << 8) + buffer[3];
1074 FETCH_DATA (info, buffer + 3);
1075 val = (buffer[2] << 8) + buffer[3];
1081 FETCH_DATA (info, buffer + 3);
1082 val = (buffer[2] << 8) + buffer[3];
1086 FETCH_DATA (info, buffer + 5);
1087 val = (buffer[4] << 8) + buffer[5];
1092 FETCH_DATA (info, buffer + 5);
1093 val = (buffer[4] << 8) + buffer[5];
1098 FETCH_DATA (info, buffer + 5);
1099 val = (buffer[4] << 8) + buffer[5];
1103 FETCH_DATA (info, buffer + 3);
1104 val = (buffer[2] << 8) + buffer[3];
1109 FETCH_DATA (info, buffer + 3);
1110 val = (buffer[2] << 8) + buffer[3];
1115 FETCH_DATA (info, buffer + 3);
1116 val = (buffer[2] << 8) + buffer[3];
1121 val = (buffer[1] >> 6);
1125 val = (buffer[1] & 0x40 ? 0x8 : 0)
1126 | ((buffer[0] >> 1) & 0x7)
1127 | (buffer[3] & 0x80 ? 0x10 : 0);
1131 val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
1135 val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
1139 val = buffer[1] | (buffer[3] & 0x40 ? 0x10 : 0);
1143 val = buffer[3] | (buffer[3] & 0x40 ? 0x10 : 0);
1147 val = buffer[2] >> 2;
1179 /* Print an indexed argument. The base register is BASEREG (-1 for pc).
1180 P points to extension word, in buffer.
1181 ADDR is the nominal core address of that extension word. */
1183 static unsigned char *
1184 print_indexed (basereg, p, addr, info)
1188 disassemble_info *info;
1191 static char *const scales[] = {"", ":2", ":4", ":8"};
1197 word = NEXTWORD (p);
1199 /* Generate the text for the index register.
1200 Where this will be output is not yet determined. */
1201 sprintf (buf, "%s:%c%s",
1202 reg_names[(word >> 12) & 0xf],
1203 (word & 0x800) ? 'l' : 'w',
1204 scales[(word >> 9) & 3]);
1206 /* Handle the 68000 style of indexing. */
1208 if ((word & 0x100) == 0)
1210 base_disp = word & 0xff;
1211 if ((base_disp & 0x80) != 0)
1215 print_base (basereg, base_disp, info);
1216 (*info->fprintf_func) (info->stream, ",%s)", buf);
1220 /* Handle the generalized kind. */
1221 /* First, compute the displacement to add to the base register. */
1233 switch ((word >> 4) & 3)
1236 base_disp = NEXTWORD (p);
1239 base_disp = NEXTLONG (p);
1244 /* Handle single-level case (not indirect) */
1246 if ((word & 7) == 0)
1248 print_base (basereg, base_disp, info);
1250 (*info->fprintf_func) (info->stream, ",%s", buf);
1251 (*info->fprintf_func) (info->stream, ")");
1255 /* Two level. Compute displacement to add after indirection. */
1261 outer_disp = NEXTWORD (p);
1264 outer_disp = NEXTLONG (p);
1267 print_base (basereg, base_disp, info);
1268 if ((word & 4) == 0 && buf[0] != '\0')
1270 (*info->fprintf_func) (info->stream, ",%s", buf);
1273 sprintf_vma (vmabuf, outer_disp);
1274 (*info->fprintf_func) (info->stream, ")@(%s", vmabuf);
1276 (*info->fprintf_func) (info->stream, ",%s", buf);
1277 (*info->fprintf_func) (info->stream, ")");
1282 /* Print a base register REGNO and displacement DISP, on INFO->STREAM.
1283 REGNO = -1 for pc, -2 for none (suppressed). */
1286 print_base (regno, disp, info)
1289 disassemble_info *info;
1293 (*info->fprintf_func) (info->stream, "%%pc@(");
1294 (*info->print_address_func) (disp, info);
1301 (*info->fprintf_func) (info->stream, "@(");
1302 else if (regno == -3)
1303 (*info->fprintf_func) (info->stream, "%%zpc@(");
1305 (*info->fprintf_func) (info->stream, "%s@(", reg_names[regno]);
1307 sprintf_vma (buf, disp);
1308 (*info->fprintf_func) (info->stream, "%s", buf);