Coverage Report

Created: 2023-08-28 06:30

/src/binutils-gdb/opcodes/m68k-dis.c
Line
Count
Source (jump to first uncovered line)
1
/* Print Motorola 68k instructions.
2
   Copyright (C) 1986-2023 Free Software Foundation, Inc.
3
4
   This file is part of the GNU opcodes library.
5
6
   This library is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
11
   It is distributed in the hope that it will be useful, but WITHOUT
12
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14
   License for more details.
15
16
   You should have received a copy of the GNU General Public License
17
   along with this program; if not, write to the Free Software
18
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
   MA 02110-1301, USA.  */
20
21
#include "sysdep.h"
22
#include "disassemble.h"
23
#include "floatformat.h"
24
#include "libiberty.h"
25
#include "opintl.h"
26
#include "cpu-m68k.h"
27
#include "opcode/m68k.h"
28
29
/* Local function prototypes.  */
30
31
const char * const fpcr_names[] =
32
{
33
  "", "%fpiar", "%fpsr", "%fpiar/%fpsr", "%fpcr",
34
  "%fpiar/%fpcr", "%fpsr/%fpcr", "%fpiar/%fpsr/%fpcr"
35
};
36
37
static char *const reg_names[] =
38
{
39
  "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
40
  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp",
41
  "%ps", "%pc"
42
};
43
44
/* Name of register halves for MAC/EMAC.
45
   Seperate from reg_names since 'spu', 'fpl' look weird.  */
46
static char *const reg_half_names[] =
47
{
48
  "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
49
  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
50
  "%ps", "%pc"
51
};
52
53
/* Sign-extend an (unsigned char).  */
54
#if __STDC__ == 1
55
2.42M
#define COERCE_SIGNED_CHAR(ch) ((signed char) (ch))
56
#else
57
#define COERCE_SIGNED_CHAR(ch) ((int) (((ch) ^ 0x80) & 0xFF) - 128)
58
#endif
59
60
/* Error code of print_insn_arg's return value.  */
61
62
enum print_insn_arg_error
63
  {
64
    /* An invalid operand is found.  */
65
    PRINT_INSN_ARG_INVALID_OPERAND = -1,
66
67
    /* An opcode table error.  */
68
    PRINT_INSN_ARG_INVALID_OP_TABLE = -2,
69
70
    /* A memory error.  */
71
    PRINT_INSN_ARG_MEMORY_ERROR = -3,
72
  };
73
74
/* Get a 1 byte signed integer.  */
75
#define NEXTBYTE(p, val)      \
76
2.08M
  do            \
77
2.08M
    {           \
78
2.08M
      p += 2;         \
79
2.08M
      if (!FETCH_DATA (info, p))   \
80
2.08M
  return PRINT_INSN_ARG_MEMORY_ERROR; \
81
2.08M
      val = COERCE_SIGNED_CHAR (p[-1]);   \
82
2.08M
    }            \
83
2.08M
  while (0)
84
85
/* Get a 2 byte signed integer.  */
86
1.45M
#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
87
88
#define NEXTWORD(p, val, ret_val)   \
89
1.45M
  do            \
90
1.45M
    {           \
91
1.45M
      p += 2;         \
92
1.45M
      if (!FETCH_DATA (info, p))   \
93
1.45M
  return ret_val;       \
94
1.45M
      val = COERCE16 ((p[-2] << 8) + p[-1]);  \
95
1.45M
    }            \
96
1.45M
  while (0)
97
98
/* Get a 4 byte signed integer.  */
99
223k
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000)
100
101
#define NEXTLONG(p, val, ret_val)         \
102
223k
  do                  \
103
223k
    {                 \
104
223k
      p += 4;               \
105
223k
      if (!FETCH_DATA (info, p))         \
106
223k
  return ret_val;             \
107
223k
      val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8)  \
108
223k
      + p[-2]) << 8) + p[-1]);      \
109
223k
    }                  \
110
223k
  while (0)
111
112
/* Get a 4 byte unsigned integer.  */
113
#define NEXTULONG(p, val)           \
114
71.2k
  do                  \
115
71.2k
    {                 \
116
71.2k
      p += 4;               \
117
71.2k
      if (!FETCH_DATA (info, p))         \
118
71.2k
  return PRINT_INSN_ARG_MEMORY_ERROR;       \
119
71.2k
      val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8)     \
120
71.2k
         + p[-2]) << 8) + p[-1]);         \
121
71.2k
    }                  \
122
71.2k
  while (0)
123
124
/* Get a single precision float.  */
125
#define NEXTSINGLE(val, p)          \
126
0
  do                \
127
0
    {               \
128
0
      p += 4;             \
129
0
      if (!FETCH_DATA (info, p))       \
130
0
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
131
0
      floatformat_to_double (& floatformat_ieee_single_big, \
132
0
           (char *) p - 4, & val);    \
133
0
    }                \
134
0
  while (0)
135
136
/* Get a double precision float.  */
137
#define NEXTDOUBLE(val, p)          \
138
0
  do                \
139
0
    {               \
140
0
      p += 8;             \
141
0
      if (!FETCH_DATA (info, p))       \
142
0
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
143
0
      floatformat_to_double (& floatformat_ieee_double_big, \
144
0
           (char *) p - 8, & val);    \
145
0
    }                \
146
0
  while (0)
147
148
/* Get an extended precision float.  */
149
#define NEXTEXTEND(val, p)        \
150
0
  do              \
151
0
    {             \
152
0
      p += 12;            \
153
0
      if (!FETCH_DATA (info, p))     \
154
0
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
155
0
      floatformat_to_double (& floatformat_m68881_ext,  \
156
0
           (char *) p - 12, & val); \
157
0
    }              \
158
0
  while (0)
159
160
/* Need a function to convert from packed to double
161
   precision.   Actually, it's easier to print a
162
   packed number than a double anyway, so maybe
163
   there should be a special case to handle this... */
164
#define NEXTPACKED(p, val)      \
165
0
  do            \
166
0
    {           \
167
0
      p += 12;          \
168
0
      if (!FETCH_DATA (info, p))   \
169
0
  return PRINT_INSN_ARG_MEMORY_ERROR; \
170
0
      val = 0.0;        \
171
0
    }            \
172
0
  while (0)
173
174

175
/* Maximum length of an instruction.  */
176
#define MAXLEN 22
177
178
struct private
179
{
180
  /* Points to first byte not fetched.  */
181
  bfd_byte *max_fetched;
182
  bfd_byte the_buffer[MAXLEN];
183
  bfd_vma insn_start;
184
};
185
186
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
187
   to ADDR (exclusive) are valid.  Returns 1 for success, 0 on memory
188
   error.  */
189
#define FETCH_DATA(info, addr) \
190
60.3M
  ((addr) <= ((struct private *) (info->private_data))->max_fetched \
191
60.3M
   ? 1 : fetch_data ((info), (addr)))
192
193
static int
194
fetch_data (struct disassemble_info *info, bfd_byte *addr)
195
5.79M
{
196
5.79M
  int status;
197
5.79M
  struct private *priv = (struct private *)info->private_data;
198
5.79M
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
199
200
5.79M
  status = (*info->read_memory_func) (start,
201
5.79M
              priv->max_fetched,
202
5.79M
              addr - priv->max_fetched,
203
5.79M
              info);
204
5.79M
  if (status != 0)
205
30.2k
    {
206
30.2k
      (*info->memory_error_func) (status, start, info);
207
30.2k
      return 0;
208
30.2k
    }
209
5.76M
  else
210
5.76M
    priv->max_fetched = addr;
211
5.76M
  return 1;
212
5.79M
}
213

214
/* This function is used to print to the bit-bucket.  */
215
static int
216
dummy_printer (void *file ATTRIBUTE_UNUSED,
217
         enum disassembler_style style ATTRIBUTE_UNUSED,
218
         const char *format ATTRIBUTE_UNUSED,
219
         ...)
220
9.34M
{
221
9.34M
  return 0;
222
9.34M
}
223
224
static void
225
dummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,
226
         struct disassemble_info *info ATTRIBUTE_UNUSED)
227
299k
{
228
299k
}
229
230
/* Fetch BITS bits from a position in the instruction specified by CODE.
231
   CODE is a "place to put an argument", or 'x' for a destination
232
   that is a general address (mode and register).
233
   BUFFER contains the instruction.
234
   Returns -1 on failure.  */
235
236
static int
237
fetch_arg (unsigned char *buffer,
238
     int code,
239
     int bits,
240
     disassemble_info *info)
241
9.96M
{
242
9.96M
  int val = 0;
243
244
9.96M
  switch (code)
245
9.96M
    {
246
9.05k
    case '/': /* MAC/EMAC mask bit.  */
247
9.05k
      val = buffer[3] >> 5;
248
9.05k
      break;
249
250
106
    case 'G': /* EMAC ACC load.  */
251
106
      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);
252
106
      break;
253
254
146
    case 'H': /* EMAC ACC !load.  */
255
146
      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);
256
146
      break;
257
258
28
    case ']': /* EMAC ACCEXT bit.  */
259
28
      val = buffer[0] >> 2;
260
28
      break;
261
262
24.2k
    case 'I': /* MAC/EMAC scale factor.  */
263
24.2k
      val = buffer[2] >> 1;
264
24.2k
      break;
265
266
50
    case 'F': /* EMAC ACCx.  */
267
50
      val = buffer[0] >> 1;
268
50
      break;
269
270
12
    case 'f':
271
12
      val = buffer[1];
272
12
      break;
273
274
6.32M
    case 's':
275
6.32M
      val = buffer[1];
276
6.32M
      break;
277
278
2.46M
    case 'd':     /* Destination, for register or quick.  */
279
2.46M
      val = (buffer[0] << 8) + buffer[1];
280
2.46M
      val >>= 9;
281
2.46M
      break;
282
283
790k
    case 'x':     /* Destination, for general arg.  */
284
790k
      val = (buffer[0] << 8) + buffer[1];
285
790k
      val >>= 6;
286
790k
      break;
287
288
0
    case 'k':
289
0
      if (! FETCH_DATA (info, buffer + 3))
290
0
  return -1;
291
0
      val = (buffer[3] >> 4);
292
0
      break;
293
294
36
    case 'C':
295
36
      if (! FETCH_DATA (info, buffer + 3))
296
0
  return -1;
297
36
      val = buffer[3];
298
36
      break;
299
300
89.5k
    case '1':
301
89.5k
      if (! FETCH_DATA (info, buffer + 3))
302
0
  return -1;
303
89.5k
      val = (buffer[2] << 8) + buffer[3];
304
89.5k
      val >>= 12;
305
89.5k
      break;
306
307
4.27k
    case '2':
308
4.27k
      if (! FETCH_DATA (info, buffer + 3))
309
0
  return -1;
310
4.27k
      val = (buffer[2] << 8) + buffer[3];
311
4.27k
      val >>= 6;
312
4.27k
      break;
313
314
76.2k
    case '3':
315
77.0k
    case 'j':
316
77.0k
      if (! FETCH_DATA (info, buffer + 3))
317
0
  return -1;
318
77.0k
      val = (buffer[2] << 8) + buffer[3];
319
77.0k
      break;
320
321
18
    case '4':
322
18
      if (! FETCH_DATA (info, buffer + 5))
323
0
  return -1;
324
18
      val = (buffer[4] << 8) + buffer[5];
325
18
      val >>= 12;
326
18
      break;
327
328
18
    case '5':
329
18
      if (! FETCH_DATA (info, buffer + 5))
330
0
  return -1;
331
18
      val = (buffer[4] << 8) + buffer[5];
332
18
      val >>= 6;
333
18
      break;
334
335
18
    case '6':
336
18
      if (! FETCH_DATA (info, buffer + 5))
337
0
  return -1;
338
18
      val = (buffer[4] << 8) + buffer[5];
339
18
      break;
340
341
907
    case '7':
342
907
      if (! FETCH_DATA (info, buffer + 3))
343
0
  return -1;
344
907
      val = (buffer[2] << 8) + buffer[3];
345
907
      val >>= 7;
346
907
      break;
347
348
3.05k
    case '8':
349
3.05k
      if (! FETCH_DATA (info, buffer + 3))
350
0
  return -1;
351
3.05k
      val = (buffer[2] << 8) + buffer[3];
352
3.05k
      val >>= 10;
353
3.05k
      break;
354
355
243
    case '9':
356
243
      if (! FETCH_DATA (info, buffer + 3))
357
0
  return -1;
358
243
      val = (buffer[2] << 8) + buffer[3];
359
243
      val >>= 5;
360
243
      break;
361
362
9.82k
    case 'e':
363
9.82k
      val = (buffer[1] >> 6);
364
9.82k
      break;
365
366
69.5k
    case 'E':
367
69.5k
      if (! FETCH_DATA (info, buffer + 3))
368
0
  return -1;
369
69.5k
      val = (buffer[2] >> 1);
370
69.5k
      break;
371
372
21.0k
    case 'm':
373
21.0k
      val = (buffer[1] & 0x40 ? 0x8 : 0)
374
21.0k
  | ((buffer[0] >> 1) & 0x7)
375
21.0k
  | (buffer[3] & 0x80 ? 0x10 : 0);
376
21.0k
      break;
377
378
9.05k
    case 'n':
379
9.05k
      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
380
9.05k
      break;
381
382
21.8k
    case 'o':
383
21.8k
      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
384
21.8k
      break;
385
386
21.0k
    case 'M':
387
21.0k
      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
388
21.0k
      break;
389
390
21.8k
    case 'N':
391
21.8k
      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
392
21.8k
      break;
393
394
3.44k
    case 'h':
395
3.44k
      val = buffer[2] >> 2;
396
3.44k
      break;
397
398
0
    default:
399
0
      abort ();
400
9.96M
    }
401
402
  /* bits is never too big.  */
403
9.96M
  return val & ((1 << bits) - 1);
404
9.96M
}
405
406
/* Check if an EA is valid for a particular code.  This is required
407
   for the EMAC instructions since the type of source address determines
408
   if it is a EMAC-load instruciton if the EA is mode 2-5, otherwise it
409
   is a non-load EMAC instruction and the bits mean register Ry.
410
   A similar case exists for the movem instructions where the register
411
   mask is interpreted differently for different EAs.  */
412
413
static bool
414
m68k_valid_ea (char code, int val)
415
6.50M
{
416
6.50M
  int mode, mask;
417
6.50M
#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \
418
6.50M
  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \
419
6.50M
   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)
420
421
6.50M
  switch (code)
422
6.50M
    {
423
1.04M
    case '*':
424
1.04M
      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);
425
1.04M
      break;
426
305k
    case '~':
427
305k
      mask = M (0,0,1,1,1,1,1,1,1,0,0,0);
428
305k
      break;
429
663k
    case '%':
430
663k
      mask = M (1,1,1,1,1,1,1,1,1,0,0,0);
431
663k
      break;
432
1.04M
    case ';':
433
1.04M
      mask = M (1,0,1,1,1,1,1,1,1,1,1,1);
434
1.04M
      break;
435
17.0k
    case '@':
436
17.0k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,0);
437
17.0k
      break;
438
49.5k
    case '!':
439
49.5k
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
440
49.5k
      break;
441
13.3k
    case '&':
442
13.3k
      mask = M (0,0,1,0,0,1,1,1,1,0,0,0);
443
13.3k
      break;
444
3.04M
    case '$':
445
3.04M
      mask = M (1,0,1,1,1,1,1,1,1,0,0,0);
446
3.04M
      break;
447
1.61k
    case '?':
448
1.61k
      mask = M (1,0,1,0,0,1,1,1,1,0,0,0);
449
1.61k
      break;
450
3.97k
    case '/':
451
3.97k
      mask = M (1,0,1,0,0,1,1,1,1,1,1,0);
452
3.97k
      break;
453
0
    case '|':
454
0
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
455
0
      break;
456
13.7k
    case '>':
457
13.7k
      mask = M (0,0,1,0,1,1,1,1,1,0,0,0);
458
13.7k
      break;
459
15.5k
    case '<':
460
15.5k
      mask = M (0,0,1,1,0,1,1,1,1,1,1,0);
461
15.5k
      break;
462
46.3k
    case 'm':
463
46.3k
      mask = M (1,1,1,1,1,0,0,0,0,0,0,0);
464
46.3k
      break;
465
82.1k
    case 'n':
466
82.1k
      mask = M (0,0,0,0,0,1,0,0,0,1,0,0);
467
82.1k
      break;
468
49.7k
    case 'o':
469
49.7k
      mask = M (0,0,0,0,0,0,1,1,1,0,1,1);
470
49.7k
      break;
471
83.3k
    case 'p':
472
83.3k
      mask = M (1,1,1,1,1,1,0,0,0,0,0,0);
473
83.3k
      break;
474
8.32k
    case 'q':
475
8.32k
      mask = M (1,0,1,1,1,1,0,0,0,0,0,0);
476
8.32k
      break;
477
5.50k
    case 'v':
478
5.50k
      mask = M (1,0,1,1,1,1,0,1,1,0,0,0);
479
5.50k
      break;
480
0
    case 'b':
481
0
      mask = M (1,0,1,1,1,1,0,0,0,1,0,0);
482
0
      break;
483
0
    case 'w':
484
0
      mask = M (0,0,1,1,1,1,0,0,0,1,0,0);
485
0
      break;
486
3.37k
    case 'y':
487
3.37k
      mask = M (0,0,1,0,0,1,0,0,0,0,0,0);
488
3.37k
      break;
489
1
    case 'z':
490
1
      mask = M (0,0,1,0,0,1,0,0,0,1,0,0);
491
1
      break;
492
14.3k
    case '4':
493
14.3k
      mask = M (0,0,1,1,1,1,0,0,0,0,0,0);
494
14.3k
      break;
495
0
    default:
496
0
      abort ();
497
6.50M
    }
498
6.50M
#undef M
499
500
6.50M
  mode = (val >> 3) & 7;
501
6.50M
  if (mode == 7)
502
508k
    mode += val & 7;
503
6.50M
  return (mask & (1 << mode)) != 0;
504
6.50M
}
505
506
/* Print a base register REGNO and displacement DISP, on INFO->STREAM.
507
   REGNO = -1 for pc, -2 for none (suppressed).  */
508
509
static void
510
print_base (int regno, bfd_vma disp, disassemble_info *info)
511
465k
{
512
465k
  if (regno == -1)
513
18.9k
    {
514
18.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
515
18.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
516
18.9k
      (*info->print_address_func) (disp, info);
517
18.9k
    }
518
447k
  else
519
447k
    {
520
447k
      if (regno == -3)
521
4.92k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
522
4.92k
              "%%zpc");
523
442k
      else if (regno != -2)
524
359k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
525
359k
              "%s", reg_names[regno]);
526
447k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
527
447k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
528
447k
            "%" PRIx64, (uint64_t) disp);
529
447k
    }
530
465k
}
531
532
/* Print the index register of an indexed argument, as encoded in the
533
   extension word.  */
534
535
static void
536
print_index_register (int ext, disassemble_info *info)
537
369k
{
538
369k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
539
369k
        "%s", reg_names[(ext >> 12) & 0xf]);
540
369k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
541
369k
        ":%c", ext & 0x800 ? 'l' : 'w');
542
369k
  if ((ext >> 9) & 3)
543
234k
    {
544
234k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
545
234k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
546
234k
            "%d", 1 << ((ext >> 9) & 3));
547
234k
    }
548
369k
}
549
550
/* Print an indexed argument.  The base register is BASEREG (-1 for pc).
551
   P points to extension word, in buffer.
552
   ADDR is the nominal core address of that extension word.
553
   Returns NULL upon error.  */
554
555
static unsigned char *
556
print_indexed (int basereg,
557
         unsigned char *p,
558
         bfd_vma addr,
559
         disassemble_info *info)
560
466k
{
561
466k
  int word;
562
466k
  bfd_vma base_disp;
563
466k
  bfd_vma outer_disp;
564
466k
  bool print_index = true;
565
566
466k
  NEXTWORD (p, word, NULL);
567
568
  /* Handle the 68000 style of indexing.  */
569
570
466k
  if ((word & 0x100) == 0)
571
269k
    {
572
269k
      base_disp = word & 0xff;
573
269k
      if ((base_disp & 0x80) != 0)
574
89.7k
  base_disp -= 0x100;
575
269k
      if (basereg == -1)
576
11.7k
  base_disp += addr;
577
269k
      print_base (basereg, base_disp, info);
578
269k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
579
269k
      print_index_register (word, info);
580
269k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
581
269k
      return p;
582
269k
    }
583
584
  /* Handle the generalized kind.  */
585
  /* First, compute the displacement to add to the base register.  */
586
196k
  if (word & 0200)
587
88.0k
    {
588
88.0k
      if (basereg == -1)
589
4.92k
  basereg = -3;
590
83.1k
      else
591
83.1k
  basereg = -2;
592
88.0k
    }
593
196k
  if (word & 0100)
594
96.4k
    print_index = false;
595
196k
  base_disp = 0;
596
196k
  switch ((word >> 4) & 3)
597
196k
    {
598
53.7k
    case 2:
599
53.7k
      NEXTWORD (p, base_disp, NULL);
600
53.7k
      break;
601
53.7k
    case 3:
602
45.6k
      NEXTLONG (p, base_disp, NULL);
603
196k
    }
604
196k
  if (basereg == -1)
605
7.20k
    base_disp += addr;
606
607
  /* Handle single-level case (not indirect).  */
608
196k
  if ((word & 7) == 0)
609
30.7k
    {
610
30.7k
      print_base (basereg, base_disp, info);
611
30.7k
      if (print_index)
612
19.8k
  {
613
19.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
614
19.8k
    print_index_register (word, info);
615
19.8k
  }
616
30.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
617
30.7k
      return p;
618
30.7k
    }
619
620
  /* Two level.  Compute displacement to add after indirection.  */
621
165k
  outer_disp = 0;
622
165k
  switch (word & 3)
623
165k
    {
624
51.1k
    case 2:
625
51.1k
      NEXTWORD (p, outer_disp, NULL);
626
51.0k
      break;
627
51.0k
    case 3:
628
45.3k
      NEXTLONG (p, outer_disp, NULL);
629
165k
    }
630
631
165k
  print_base (basereg, base_disp, info);
632
165k
  if ((word & 4) == 0 && print_index)
633
32.6k
    {
634
32.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
635
32.6k
      print_index_register (word, info);
636
32.6k
      print_index = false;
637
32.6k
    }
638
165k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
639
165k
        ")@(");
640
165k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
641
165k
        "%" PRIx64, (uint64_t) outer_disp);
642
165k
  if (print_index)
643
47.6k
    {
644
47.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
645
47.6k
      print_index_register (word, info);
646
47.6k
    }
647
165k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
648
649
165k
  return p;
650
165k
}
651
652
#define FETCH_ARG(size, val)        \
653
3.36M
  do              \
654
3.36M
    {             \
655
3.36M
      val = fetch_arg (buffer, place, size, info);  \
656
3.36M
      if (val < 0)         \
657
3.36M
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
658
3.36M
    }             \
659
3.36M
  while (0)
660
661
/* Returns number of bytes "eaten" by the operand, or
662
   return enum print_insn_arg_error.  ADDR is the pc for this arg to be
663
   relative to.  */
664
665
static int
666
print_insn_arg (const char *d,
667
    unsigned char *buffer,
668
    unsigned char *p0,
669
    bfd_vma addr,
670
    disassemble_info *info)
671
12.7M
{
672
12.7M
  int val = 0;
673
12.7M
  int place = d[1];
674
12.7M
  unsigned char *p = p0;
675
12.7M
  int regno;
676
12.7M
  const char *regname;
677
12.7M
  unsigned char *p1;
678
12.7M
  double flval;
679
12.7M
  int flt_p;
680
12.7M
  bfd_signed_vma disp;
681
12.7M
  unsigned int uval;
682
683
12.7M
  switch (*d)
684
12.7M
    {
685
9.82k
    case 'c':   /* Cache identifier.  */
686
9.82k
      {
687
9.82k
        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
688
9.82k
        FETCH_ARG (2, val);
689
9.82k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
690
9.82k
              "%s", cacheFieldName[val]);
691
9.82k
        break;
692
9.82k
      }
693
694
14.0k
    case 'a':   /* Address register indirect only. Cf. case '+'.  */
695
14.0k
      {
696
14.0k
  FETCH_ARG (3, val);
697
14.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
698
14.0k
              reg_names[val + 8]);
699
14.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
700
14.0k
        break;
701
14.0k
      }
702
703
2.76k
    case '_':   /* 32-bit absolute address for move16.  */
704
2.76k
      {
705
2.76k
        NEXTULONG (p, uval);
706
2.76k
  (*info->print_address_func) (uval, info);
707
2.76k
        break;
708
2.76k
      }
709
710
7.25k
    case 'C':
711
7.25k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
712
7.25k
      break;
713
714
8.03k
    case 'S':
715
8.03k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
716
8.03k
      break;
717
718
488
    case 'U':
719
488
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
720
488
      break;
721
722
1.10k
    case 'E':
723
1.10k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
724
1.10k
      break;
725
726
2.10k
    case 'G':
727
2.10k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
728
2.10k
      break;
729
730
2.94k
    case 'H':
731
2.94k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
732
2.94k
      break;
733
734
776
    case 'J':
735
776
      {
736
  /* FIXME: There's a problem here, different m68k processors call the
737
     same address different names.  The tables below try to get it right
738
     using info->mach, but only for v4e.  */
739
776
  struct regname { char * name; int value; };
740
776
  static const struct regname names[] =
741
776
    {
742
776
      {"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
743
776
      {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
744
776
      {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
745
776
      {"%rgpiobar", 0x009}, {"%acr4",0x00c},
746
776
      {"%acr5",0x00d}, {"%acr6",0x00e}, {"%acr7", 0x00f},
747
776
      {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
748
776
      {"%msp", 0x803}, {"%isp", 0x804},
749
776
      {"%pc", 0x80f},
750
      /* Reg c04 is sometimes called flashbar or rambar.
751
         Reg c05 is also sometimes called rambar.  */
752
776
      {"%rambar0", 0xc04}, {"%rambar1", 0xc05},
753
754
      /* reg c0e is sometimes called mbar2 or secmbar.
755
         reg c0f is sometimes called mbar.  */
756
776
      {"%mbar0", 0xc0e}, {"%mbar1", 0xc0f},
757
758
      /* Should we be calling this psr like we do in case 'Y'?  */
759
776
      {"%mmusr",0x805},
760
761
776
      {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808},
762
763
      /* Fido added these.  */
764
776
      {"%cac", 0xffe}, {"%mbo", 0xfff}
765
776
  };
766
  /* Alternate names for v4e (MCF5407/5445x/MCF547x/MCF548x), at least.  */
767
776
  static const struct regname names_v4e[] =
768
776
    {
769
776
      {"%asid",0x003}, {"%acr0",0x004}, {"%acr1",0x005},
770
776
      {"%acr2",0x006}, {"%acr3",0x007}, {"%mmubar",0x008},
771
776
    };
772
776
  unsigned int arch_mask;
773
774
776
  arch_mask = bfd_m68k_mach_to_features (info->mach);
775
776
  FETCH_ARG (12, val);
776
776
  if (arch_mask & (mcfisa_b | mcfisa_c))
777
0
    {
778
0
      for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
779
0
        if (names_v4e[regno].value == val)
780
0
    {
781
0
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
782
0
                 "%s", names_v4e[regno].name);
783
0
      break;
784
0
    }
785
0
      if (regno >= 0)
786
0
        break;
787
0
    }
788
23.0k
  for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
789
23.0k
    if (names[regno].value == val)
790
770
      {
791
770
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
792
770
              "%s", names[regno].name);
793
770
        break;
794
770
      }
795
776
  if (regno < 0)
796
6
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
797
776
      }
798
0
      break;
799
800
348k
    case 'Q':
801
348k
      FETCH_ARG (3, val);
802
      /* 0 means 8, except for the bkpt instruction... */
803
348k
      if (val == 0 && d[1] != 's')
804
45.4k
  val = 8;
805
348k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
806
348k
            "#%d", val);
807
348k
      break;
808
809
19.6k
    case 'x':
810
19.6k
      FETCH_ARG (3, val);
811
      /* 0 means -1.  */
812
19.6k
      if (val == 0)
813
2.06k
  val = -1;
814
19.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
815
19.6k
            "#%d", val);
816
19.6k
      break;
817
818
69.5k
    case 'j':
819
69.5k
      FETCH_ARG (3, val);
820
69.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
821
69.5k
            "#%d", val+1);
822
69.5k
      break;
823
824
69.3k
    case 'K':
825
69.3k
      FETCH_ARG (9, val);
826
69.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
827
69.3k
            "#%d", val);
828
69.3k
      break;
829
830
178k
    case 'M':
831
178k
      if (place == 'h')
832
3.44k
  {
833
3.44k
    static char *const scalefactor_name[] = { "<<", ">>" };
834
835
3.44k
    FETCH_ARG (1, val);
836
3.44k
    (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
837
3.44k
          "%s", scalefactor_name[val]);
838
3.44k
  }
839
175k
      else
840
175k
  {
841
175k
    FETCH_ARG (8, val);
842
175k
    if (val & 0x80)
843
50.9k
      val = val - 0x100;
844
175k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
845
175k
          "#%d", val);
846
175k
  }
847
178k
      break;
848
849
178k
    case 'T':
850
1.54k
      FETCH_ARG (4, val);
851
1.54k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
852
1.54k
            "#%d", val);
853
1.54k
      break;
854
855
2.02M
    case 'D':
856
2.02M
      FETCH_ARG (3, val);
857
2.02M
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
858
2.02M
            "%s", reg_names[val]);
859
2.02M
      break;
860
861
256k
    case 'A':
862
256k
      FETCH_ARG (3, val);
863
256k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
864
256k
            "%s", reg_names[val + 010]);
865
256k
      break;
866
867
140k
    case 'R':
868
140k
      FETCH_ARG (4, val);
869
140k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
870
140k
            "%s", reg_names[val]);
871
140k
      break;
872
873
36
    case 'r':
874
36
      FETCH_ARG (4, regno);
875
36
      if (regno > 7)
876
0
  {
877
0
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
878
0
          "%s", reg_names[regno]);
879
0
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
880
0
  }
881
36
      else
882
36
  {
883
36
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
884
36
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
885
36
          "%s", reg_names[regno]);
886
36
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
887
36
  }
888
36
      break;
889
890
1.67k
    case 'F':
891
1.67k
      FETCH_ARG (3, val);
892
1.67k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
893
1.67k
            "%%fp%d", val);
894
1.67k
      break;
895
896
8.11k
    case 'O':
897
8.11k
      FETCH_ARG (6, val);
898
8.11k
      if (val & 0x20)
899
2.53k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
900
2.53k
              "%s", reg_names[val & 7]);
901
5.58k
      else
902
5.58k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
903
5.58k
              "%d", val);
904
8.11k
      break;
905
906
26.1k
    case '+':
907
26.1k
      FETCH_ARG (3, val);
908
26.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
909
26.1k
            "%s", reg_names[val + 8]);
910
26.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
911
26.1k
      break;
912
913
87.1k
    case '-':
914
87.1k
      FETCH_ARG (3, val);
915
87.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
916
87.1k
            "%s", reg_names[val + 8]);
917
87.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
918
87.1k
      break;
919
920
36
    case 'k':
921
36
      if (place == 'k')
922
0
  {
923
0
    FETCH_ARG (3, val);
924
0
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
925
0
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
926
0
          "%s", reg_names[val]);
927
0
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
928
0
  }
929
36
      else if (place == 'C')
930
36
  {
931
36
    FETCH_ARG (7, val);
932
36
    if (val > 63)   /* This is a signed constant.  */
933
36
      val -= 128;
934
36
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
935
36
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
936
36
          "#%d", val);
937
36
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
938
36
  }
939
0
      else
940
0
  return PRINT_INSN_ARG_INVALID_OPERAND;
941
36
      break;
942
943
2.41M
    case '#':
944
2.41M
    case '^':
945
2.41M
      p1 = buffer + (*d == '#' ? 2 : 4);
946
2.41M
      if (place == 's')
947
0
  FETCH_ARG (4, val);
948
2.41M
      else if (place == 'C')
949
0
  FETCH_ARG (7, val);
950
2.41M
      else if (place == '8')
951
0
  FETCH_ARG (3, val);
952
2.41M
      else if (place == '3')
953
0
  FETCH_ARG (8, val);
954
2.41M
      else if (place == 'b')
955
2.07M
  NEXTBYTE (p1, val);
956
333k
      else if (place == 'w' || place == 'W')
957
209k
  NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
958
124k
      else if (place == 'l')
959
124k
  NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
960
0
      else
961
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
962
963
2.41M
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
964
2.41M
            "#%d", val);
965
2.41M
      break;
966
967
419k
    case 'B':
968
419k
      if (place == 'b')
969
0
  NEXTBYTE (p, disp);
970
419k
      else if (place == 'B')
971
342k
  disp = COERCE_SIGNED_CHAR (buffer[1]);
972
77.1k
      else if (place == 'w' || place == 'W')
973
71.7k
  NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
974
5.37k
      else if (place == 'l' || place == 'L' || place == 'C')
975
2.64k
  NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
976
2.73k
      else if (place == 'g')
977
0
  {
978
0
    NEXTBYTE (buffer, disp);
979
0
    if (disp == 0)
980
0
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
981
0
    else if (disp == -1)
982
0
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
983
0
  }
984
2.73k
      else if (place == 'c')
985
2.73k
  {
986
2.73k
    if (buffer[1] & 0x40)    /* If bit six is one, long offset.  */
987
1.00k
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
988
1.73k
    else
989
1.73k
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
990
2.73k
  }
991
0
      else
992
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
993
994
419k
      (*info->print_address_func) (addr + disp, info);
995
419k
      break;
996
997
31.4k
    case 'd':
998
31.4k
      {
999
31.4k
  int val1;
1000
1001
31.4k
  NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1002
31.4k
  FETCH_ARG (3, val1);
1003
31.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
1004
31.4k
              "%s", reg_names[val1 + 8]);
1005
31.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1006
31.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1007
31.4k
              "%d", val);
1008
31.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1009
31.4k
  break;
1010
31.4k
      }
1011
1012
4
    case 's':
1013
4
      FETCH_ARG (3, val);
1014
4
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1015
4
            "%s", fpcr_names[val]);
1016
4
      break;
1017
1018
314
    case 'e':
1019
314
      FETCH_ARG (2, val);
1020
314
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1021
314
            "%%acc%d", val);
1022
314
      break;
1023
1024
28
    case 'g':
1025
28
      FETCH_ARG (1, val);
1026
28
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1027
28
            "%%accext%s", val == 0 ? "01" : "23");
1028
28
      break;
1029
1030
24.2k
    case 'i':
1031
24.2k
      FETCH_ARG (2, val);
1032
24.2k
      if (val == 1)
1033
6.15k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1034
6.15k
              "<<");
1035
18.0k
      else if (val == 3)
1036
3.89k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1037
3.89k
              ">>");
1038
14.1k
      else
1039
14.1k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1040
10.0k
      break;
1041
1042
10.0k
    case 'I':
1043
      /* Get coprocessor ID... */
1044
9.10k
      val = fetch_arg (buffer, 'd', 3, info);
1045
9.10k
      if (val < 0)
1046
0
  return PRINT_INSN_ARG_MEMORY_ERROR;
1047
9.10k
      if (val != 1)        /* Unusual coprocessor ID?  */
1048
0
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
1049
0
              "(cpid=%d) ", val);
1050
9.10k
      break;
1051
1052
14.3k
    case '4':
1053
1.05M
    case '*':
1054
1.36M
    case '~':
1055
2.02M
    case '%':
1056
3.07M
    case ';':
1057
3.09M
    case '@':
1058
3.14M
    case '!':
1059
6.18M
    case '$':
1060
6.18M
    case '?':
1061
6.18M
    case '/':
1062
6.20M
    case '&':
1063
6.20M
    case '|':
1064
6.21M
    case '<':
1065
6.23M
    case '>':
1066
6.27M
    case 'm':
1067
6.35M
    case 'n':
1068
6.40M
    case 'o':
1069
6.49M
    case 'p':
1070
6.50M
    case 'q':
1071
6.50M
    case 'v':
1072
6.50M
    case 'b':
1073
6.50M
    case 'w':
1074
6.50M
    case 'y':
1075
6.50M
    case 'z':
1076
6.50M
      if (place == 'd')
1077
790k
  {
1078
790k
    val = fetch_arg (buffer, 'x', 6, info);
1079
790k
    if (val < 0)
1080
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1081
790k
    val = ((val & 7) << 3) + ((val >> 3) & 7);
1082
790k
  }
1083
5.71M
      else
1084
5.71M
  {
1085
5.71M
    val = fetch_arg (buffer, 's', 6, info);
1086
5.71M
    if (val < 0)
1087
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1088
5.71M
  }
1089
1090
      /* If the <ea> is invalid for *d, then reject this match.  */
1091
6.50M
      if (!m68k_valid_ea (*d, val))
1092
783k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1093
1094
      /* Get register number assuming address register.  */
1095
5.72M
      regno = (val & 7) + 8;
1096
5.72M
      regname = reg_names[regno];
1097
5.72M
      switch (val >> 3)
1098
5.72M
  {
1099
2.89M
  case 0:
1100
2.89M
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1101
2.89M
          "%s", reg_names[val]);
1102
2.89M
    break;
1103
1104
151k
  case 1:
1105
151k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1106
151k
          "%s", regname);
1107
151k
    break;
1108
1109
610k
  case 2:
1110
610k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1111
610k
          "%s", regname);
1112
610k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
1113
610k
    break;
1114
1115
426k
  case 3:
1116
426k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1117
426k
          "%s", regname);
1118
426k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
1119
426k
    break;
1120
1121
535k
  case 4:
1122
535k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1123
535k
          "%s", regname);
1124
535k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
1125
535k
    break;
1126
1127
468k
  case 5:
1128
468k
    NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1129
468k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1130
468k
          "%s", regname);
1131
468k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1132
468k
    (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1133
468k
          "%d", val);
1134
468k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1135
468k
    break;
1136
1137
442k
  case 6:
1138
442k
    p = print_indexed (regno, p, addr, info);
1139
442k
    if (p == NULL)
1140
255
      return PRINT_INSN_ARG_MEMORY_ERROR;
1141
442k
    break;
1142
1143
442k
  case 7:
1144
192k
    switch (val & 7)
1145
192k
      {
1146
55.9k
      case 0:
1147
55.9k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1148
55.9k
        (*info->print_address_func) (val, info);
1149
55.9k
        break;
1150
1151
68.4k
      case 1:
1152
68.4k
        NEXTULONG (p, uval);
1153
68.4k
        (*info->print_address_func) (uval, info);
1154
68.4k
        break;
1155
1156
23.6k
      case 2:
1157
23.6k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1158
23.6k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
1159
23.6k
              "%%pc");
1160
23.6k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1161
23.6k
        (*info->print_address_func) (addr + val, info);
1162
23.6k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1163
23.6k
        break;
1164
1165
23.8k
      case 3:
1166
23.8k
        p = print_indexed (-1, p, addr, info);
1167
23.8k
        if (p == NULL)
1168
23
    return PRINT_INSN_ARG_MEMORY_ERROR;
1169
23.8k
        break;
1170
1171
23.8k
      case 4:
1172
20.6k
        flt_p = 1;  /* Assume it's a float... */
1173
20.6k
        switch (place)
1174
20.6k
        {
1175
6.02k
    case 'b':
1176
6.02k
      NEXTBYTE (p, val);
1177
6.01k
      flt_p = 0;
1178
6.01k
      break;
1179
1180
9.67k
    case 'w':
1181
9.67k
      NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1182
9.67k
      flt_p = 0;
1183
9.67k
      break;
1184
1185
4.99k
    case 'l':
1186
4.99k
      NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1187
4.98k
      flt_p = 0;
1188
4.98k
      break;
1189
1190
0
    case 'f':
1191
0
      NEXTSINGLE (flval, p);
1192
0
      break;
1193
1194
0
    case 'F':
1195
0
      NEXTDOUBLE (flval, p);
1196
0
      break;
1197
1198
0
    case 'x':
1199
0
      NEXTEXTEND (flval, p);
1200
0
      break;
1201
1202
0
    case 'p':
1203
0
      NEXTPACKED (p, flval);
1204
0
      break;
1205
1206
0
    default:
1207
0
      return PRINT_INSN_ARG_INVALID_OPERAND;
1208
20.6k
        }
1209
20.6k
        if (flt_p)  /* Print a float? */
1210
0
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1211
0
                "#0e%g", flval);
1212
20.6k
        else
1213
20.6k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1214
20.6k
                "#%d", val);
1215
20.6k
        break;
1216
1217
0
      default:
1218
0
        return PRINT_INSN_ARG_INVALID_OPERAND;
1219
192k
      }
1220
5.72M
  }
1221
1222
      /* If place is '/', then this is the case of the mask bit for
1223
   mac/emac loads. Now that the arg has been printed, grab the
1224
   mask bit and if set, add a '&' to the arg.  */
1225
5.72M
      if (place == '/')
1226
9.05k
  {
1227
9.05k
    FETCH_ARG (1, val);
1228
9.05k
    if (val)
1229
4.20k
      info->fprintf_styled_func (info->stream, dis_style_text, "&");
1230
9.05k
  }
1231
5.72M
      break;
1232
1233
5.72M
    case 'L':
1234
17.2k
    case 'l':
1235
17.2k
  if (place == 'w')
1236
17.2k
    {
1237
17.2k
      char doneany;
1238
17.2k
      p1 = buffer + 2;
1239
17.2k
      NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
1240
      /* Move the pointer ahead if this point is farther ahead
1241
         than the last.  */
1242
17.2k
      p = p1 > p ? p1 : p;
1243
17.2k
      if (val == 0)
1244
9
        {
1245
9
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1246
9
                "#0");
1247
9
    break;
1248
9
        }
1249
17.2k
      if (*d == 'l')
1250
478
        {
1251
478
    int newval = 0;
1252
1253
8.12k
    for (regno = 0; regno < 16; ++regno)
1254
7.64k
      if (val & (0x8000 >> regno))
1255
4.67k
        newval |= 1 << regno;
1256
478
    val = newval;
1257
478
        }
1258
17.2k
      val &= 0xffff;
1259
17.2k
      doneany = 0;
1260
232k
      for (regno = 0; regno < 16; ++regno)
1261
214k
        if (val & (1 << regno))
1262
70.1k
    {
1263
70.1k
      int first_regno;
1264
1265
70.1k
      if (doneany)
1266
52.8k
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1267
52.8k
              "/");
1268
70.1k
      doneany = 1;
1269
70.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1270
70.1k
            "%s", reg_names[regno]);
1271
70.1k
      first_regno = regno;
1272
131k
      while (val & (1 << (regno + 1)))
1273
61.1k
        ++regno;
1274
70.1k
      if (regno > first_regno)
1275
31.7k
        {
1276
31.7k
          (*info->fprintf_styled_func) (info->stream,
1277
31.7k
                dis_style_text, "-");
1278
31.7k
          (*info->fprintf_styled_func) (info->stream,
1279
31.7k
                dis_style_register, "%s",
1280
31.7k
                reg_names[regno]);
1281
31.7k
        }
1282
70.1k
    }
1283
17.2k
    }
1284
30
  else if (place == '3')
1285
28
    {
1286
      /* `fmovem' insn.  */
1287
28
      char doneany;
1288
1289
28
      FETCH_ARG (8, val);
1290
28
      if (val == 0)
1291
16
        {
1292
16
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1293
16
                "#0");
1294
16
    break;
1295
16
        }
1296
12
      if (*d == 'l')
1297
12
        {
1298
12
    int newval = 0;
1299
1300
108
    for (regno = 0; regno < 8; ++regno)
1301
96
      if (val & (0x80 >> regno))
1302
70
        newval |= 1 << regno;
1303
12
    val = newval;
1304
12
        }
1305
12
      val &= 0xff;
1306
12
      doneany = 0;
1307
54
      for (regno = 0; regno < 8; ++regno)
1308
42
        if (val & (1 << regno))
1309
16
    {
1310
16
      int first_regno;
1311
16
      if (doneany)
1312
4
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1313
4
              "/");
1314
16
      doneany = 1;
1315
16
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1316
16
            "%%fp%d", regno);
1317
16
      first_regno = regno;
1318
70
      while (val & (1 << (regno + 1)))
1319
54
        ++regno;
1320
16
      if (regno > first_regno)
1321
10
        {
1322
10
          (*info->fprintf_styled_func) (info->stream,
1323
10
                dis_style_text, "-");
1324
10
          (*info->fprintf_styled_func) (info->stream,
1325
10
                dis_style_register,
1326
10
                "%%fp%d", regno);
1327
10
        }
1328
16
    }
1329
12
    }
1330
2
  else if (place == '8')
1331
2
    {
1332
2
      FETCH_ARG (3, val);
1333
      /* fmoveml for FP status registers.  */
1334
2
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1335
2
            "%s", fpcr_names[val]);
1336
2
    }
1337
0
  else
1338
0
    return PRINT_INSN_ARG_INVALID_OP_TABLE;
1339
17.2k
      break;
1340
1341
17.2k
    case 'X':
1342
202
      place = '8';
1343
      /* Fall through.  */
1344
204
    case 'Y':
1345
204
    case 'Z':
1346
204
    case 'W':
1347
604
    case '0':
1348
604
    case '1':
1349
1.15k
    case '2':
1350
1.18k
    case '3':
1351
1.18k
      {
1352
1.18k
  char *name = 0;
1353
1354
1.18k
  FETCH_ARG (5, val);
1355
1.18k
  switch (val)
1356
1.18k
    {
1357
32
    case 2: name = "%tt0"; break;
1358
0
    case 3: name = "%tt1"; break;
1359
32
    case 0x10: name = "%tc"; break;
1360
274
    case 0x11: name = "%drp"; break;
1361
620
    case 0x12: name = "%srp"; break;
1362
6
    case 0x13: name = "%crp"; break;
1363
10
    case 0x14: name = "%cal"; break;
1364
6
    case 0x15: name = "%val"; break;
1365
0
    case 0x16: name = "%scc"; break;
1366
0
    case 0x17: name = "%ac"; break;
1367
2
    case 0x18: name = "%psr"; break;
1368
0
    case 0x19: name = "%pcsr"; break;
1369
36
    case 0x1c:
1370
38
    case 0x1d:
1371
38
      {
1372
38
        int break_reg = ((buffer[3] >> 2) & 7);
1373
1374
38
        (*info->fprintf_styled_func)
1375
38
    (info->stream, dis_style_register,
1376
38
     val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
1377
38
      }
1378
38
      break;
1379
164
    default:
1380
164
      (*info->fprintf_styled_func) (info->stream, dis_style_text,
1381
164
            "<mmu register %d>", val);
1382
1.18k
    }
1383
1.18k
  if (name)
1384
982
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1385
982
          "%s", name);
1386
1.18k
      }
1387
0
      break;
1388
1389
61
    case 'f':
1390
61
      {
1391
61
  int fc;
1392
1393
61
  FETCH_ARG (5, fc);
1394
61
  if (fc == 1)
1395
9
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1396
9
          "%%dfc");
1397
52
  else if (fc == 0)
1398
52
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1399
52
          "%%sfc");
1400
0
  else
1401
    /* xgettext:c-format */
1402
0
    (*info->fprintf_styled_func) (info->stream, dis_style_text,
1403
0
          _("<function code %d>"), fc);
1404
61
      }
1405
0
      break;
1406
1407
0
    case 'V':
1408
0
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
1409
0
      break;
1410
1411
1.50k
    case 't':
1412
1.50k
      {
1413
1.50k
  int level;
1414
1415
1.50k
  FETCH_ARG (3, level);
1416
1.50k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1417
1.50k
              "%d", level);
1418
1.50k
      }
1419
0
      break;
1420
1421
43.9k
    case 'u':
1422
43.9k
      {
1423
43.9k
  short is_upper = 0;
1424
43.9k
  int reg;
1425
1426
43.9k
  FETCH_ARG (5, reg);
1427
43.9k
  if (reg & 0x10)
1428
15.0k
    {
1429
15.0k
      is_upper = 1;
1430
15.0k
      reg &= 0xf;
1431
15.0k
    }
1432
43.9k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
1433
43.9k
              reg_half_names[reg],
1434
43.9k
              is_upper ? "u" : "l");
1435
43.9k
      }
1436
0
      break;
1437
1438
0
    default:
1439
0
      return PRINT_INSN_ARG_INVALID_OP_TABLE;
1440
12.7M
    }
1441
1442
11.9M
  return p - p0;
1443
12.7M
}
1444
1445
/* Try to match the current instruction to best and if so, return the
1446
   number of bytes consumed from the instruction stream, else zero.
1447
   Return -1 on memory error.  */
1448
1449
static int
1450
match_insn_m68k (bfd_vma memaddr,
1451
     disassemble_info * info,
1452
     const struct m68k_opcode * best)
1453
3.78M
{
1454
3.78M
  unsigned char *save_p;
1455
3.78M
  unsigned char *p;
1456
3.78M
  const char *d;
1457
3.78M
  const char *args = best->args;
1458
1459
3.78M
  struct private *priv = (struct private *) info->private_data;
1460
3.78M
  bfd_byte *buffer = priv->the_buffer;
1461
3.78M
  fprintf_styled_ftype save_printer = info->fprintf_styled_func;
1462
3.78M
  void (* save_print_address) (bfd_vma, struct disassemble_info *)
1463
3.78M
    = info->print_address_func;
1464
1465
3.78M
  if (*args == '.')
1466
43.2k
    args++;
1467
1468
  /* Point at first word of argument data,
1469
     and at descriptor for first argument.  */
1470
3.78M
  p = buffer + 2;
1471
1472
  /* Figure out how long the fixed-size portion of the instruction is.
1473
     The only place this is stored in the opcode table is
1474
     in the arguments--look for arguments which specify fields in the 2nd
1475
     or 3rd words of the instruction.  */
1476
11.1M
  for (d = args; *d; d += 2)
1477
7.38M
    {
1478
      /* I don't think it is necessary to be checking d[0] here;
1479
   I suspect all this could be moved to the case statement below.  */
1480
7.38M
      if (d[0] == '#')
1481
1.28M
  {
1482
1.28M
    if (d[1] == 'l' && p - buffer < 6)
1483
70.2k
      p = buffer + 6;
1484
1.21M
    else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8')
1485
1.21M
      p = buffer + 4;
1486
1.28M
  }
1487
1488
7.38M
      if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
1489
18.7k
  p = buffer + 4;
1490
1491
7.38M
      switch (d[1])
1492
7.38M
  {
1493
57.8k
  case '1':
1494
61.4k
  case '2':
1495
110k
  case '3':
1496
110k
  case '7':
1497
111k
  case '8':
1498
111k
  case '9':
1499
112k
  case 'i':
1500
112k
    if (p - buffer < 4)
1501
59.9k
      p = buffer + 4;
1502
112k
    break;
1503
9
  case '4':
1504
18
  case '5':
1505
27
  case '6':
1506
27
    if (p - buffer < 6)
1507
9
      p = buffer + 6;
1508
27
    break;
1509
7.27M
  default:
1510
7.27M
    break;
1511
7.38M
  }
1512
7.38M
    }
1513
1514
  /* pflusha is an exceptions.  It takes no arguments but is two words
1515
     long.  Recognize it by looking at the lower 16 bits of the mask.  */
1516
3.78M
  if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
1517
31.3k
    p = buffer + 4;
1518
1519
  /* lpstop is another exception.  It takes a one word argument but is
1520
     three words long.  */
1521
3.78M
  if (p - buffer < 6
1522
3.78M
      && (best->match & 0xffff) == 0xffff
1523
3.78M
      && args[0] == '#'
1524
3.78M
      && args[1] == 'w')
1525
0
    {
1526
      /* Copy the one word argument into the usual location for a one
1527
   word argument, to simplify printing it.  We can get away with
1528
   this because we know exactly what the second word is, and we
1529
   aren't going to print anything based on it.  */
1530
0
      p = buffer + 6;
1531
0
      if (!FETCH_DATA (info, p))
1532
0
  return -1;
1533
0
      buffer[2] = buffer[4];
1534
0
      buffer[3] = buffer[5];
1535
0
    }
1536
1537
3.78M
  if (!FETCH_DATA (info, p))
1538
223
    return -1;
1539
1540
3.78M
  save_p = p;
1541
3.78M
  info->print_address_func = dummy_print_address;
1542
3.78M
  info->fprintf_styled_func = dummy_printer;
1543
1544
  /* We scan the operands twice.  The first time we don't print anything,
1545
     but look for errors.  */
1546
9.98M
  for (d = args; *d; d += 2)
1547
6.99M
    {
1548
6.99M
      int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1549
1550
6.99M
      if (eaten >= 0)
1551
6.19M
  p += eaten;
1552
798k
      else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
1553
798k
         || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
1554
798k
  {
1555
798k
    info->fprintf_styled_func = save_printer;
1556
798k
    info->print_address_func = save_print_address;
1557
798k
    return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
1558
798k
  }
1559
0
      else
1560
0
  {
1561
    /* We must restore the print functions before trying to print the
1562
       error message.  */
1563
0
    info->fprintf_styled_func = save_printer;
1564
0
    info->print_address_func = save_print_address;
1565
0
    info->fprintf_styled_func (info->stream, dis_style_text,
1566
             /* xgettext:c-format */
1567
0
             _("<internal error in opcode table: %s %s>\n"),
1568
0
             best->name, best->args);
1569
0
    return 2;
1570
0
  }
1571
6.99M
    }
1572
1573
2.98M
  p = save_p;
1574
2.98M
  info->fprintf_styled_func = save_printer;
1575
2.98M
  info->print_address_func = save_print_address;
1576
1577
2.98M
  d = args;
1578
1579
2.98M
  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
1580
1581
2.98M
  if (*d)
1582
2.98M
    info->fprintf_styled_func (info->stream, dis_style_text, " ");
1583
1584
8.74M
  while (*d)
1585
5.75M
    {
1586
5.75M
      p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1587
5.75M
      d += 2;
1588
1589
5.75M
      if (*d && *(d - 2) != 'I' && *d != 'k')
1590
2.76M
  info->fprintf_styled_func (info->stream, dis_style_text, ",");
1591
5.75M
    }
1592
1593
2.98M
  return p - buffer;
1594
3.78M
}
1595
1596
/* Try to interpret the instruction at address MEMADDR as one that
1597
   can execute on a processor with the features given by ARCH_MASK.
1598
   If successful, print the instruction to INFO->STREAM and return
1599
   its length in bytes.  Return 0 otherwise.  Return -1 on memory
1600
   error.  */
1601
1602
static int
1603
m68k_scan_mask (bfd_vma memaddr, disassemble_info *info,
1604
    unsigned int arch_mask)
1605
4.36M
{
1606
4.36M
  int i;
1607
4.36M
  const char *d;
1608
4.36M
  static const struct m68k_opcode **opcodes[16];
1609
4.36M
  static int numopcodes[16];
1610
4.36M
  int val;
1611
4.36M
  int major_opcode;
1612
1613
4.36M
  struct private *priv = (struct private *) info->private_data;
1614
4.36M
  bfd_byte *buffer = priv->the_buffer;
1615
1616
4.36M
  if (!opcodes[0])
1617
1
    {
1618
      /* Speed up the matching by sorting the opcode
1619
   table on the upper four bits of the opcode.  */
1620
1
      const struct m68k_opcode **opc_pointer[16];
1621
1622
      /* First count how many opcodes are in each of the sixteen buckets.  */
1623
1.90k
      for (i = 0; i < m68k_numopcodes; i++)
1624
1.90k
  numopcodes[(m68k_opcodes[i].opcode >> 28) & 15]++;
1625
1626
      /* Then create a sorted table of pointers
1627
   that point into the unsorted table.  */
1628
1
      opc_pointer[0] = xmalloc (sizeof (struct m68k_opcode *)
1629
1
        * m68k_numopcodes);
1630
1
      opcodes[0] = opc_pointer[0];
1631
1632
16
      for (i = 1; i < 16; i++)
1633
15
  {
1634
15
    opc_pointer[i] = opc_pointer[i - 1] + numopcodes[i - 1];
1635
15
    opcodes[i] = opc_pointer[i];
1636
15
  }
1637
1638
1.90k
      for (i = 0; i < m68k_numopcodes; i++)
1639
1.90k
  *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i];
1640
1
    }
1641
1642
4.36M
  if (!FETCH_DATA (info, buffer + 2))
1643
670
    return -1;
1644
4.36M
  major_opcode = (buffer[0] >> 4) & 15;
1645
1646
600M
  for (i = 0; i < numopcodes[major_opcode]; i++)
1647
599M
    {
1648
599M
      const struct m68k_opcode *opc = opcodes[major_opcode][i];
1649
599M
      unsigned long opcode = opc->opcode;
1650
599M
      unsigned long match = opc->match;
1651
599M
      const char *args = opc->args;
1652
1653
599M
      if (*args == '.')
1654
5.17M
  args++;
1655
1656
599M
      if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
1657
599M
    && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
1658
    /* Only fetch the next two bytes if we need to.  */
1659
599M
    && (((0xffff & match) == 0)
1660
28.6M
        ||
1661
28.6M
        (FETCH_DATA (info, buffer + 4)
1662
24.0M
         && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
1663
24.0M
         && ((0xff & buffer[3] & match) == (0xff & opcode)))
1664
28.6M
        )
1665
599M
    && (opc->arch & arch_mask) != 0)
1666
3.85M
  {
1667
    /* Don't use for printout the variants of divul and divsl
1668
       that have the same register number in two places.
1669
       The more general variants will match instead.  */
1670
11.3M
    for (d = args; *d; d += 2)
1671
7.53M
      if (d[1] == 'D')
1672
981
        break;
1673
1674
    /* Don't use for printout the variants of most floating
1675
       point coprocessor instructions which use the same
1676
       register number in two places, as above.  */
1677
3.85M
    if (*d == '\0')
1678
11.3M
      for (d = args; *d; d += 2)
1679
7.53M
        if (d[1] == 't')
1680
1.41k
    break;
1681
1682
    /* Don't match fmovel with more than one register;
1683
       wait for fmoveml.  */
1684
3.85M
    if (*d == '\0')
1685
3.85M
      {
1686
11.3M
        for (d = args; *d; d += 2)
1687
7.53M
    {
1688
7.53M
      if (d[0] == 's' && d[1] == '8')
1689
1.10k
        {
1690
1.10k
          val = fetch_arg (buffer, d[1], 3, info);
1691
1.10k
          if (val < 0)
1692
0
      return 0;
1693
1.10k
          if ((val & (val - 1)) != 0)
1694
1.08k
      break;
1695
1.10k
        }
1696
7.53M
    }
1697
3.85M
      }
1698
1699
    /* Don't match FPU insns with non-default coprocessor ID.  */
1700
3.85M
    if (*d == '\0')
1701
3.85M
      {
1702
11.2M
        for (d = args; *d; d += 2)
1703
7.45M
    {
1704
7.45M
      if (d[0] == 'I')
1705
73.8k
        {
1706
73.8k
          val = fetch_arg (buffer, 'd', 3, info);
1707
73.8k
          if (val != 1)
1708
68.5k
      break;
1709
73.8k
        }
1710
7.45M
    }
1711
3.85M
      }
1712
1713
3.85M
    if (*d == '\0')
1714
3.78M
      if ((val = match_insn_m68k (memaddr, info, opc)))
1715
2.98M
        return val;
1716
3.85M
  }
1717
599M
    }
1718
1.37M
  return 0;
1719
4.36M
}
1720
1721
/* Print the m68k instruction at address MEMADDR in debugged memory,
1722
   on INFO->STREAM.  Returns length of the instruction, in bytes.  */
1723
1724
int
1725
print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
1726
3.61M
{
1727
3.61M
  unsigned int arch_mask;
1728
3.61M
  struct private priv;
1729
3.61M
  int val;
1730
1731
3.61M
  bfd_byte *buffer = priv.the_buffer;
1732
1733
3.61M
  info->private_data = & priv;
1734
  /* Tell objdump to use two bytes per chunk
1735
     and six bytes per line for displaying raw data.  */
1736
3.61M
  info->bytes_per_chunk = 2;
1737
3.61M
  info->bytes_per_line = 6;
1738
3.61M
  info->display_endian = BFD_ENDIAN_BIG;
1739
3.61M
  priv.max_fetched = priv.the_buffer;
1740
3.61M
  priv.insn_start = memaddr;
1741
1742
3.61M
  arch_mask = bfd_m68k_mach_to_features (info->mach);
1743
3.61M
  if (!arch_mask)
1744
3.56M
    {
1745
      /* First try printing an m680x0 instruction.  Try printing a Coldfire
1746
   one if that fails.  */
1747
3.56M
      val = m68k_scan_mask (memaddr, info, m68k_mask);
1748
3.56M
      if (val <= 0)
1749
755k
  val = m68k_scan_mask (memaddr, info, mcf_mask);
1750
3.56M
    }
1751
47.6k
  else
1752
47.6k
    {
1753
47.6k
      val = m68k_scan_mask (memaddr, info, arch_mask);
1754
47.6k
    }
1755
1756
3.61M
  if (val == 0)
1757
621k
    {
1758
      /* Handle undefined instructions.  */
1759
621k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
1760
621k
         ".short");
1761
621k
      info->fprintf_styled_func (info->stream, dis_style_text, " ");
1762
621k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
1763
621k
         "0x%04x", (buffer[0] << 8) + buffer[1]);
1764
621k
    }
1765
1766
3.61M
  return val ? val : 2;
1767
3.61M
}