Coverage Report

Created: 2024-05-21 06:29

/src/binutils-gdb/opcodes/m68k-dis.c
Line
Count
Source (jump to first uncovered line)
1
/* Print Motorola 68k instructions.
2
   Copyright (C) 1986-2024 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
544k
#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
436k
  do            \
77
436k
    {           \
78
436k
      p += 2;         \
79
436k
      if (!FETCH_DATA (info, p))   \
80
436k
  return PRINT_INSN_ARG_MEMORY_ERROR; \
81
436k
      val = COERCE_SIGNED_CHAR (p[-1]);   \
82
436k
    }            \
83
436k
  while (0)
84
85
/* Get a 2 byte signed integer.  */
86
342k
#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
87
88
#define NEXTWORD(p, val, ret_val)   \
89
343k
  do            \
90
343k
    {           \
91
343k
      p += 2;         \
92
343k
      if (!FETCH_DATA (info, p))   \
93
343k
  return ret_val;       \
94
343k
      val = COERCE16 ((p[-2] << 8) + p[-1]);  \
95
342k
    }            \
96
343k
  while (0)
97
98
/* Get a 4 byte signed integer.  */
99
59.5k
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000)
100
101
#define NEXTLONG(p, val, ret_val)         \
102
59.6k
  do                  \
103
59.6k
    {                 \
104
59.6k
      p += 4;               \
105
59.6k
      if (!FETCH_DATA (info, p))         \
106
59.6k
  return ret_val;             \
107
59.6k
      val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8)  \
108
59.5k
      + p[-2]) << 8) + p[-1]);      \
109
59.5k
    }                  \
110
59.6k
  while (0)
111
112
/* Get a 4 byte unsigned integer.  */
113
#define NEXTULONG(p, val)           \
114
11.4k
  do                  \
115
11.4k
    {                 \
116
11.4k
      p += 4;               \
117
11.4k
      if (!FETCH_DATA (info, p))         \
118
11.4k
  return PRINT_INSN_ARG_MEMORY_ERROR;       \
119
11.4k
      val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8)     \
120
11.4k
         + p[-2]) << 8) + p[-1]);         \
121
11.4k
    }                  \
122
11.4k
  while (0)
123
124
/* Get a single precision float.  */
125
#define NEXTSINGLE(val, p)          \
126
199
  do                \
127
199
    {               \
128
199
      p += 4;             \
129
199
      if (!FETCH_DATA (info, p))       \
130
199
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
131
199
      floatformat_to_double (& floatformat_ieee_single_big, \
132
198
           (char *) p - 4, & val);    \
133
198
    }                \
134
199
  while (0)
135
136
/* Get a double precision float.  */
137
#define NEXTDOUBLE(val, p)          \
138
692
  do                \
139
692
    {               \
140
692
      p += 8;             \
141
692
      if (!FETCH_DATA (info, p))       \
142
692
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
143
692
      floatformat_to_double (& floatformat_ieee_double_big, \
144
692
           (char *) p - 8, & val);    \
145
692
    }                \
146
692
  while (0)
147
148
/* Get an extended precision float.  */
149
#define NEXTEXTEND(val, p)        \
150
506
  do              \
151
506
    {             \
152
506
      p += 12;            \
153
506
      if (!FETCH_DATA (info, p))     \
154
506
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
155
506
      floatformat_to_double (& floatformat_m68881_ext,  \
156
506
           (char *) p - 12, & val); \
157
506
    }              \
158
506
  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
371
  do            \
166
371
    {           \
167
371
      p += 12;          \
168
371
      if (!FETCH_DATA (info, p))   \
169
371
  return PRINT_INSN_ARG_MEMORY_ERROR; \
170
371
      val = 0.0;        \
171
370
    }            \
172
371
  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
24.2M
  ((addr) <= ((struct private *) (info->private_data))->max_fetched \
191
24.2M
   ? 1 : fetch_data ((info), (addr)))
192
193
static int
194
fetch_data (struct disassemble_info *info, bfd_byte *addr)
195
1.43M
{
196
1.43M
  int status;
197
1.43M
  struct private *priv = (struct private *)info->private_data;
198
1.43M
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
199
200
1.43M
  status = (*info->read_memory_func) (start,
201
1.43M
              priv->max_fetched,
202
1.43M
              addr - priv->max_fetched,
203
1.43M
              info);
204
1.43M
  if (status != 0)
205
12.8k
    {
206
12.8k
      (*info->memory_error_func) (status, start, info);
207
12.8k
      return 0;
208
12.8k
    }
209
1.42M
  else
210
1.42M
    priv->max_fetched = addr;
211
1.42M
  return 1;
212
1.43M
}
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
2.27M
{
221
2.27M
  return 0;
222
2.27M
}
223
224
static void
225
dummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,
226
         struct disassemble_info *info ATTRIBUTE_UNUSED)
227
78.5k
{
228
78.5k
}
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
2.49M
{
242
2.49M
  int val = 0;
243
244
2.49M
  switch (code)
245
2.49M
    {
246
6.17k
    case '/': /* MAC/EMAC mask bit.  */
247
6.17k
      val = buffer[3] >> 5;
248
6.17k
      break;
249
250
798
    case 'G': /* EMAC ACC load.  */
251
798
      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);
252
798
      break;
253
254
616
    case 'H': /* EMAC ACC !load.  */
255
616
      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);
256
616
      break;
257
258
74
    case ']': /* EMAC ACCEXT bit.  */
259
74
      val = buffer[0] >> 2;
260
74
      break;
261
262
10.4k
    case 'I': /* MAC/EMAC scale factor.  */
263
10.4k
      val = buffer[2] >> 1;
264
10.4k
      break;
265
266
262
    case 'F': /* EMAC ACCx.  */
267
262
      val = buffer[0] >> 1;
268
262
      break;
269
270
76
    case 'f':
271
76
      val = buffer[1];
272
76
      break;
273
274
1.50M
    case 's':
275
1.50M
      val = buffer[1];
276
1.50M
      break;
277
278
589k
    case 'd':     /* Destination, for register or quick.  */
279
589k
      val = (buffer[0] << 8) + buffer[1];
280
589k
      val >>= 9;
281
589k
      break;
282
283
230k
    case 'x':     /* Destination, for general arg.  */
284
230k
      val = (buffer[0] << 8) + buffer[1];
285
230k
      val >>= 6;
286
230k
      break;
287
288
72
    case 'k':
289
72
      if (! FETCH_DATA (info, buffer + 3))
290
0
  return -1;
291
72
      val = (buffer[3] >> 4);
292
72
      break;
293
294
268
    case 'C':
295
268
      if (! FETCH_DATA (info, buffer + 3))
296
0
  return -1;
297
268
      val = buffer[3];
298
268
      break;
299
300
35.1k
    case '1':
301
35.1k
      if (! FETCH_DATA (info, buffer + 3))
302
0
  return -1;
303
35.1k
      val = (buffer[2] << 8) + buffer[3];
304
35.1k
      val >>= 12;
305
35.1k
      break;
306
307
1.46k
    case '2':
308
1.46k
      if (! FETCH_DATA (info, buffer + 3))
309
0
  return -1;
310
1.46k
      val = (buffer[2] << 8) + buffer[3];
311
1.46k
      val >>= 6;
312
1.46k
      break;
313
314
29.7k
    case '3':
315
31.2k
    case 'j':
316
31.2k
      if (! FETCH_DATA (info, buffer + 3))
317
0
  return -1;
318
31.2k
      val = (buffer[2] << 8) + buffer[3];
319
31.2k
      break;
320
321
70
    case '4':
322
70
      if (! FETCH_DATA (info, buffer + 5))
323
0
  return -1;
324
70
      val = (buffer[4] << 8) + buffer[5];
325
70
      val >>= 12;
326
70
      break;
327
328
70
    case '5':
329
70
      if (! FETCH_DATA (info, buffer + 5))
330
0
  return -1;
331
70
      val = (buffer[4] << 8) + buffer[5];
332
70
      val >>= 6;
333
70
      break;
334
335
70
    case '6':
336
70
      if (! FETCH_DATA (info, buffer + 5))
337
0
  return -1;
338
70
      val = (buffer[4] << 8) + buffer[5];
339
70
      break;
340
341
2.53k
    case '7':
342
2.53k
      if (! FETCH_DATA (info, buffer + 3))
343
0
  return -1;
344
2.53k
      val = (buffer[2] << 8) + buffer[3];
345
2.53k
      val >>= 7;
346
2.53k
      break;
347
348
7.42k
    case '8':
349
7.42k
      if (! FETCH_DATA (info, buffer + 3))
350
0
  return -1;
351
7.42k
      val = (buffer[2] << 8) + buffer[3];
352
7.42k
      val >>= 10;
353
7.42k
      break;
354
355
45
    case '9':
356
45
      if (! FETCH_DATA (info, buffer + 3))
357
0
  return -1;
358
45
      val = (buffer[2] << 8) + buffer[3];
359
45
      val >>= 5;
360
45
      break;
361
362
2.45k
    case 'e':
363
2.45k
      val = (buffer[1] >> 6);
364
2.45k
      break;
365
366
26.7k
    case 'E':
367
26.7k
      if (! FETCH_DATA (info, buffer + 3))
368
0
  return -1;
369
26.7k
      val = (buffer[2] >> 1);
370
26.7k
      break;
371
372
6.21k
    case 'm':
373
6.21k
      val = (buffer[1] & 0x40 ? 0x8 : 0)
374
6.21k
  | ((buffer[0] >> 1) & 0x7)
375
6.21k
  | (buffer[3] & 0x80 ? 0x10 : 0);
376
6.21k
      break;
377
378
6.17k
    case 'n':
379
6.17k
      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
380
6.17k
      break;
381
382
9.93k
    case 'o':
383
9.93k
      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
384
9.93k
      break;
385
386
6.21k
    case 'M':
387
6.21k
      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
388
6.21k
      break;
389
390
9.93k
    case 'N':
391
9.93k
      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
392
9.93k
      break;
393
394
546
    case 'h':
395
546
      val = buffer[2] >> 2;
396
546
      break;
397
398
0
    default:
399
0
      abort ();
400
2.49M
    }
401
402
  /* bits is never too big.  */
403
2.49M
  return val & ((1 << bits) - 1);
404
2.49M
}
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
1.58M
{
416
1.58M
  int mode, mask;
417
1.58M
#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \
418
1.58M
  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \
419
1.58M
   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)
420
421
1.58M
  switch (code)
422
1.58M
    {
423
258k
    case '*':
424
258k
      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);
425
258k
      break;
426
68.0k
    case '~':
427
68.0k
      mask = M (0,0,1,1,1,1,1,1,1,0,0,0);
428
68.0k
      break;
429
173k
    case '%':
430
173k
      mask = M (1,1,1,1,1,1,1,1,1,0,0,0);
431
173k
      break;
432
279k
    case ';':
433
279k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,1);
434
279k
      break;
435
6.11k
    case '@':
436
6.11k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,0);
437
6.11k
      break;
438
9.65k
    case '!':
439
9.65k
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
440
9.65k
      break;
441
5.08k
    case '&':
442
5.08k
      mask = M (0,0,1,0,0,1,1,1,1,0,0,0);
443
5.08k
      break;
444
665k
    case '$':
445
665k
      mask = M (1,0,1,1,1,1,1,1,1,0,0,0);
446
665k
      break;
447
1.02k
    case '?':
448
1.02k
      mask = M (1,0,1,0,0,1,1,1,1,0,0,0);
449
1.02k
      break;
450
718
    case '/':
451
718
      mask = M (1,0,1,0,0,1,1,1,1,1,1,0);
452
718
      break;
453
102
    case '|':
454
102
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
455
102
      break;
456
4.89k
    case '>':
457
4.89k
      mask = M (0,0,1,0,1,1,1,1,1,0,0,0);
458
4.89k
      break;
459
3.42k
    case '<':
460
3.42k
      mask = M (0,0,1,1,0,1,1,1,1,1,1,0);
461
3.42k
      break;
462
25.1k
    case 'm':
463
25.1k
      mask = M (1,1,1,1,1,0,0,0,0,0,0,0);
464
25.1k
      break;
465
22.8k
    case 'n':
466
22.8k
      mask = M (0,0,0,0,0,1,0,0,0,1,0,0);
467
22.8k
      break;
468
16.9k
    case 'o':
469
16.9k
      mask = M (0,0,0,0,0,0,1,1,1,0,1,1);
470
16.9k
      break;
471
34.5k
    case 'p':
472
34.5k
      mask = M (1,1,1,1,1,1,0,0,0,0,0,0);
473
34.5k
      break;
474
2.54k
    case 'q':
475
2.54k
      mask = M (1,0,1,1,1,1,0,0,0,0,0,0);
476
2.54k
      break;
477
1.34k
    case 'v':
478
1.34k
      mask = M (1,0,1,1,1,1,0,1,1,0,0,0);
479
1.34k
      break;
480
265
    case 'b':
481
265
      mask = M (1,0,1,1,1,1,0,0,0,1,0,0);
482
265
      break;
483
30
    case 'w':
484
30
      mask = M (0,0,1,1,1,1,0,0,0,1,0,0);
485
30
      break;
486
853
    case 'y':
487
853
      mask = M (0,0,1,0,0,1,0,0,0,0,0,0);
488
853
      break;
489
97
    case 'z':
490
97
      mask = M (0,0,1,0,0,1,0,0,0,1,0,0);
491
97
      break;
492
7.40k
    case '4':
493
7.40k
      mask = M (0,0,1,1,1,1,0,0,0,0,0,0);
494
7.40k
      break;
495
0
    default:
496
0
      abort ();
497
1.58M
    }
498
1.58M
#undef M
499
500
1.58M
  mode = (val >> 3) & 7;
501
1.58M
  if (mode == 7)
502
151k
    mode += val & 7;
503
1.58M
  return (mask & (1 << mode)) != 0;
504
1.58M
}
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
116k
{
512
116k
  if (regno == -1)
513
4.42k
    {
514
4.42k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
515
4.42k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
516
4.42k
      (*info->print_address_func) (disp, info);
517
4.42k
    }
518
112k
  else
519
112k
    {
520
112k
      if (regno == -3)
521
943
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
522
943
              "%%zpc");
523
111k
      else if (regno != -2)
524
94.7k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
525
94.7k
              "%s", reg_names[regno]);
526
112k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
527
112k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
528
112k
            "%" PRIx64, (uint64_t) disp);
529
112k
    }
530
116k
}
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
92.8k
{
538
92.8k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
539
92.8k
        "%s", reg_names[(ext >> 12) & 0xf]);
540
92.8k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
541
92.8k
        ":%c", ext & 0x800 ? 'l' : 'w');
542
92.8k
  if ((ext >> 9) & 3)
543
50.5k
    {
544
50.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
545
50.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
546
50.5k
            "%d", 1 << ((ext >> 9) & 3));
547
50.5k
    }
548
92.8k
}
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
117k
{
561
117k
  int word;
562
117k
  bfd_vma base_disp;
563
117k
  bfd_vma outer_disp;
564
117k
  bool print_index = true;
565
566
117k
  NEXTWORD (p, word, NULL);
567
568
  /* Handle the 68000 style of indexing.  */
569
570
117k
  if ((word & 0x100) == 0)
571
64.7k
    {
572
64.7k
      base_disp = word & 0xff;
573
64.7k
      if ((base_disp & 0x80) != 0)
574
18.2k
  base_disp -= 0x100;
575
64.7k
      if (basereg == -1)
576
2.42k
  base_disp += addr;
577
64.7k
      print_base (basereg, base_disp, info);
578
64.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
579
64.7k
      print_index_register (word, info);
580
64.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
581
64.7k
      return p;
582
64.7k
    }
583
584
  /* Handle the generalized kind.  */
585
  /* First, compute the displacement to add to the base register.  */
586
52.3k
  if (word & 0200)
587
17.8k
    {
588
17.8k
      if (basereg == -1)
589
943
  basereg = -3;
590
16.8k
      else
591
16.8k
  basereg = -2;
592
17.8k
    }
593
52.3k
  if (word & 0100)
594
24.2k
    print_index = false;
595
52.3k
  base_disp = 0;
596
52.3k
  switch ((word >> 4) & 3)
597
52.3k
    {
598
11.8k
    case 2:
599
11.8k
      NEXTWORD (p, base_disp, NULL);
600
11.8k
      break;
601
19.0k
    case 3:
602
19.0k
      NEXTLONG (p, base_disp, NULL);
603
52.3k
    }
604
52.2k
  if (basereg == -1)
605
2.00k
    base_disp += addr;
606
607
  /* Handle single-level case (not indirect).  */
608
52.2k
  if ((word & 7) == 0)
609
13.1k
    {
610
13.1k
      print_base (basereg, base_disp, info);
611
13.1k
      if (print_index)
612
9.19k
  {
613
9.19k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
614
9.19k
    print_index_register (word, info);
615
9.19k
  }
616
13.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
617
13.1k
      return p;
618
13.1k
    }
619
620
  /* Two level.  Compute displacement to add after indirection.  */
621
39.1k
  outer_disp = 0;
622
39.1k
  switch (word & 3)
623
39.1k
    {
624
11.5k
    case 2:
625
11.5k
      NEXTWORD (p, outer_disp, NULL);
626
11.5k
      break;
627
11.9k
    case 3:
628
11.9k
      NEXTLONG (p, outer_disp, NULL);
629
39.1k
    }
630
631
39.0k
  print_base (basereg, base_disp, info);
632
39.0k
  if ((word & 4) == 0 && print_index)
633
9.35k
    {
634
9.35k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
635
9.35k
      print_index_register (word, info);
636
9.35k
      print_index = false;
637
9.35k
    }
638
39.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
639
39.0k
        ")@(");
640
39.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
641
39.0k
        "%" PRIx64, (uint64_t) outer_disp);
642
39.0k
  if (print_index)
643
9.54k
    {
644
9.54k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
645
9.54k
      print_index_register (word, info);
646
9.54k
    }
647
39.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
648
649
39.0k
  return p;
650
39.1k
}
651
652
#define FETCH_ARG(size, val)        \
653
866k
  do              \
654
866k
    {             \
655
866k
      val = fetch_arg (buffer, place, size, info);  \
656
866k
      if (val < 0)         \
657
866k
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
658
866k
    }             \
659
866k
  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
3.10M
{
672
3.10M
  int val = 0;
673
3.10M
  int place = d[1];
674
3.10M
  unsigned char *p = p0;
675
3.10M
  int regno;
676
3.10M
  const char *regname;
677
3.10M
  unsigned char *p1;
678
3.10M
  double flval;
679
3.10M
  int flt_p;
680
3.10M
  bfd_signed_vma disp;
681
3.10M
  unsigned int uval;
682
683
3.10M
  switch (*d)
684
3.10M
    {
685
2.45k
    case 'c':   /* Cache identifier.  */
686
2.45k
      {
687
2.45k
        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
688
2.45k
        FETCH_ARG (2, val);
689
2.45k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
690
2.45k
              "%s", cacheFieldName[val]);
691
2.45k
        break;
692
2.45k
      }
693
694
4.28k
    case 'a':   /* Address register indirect only. Cf. case '+'.  */
695
4.28k
      {
696
4.28k
  FETCH_ARG (3, val);
697
4.28k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
698
4.28k
              reg_names[val + 8]);
699
4.28k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
700
4.28k
        break;
701
4.28k
      }
702
703
538
    case '_':   /* 32-bit absolute address for move16.  */
704
538
      {
705
538
        NEXTULONG (p, uval);
706
534
  (*info->print_address_func) (uval, info);
707
534
        break;
708
538
      }
709
710
1.76k
    case 'C':
711
1.76k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
712
1.76k
      break;
713
714
1.39k
    case 'S':
715
1.39k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
716
1.39k
      break;
717
718
232
    case 'U':
719
232
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
720
232
      break;
721
722
260
    case 'E':
723
260
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
724
260
      break;
725
726
412
    case 'G':
727
412
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
728
412
      break;
729
730
1.11k
    case 'H':
731
1.11k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
732
1.11k
      break;
733
734
1.51k
    case 'J':
735
1.51k
      {
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
1.51k
  struct regname { char * name; int value; };
740
1.51k
  static const struct regname names[] =
741
1.51k
    {
742
1.51k
      {"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
743
1.51k
      {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
744
1.51k
      {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
745
1.51k
      {"%rgpiobar", 0x009}, {"%acr4",0x00c},
746
1.51k
      {"%acr5",0x00d}, {"%acr6",0x00e}, {"%acr7", 0x00f},
747
1.51k
      {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
748
1.51k
      {"%msp", 0x803}, {"%isp", 0x804},
749
1.51k
      {"%pc", 0x80f},
750
      /* Reg c04 is sometimes called flashbar or rambar.
751
         Reg c05 is also sometimes called rambar.  */
752
1.51k
      {"%rambar0", 0xc04}, {"%rambar1", 0xc05},
753
754
      /* reg c0e is sometimes called mbar2 or secmbar.
755
         reg c0f is sometimes called mbar.  */
756
1.51k
      {"%mbar0", 0xc0e}, {"%mbar1", 0xc0f},
757
758
      /* Should we be calling this psr like we do in case 'Y'?  */
759
1.51k
      {"%mmusr",0x805},
760
761
1.51k
      {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808},
762
763
      /* Fido added these.  */
764
1.51k
      {"%cac", 0xffe}, {"%mbo", 0xfff}
765
1.51k
  };
766
  /* Alternate names for v4e (MCF5407/5445x/MCF547x/MCF548x), at least.  */
767
1.51k
  static const struct regname names_v4e[] =
768
1.51k
    {
769
1.51k
      {"%asid",0x003}, {"%acr0",0x004}, {"%acr1",0x005},
770
1.51k
      {"%acr2",0x006}, {"%acr3",0x007}, {"%mmubar",0x008},
771
1.51k
    };
772
1.51k
  unsigned int arch_mask;
773
774
1.51k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
775
1.51k
  FETCH_ARG (12, val);
776
1.51k
  if (arch_mask & (mcfisa_b | mcfisa_c))
777
588
    {
778
4.07k
      for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
779
3.52k
        if (names_v4e[regno].value == val)
780
46
    {
781
46
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
782
46
                 "%s", names_v4e[regno].name);
783
46
      break;
784
46
    }
785
588
      if (regno >= 0)
786
46
        break;
787
588
    }
788
44.6k
  for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
789
43.5k
    if (names[regno].value == val)
790
352
      {
791
352
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
792
352
              "%s", names[regno].name);
793
352
        break;
794
352
      }
795
1.46k
  if (regno < 0)
796
1.11k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
797
1.46k
      }
798
0
      break;
799
800
77.9k
    case 'Q':
801
77.9k
      FETCH_ARG (3, val);
802
      /* 0 means 8, except for the bkpt instruction... */
803
77.9k
      if (val == 0 && d[1] != 's')
804
6.11k
  val = 8;
805
77.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
806
77.9k
            "#%d", val);
807
77.9k
      break;
808
809
3.82k
    case 'x':
810
3.82k
      FETCH_ARG (3, val);
811
      /* 0 means -1.  */
812
3.82k
      if (val == 0)
813
536
  val = -1;
814
3.82k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
815
3.82k
            "#%d", val);
816
3.82k
      break;
817
818
26.7k
    case 'j':
819
26.7k
      FETCH_ARG (3, val);
820
26.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
821
26.7k
            "#%d", val+1);
822
26.7k
      break;
823
824
26.4k
    case 'K':
825
26.4k
      FETCH_ARG (9, val);
826
26.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
827
26.4k
            "#%d", val);
828
26.4k
      break;
829
830
51.3k
    case 'M':
831
51.3k
      if (place == 'h')
832
546
  {
833
546
    static char *const scalefactor_name[] = { "<<", ">>" };
834
835
546
    FETCH_ARG (1, val);
836
546
    (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
837
546
          "%s", scalefactor_name[val]);
838
546
  }
839
50.8k
      else
840
50.8k
  {
841
50.8k
    FETCH_ARG (8, val);
842
50.8k
    if (val & 0x80)
843
10.4k
      val = val - 0x100;
844
50.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
845
50.8k
          "#%d", val);
846
50.8k
  }
847
51.3k
      break;
848
849
51.3k
    case 'T':
850
7.12k
      FETCH_ARG (4, val);
851
7.12k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
852
7.12k
            "#%d", val);
853
7.12k
      break;
854
855
472k
    case 'D':
856
472k
      FETCH_ARG (3, val);
857
472k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
858
472k
            "%s", reg_names[val]);
859
472k
      break;
860
861
56.6k
    case 'A':
862
56.6k
      FETCH_ARG (3, val);
863
56.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
864
56.6k
            "%s", reg_names[val + 010]);
865
56.6k
      break;
866
867
53.6k
    case 'R':
868
53.6k
      FETCH_ARG (4, val);
869
53.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
870
53.6k
            "%s", reg_names[val]);
871
53.6k
      break;
872
873
140
    case 'r':
874
140
      FETCH_ARG (4, regno);
875
140
      if (regno > 7)
876
38
  {
877
38
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
878
38
          "%s", reg_names[regno]);
879
38
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
880
38
  }
881
102
      else
882
102
  {
883
102
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
884
102
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
885
102
          "%s", reg_names[regno]);
886
102
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
887
102
  }
888
140
      break;
889
890
2.85k
    case 'F':
891
2.85k
      FETCH_ARG (3, val);
892
2.85k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
893
2.85k
            "%%fp%d", val);
894
2.85k
      break;
895
896
2.71k
    case 'O':
897
2.71k
      FETCH_ARG (6, val);
898
2.71k
      if (val & 0x20)
899
808
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
900
808
              "%s", reg_names[val & 7]);
901
1.90k
      else
902
1.90k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
903
1.90k
              "%d", val);
904
2.71k
      break;
905
906
5.01k
    case '+':
907
5.01k
      FETCH_ARG (3, val);
908
5.01k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
909
5.01k
            "%s", reg_names[val + 8]);
910
5.01k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
911
5.01k
      break;
912
913
15.9k
    case '-':
914
15.9k
      FETCH_ARG (3, val);
915
15.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
916
15.9k
            "%s", reg_names[val + 8]);
917
15.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
918
15.9k
      break;
919
920
268
    case 'k':
921
268
      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
268
      else if (place == 'C')
930
268
  {
931
268
    FETCH_ARG (7, val);
932
268
    if (val > 63)    /* This is a signed constant.  */
933
226
      val -= 128;
934
268
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
935
268
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
936
268
          "#%d", val);
937
268
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
938
268
  }
939
0
      else
940
0
  return PRINT_INSN_ARG_INVALID_OPERAND;
941
268
      break;
942
943
506k
    case '#':
944
508k
    case '^':
945
508k
      p1 = buffer + (*d == '#' ? 2 : 4);
946
508k
      if (place == 's')
947
0
  FETCH_ARG (4, val);
948
508k
      else if (place == 'C')
949
0
  FETCH_ARG (7, val);
950
508k
      else if (place == '8')
951
0
  FETCH_ARG (3, val);
952
508k
      else if (place == '3')
953
48
  FETCH_ARG (8, val);
954
508k
      else if (place == 'b')
955
435k
  NEXTBYTE (p1, val);
956
73.1k
      else if (place == 'w' || place == 'W')
957
49.9k
  NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
958
23.2k
      else if (place == 'l')
959
23.2k
  NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
960
0
      else
961
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
962
963
508k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
964
508k
            "#%d", val);
965
508k
      break;
966
967
120k
    case 'B':
968
120k
      if (place == 'b')
969
0
  NEXTBYTE (p, disp);
970
120k
      else if (place == 'B')
971
107k
  disp = COERCE_SIGNED_CHAR (buffer[1]);
972
12.2k
      else if (place == 'w' || place == 'W')
973
9.42k
  NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
974
2.87k
      else if (place == 'l' || place == 'L' || place == 'C')
975
2.30k
  NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
976
566
      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
566
      else if (place == 'c')
985
566
  {
986
566
    if (buffer[1] & 0x40)    /* If bit six is one, long offset.  */
987
437
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
988
129
    else
989
129
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
990
566
  }
991
0
      else
992
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
993
994
120k
      (*info->print_address_func) (addr + disp, info);
995
120k
      break;
996
997
8.95k
    case 'd':
998
8.95k
      {
999
8.95k
  int val1;
1000
1001
8.95k
  NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1002
8.95k
  FETCH_ARG (3, val1);
1003
8.95k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
1004
8.95k
              "%s", reg_names[val1 + 8]);
1005
8.95k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1006
8.95k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1007
8.95k
              "%d", val);
1008
8.95k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1009
8.95k
  break;
1010
8.95k
      }
1011
1012
1.34k
    case 's':
1013
1.34k
      FETCH_ARG (3, val);
1014
1.34k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1015
1.34k
            "%s", fpcr_names[val]);
1016
1.34k
      break;
1017
1018
1.75k
    case 'e':
1019
1.75k
      FETCH_ARG (2, val);
1020
1.75k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1021
1.75k
            "%%acc%d", val);
1022
1.75k
      break;
1023
1024
74
    case 'g':
1025
74
      FETCH_ARG (1, val);
1026
74
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1027
74
            "%%accext%s", val == 0 ? "01" : "23");
1028
74
      break;
1029
1030
10.4k
    case 'i':
1031
10.4k
      FETCH_ARG (2, val);
1032
10.4k
      if (val == 1)
1033
2.48k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1034
2.48k
              "<<");
1035
7.93k
      else if (val == 3)
1036
2.97k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1037
2.97k
              ">>");
1038
4.96k
      else
1039
4.96k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1040
5.45k
      break;
1041
1042
9.95k
    case 'I':
1043
      /* Get coprocessor ID... */
1044
9.95k
      val = fetch_arg (buffer, 'd', 3, info);
1045
9.95k
      if (val < 0)
1046
0
  return PRINT_INSN_ARG_MEMORY_ERROR;
1047
9.95k
      if (val != 1)        /* Unusual coprocessor ID?  */
1048
0
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
1049
0
              "(cpid=%d) ", val);
1050
9.95k
      break;
1051
1052
7.40k
    case '4':
1053
266k
    case '*':
1054
334k
    case '~':
1055
507k
    case '%':
1056
787k
    case ';':
1057
793k
    case '@':
1058
803k
    case '!':
1059
1.46M
    case '$':
1060
1.47M
    case '?':
1061
1.47M
    case '/':
1062
1.47M
    case '&':
1063
1.47M
    case '|':
1064
1.47M
    case '<':
1065
1.48M
    case '>':
1066
1.50M
    case 'm':
1067
1.53M
    case 'n':
1068
1.54M
    case 'o':
1069
1.58M
    case 'p':
1070
1.58M
    case 'q':
1071
1.58M
    case 'v':
1072
1.58M
    case 'b':
1073
1.58M
    case 'w':
1074
1.58M
    case 'y':
1075
1.58M
    case 'z':
1076
1.58M
      if (place == 'd')
1077
230k
  {
1078
230k
    val = fetch_arg (buffer, 'x', 6, info);
1079
230k
    if (val < 0)
1080
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1081
230k
    val = ((val & 7) << 3) + ((val >> 3) & 7);
1082
230k
  }
1083
1.35M
      else
1084
1.35M
  {
1085
1.35M
    val = fetch_arg (buffer, 's', 6, info);
1086
1.35M
    if (val < 0)
1087
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1088
1.35M
  }
1089
1090
      /* If the <ea> is invalid for *d, then reject this match.  */
1091
1.58M
      if (!m68k_valid_ea (*d, val))
1092
209k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1093
1094
      /* Get register number assuming address register.  */
1095
1.37M
      regno = (val & 7) + 8;
1096
1.37M
      regname = reg_names[regno];
1097
1.37M
      switch (val >> 3)
1098
1.37M
  {
1099
662k
  case 0:
1100
662k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1101
662k
          "%s", reg_names[val]);
1102
662k
    break;
1103
1104
31.0k
  case 1:
1105
31.0k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1106
31.0k
          "%s", regname);
1107
31.0k
    break;
1108
1109
142k
  case 2:
1110
142k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1111
142k
          "%s", regname);
1112
142k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
1113
142k
    break;
1114
1115
94.4k
  case 3:
1116
94.4k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1117
94.4k
          "%s", regname);
1118
94.4k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
1119
94.4k
    break;
1120
1121
187k
  case 4:
1122
187k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1123
187k
          "%s", regname);
1124
187k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
1125
187k
    break;
1126
1127
104k
  case 5:
1128
104k
    NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1129
104k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1130
104k
          "%s", regname);
1131
104k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1132
104k
    (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1133
104k
          "%d", val);
1134
104k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1135
104k
    break;
1136
1137
111k
  case 6:
1138
111k
    p = print_indexed (regno, p, addr, info);
1139
111k
    if (p == NULL)
1140
142
      return PRINT_INSN_ARG_MEMORY_ERROR;
1141
111k
    break;
1142
1143
111k
  case 7:
1144
45.7k
    switch (val & 7)
1145
45.7k
      {
1146
14.1k
      case 0:
1147
14.1k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1148
14.1k
        (*info->print_address_func) (val, info);
1149
14.1k
        break;
1150
1151
10.8k
      case 1:
1152
10.8k
        NEXTULONG (p, uval);
1153
10.8k
        (*info->print_address_func) (uval, info);
1154
10.8k
        break;
1155
1156
5.88k
      case 2:
1157
5.88k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1158
5.86k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
1159
5.86k
              "%%pc");
1160
5.86k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1161
5.86k
        (*info->print_address_func) (addr + val, info);
1162
5.86k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1163
5.86k
        break;
1164
1165
5.37k
      case 3:
1166
5.37k
        p = print_indexed (-1, p, addr, info);
1167
5.37k
        if (p == NULL)
1168
9
    return PRINT_INSN_ARG_MEMORY_ERROR;
1169
5.36k
        break;
1170
1171
9.43k
      case 4:
1172
9.43k
        flt_p = 1;  /* Assume it's a float... */
1173
9.43k
        switch (place)
1174
9.43k
        {
1175
1.18k
    case 'b':
1176
1.18k
      NEXTBYTE (p, val);
1177
1.18k
      flt_p = 0;
1178
1.18k
      break;
1179
1180
3.77k
    case 'w':
1181
3.77k
      NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1182
3.76k
      flt_p = 0;
1183
3.76k
      break;
1184
1185
2.70k
    case 'l':
1186
2.70k
      NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1187
2.69k
      flt_p = 0;
1188
2.69k
      break;
1189
1190
199
    case 'f':
1191
199
      NEXTSINGLE (flval, p);
1192
198
      break;
1193
1194
692
    case 'F':
1195
692
      NEXTDOUBLE (flval, p);
1196
692
      break;
1197
1198
692
    case 'x':
1199
506
      NEXTEXTEND (flval, p);
1200
506
      break;
1201
1202
506
    case 'p':
1203
371
      NEXTPACKED (p, flval);
1204
370
      break;
1205
1206
370
    default:
1207
0
      return PRINT_INSN_ARG_INVALID_OPERAND;
1208
9.43k
        }
1209
9.41k
        if (flt_p)  /* Print a float? */
1210
1.76k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1211
1.76k
                "#0e%g", flval);
1212
7.65k
        else
1213
7.65k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1214
7.65k
                "#%d", val);
1215
9.41k
        break;
1216
1217
0
      default:
1218
0
        return PRINT_INSN_ARG_INVALID_OPERAND;
1219
45.7k
      }
1220
1.37M
  }
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
1.37M
      if (place == '/')
1226
6.17k
  {
1227
6.17k
    FETCH_ARG (1, val);
1228
6.17k
    if (val)
1229
4.56k
      info->fprintf_styled_func (info->stream, dis_style_text, "&");
1230
6.17k
  }
1231
1.37M
      break;
1232
1233
1.37M
    case 'L':
1234
7.44k
    case 'l':
1235
7.44k
  if (place == 'w')
1236
6.20k
    {
1237
6.20k
      char doneany;
1238
6.20k
      p1 = buffer + 2;
1239
6.20k
      NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
1240
      /* Move the pointer ahead if this point is farther ahead
1241
         than the last.  */
1242
6.20k
      p = p1 > p ? p1 : p;
1243
6.20k
      if (val == 0)
1244
348
        {
1245
348
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1246
348
                "#0");
1247
348
    break;
1248
348
        }
1249
5.85k
      if (*d == 'l')
1250
630
        {
1251
630
    int newval = 0;
1252
1253
10.7k
    for (regno = 0; regno < 16; ++regno)
1254
10.0k
      if (val & (0x8000 >> regno))
1255
5.85k
        newval |= 1 << regno;
1256
630
    val = newval;
1257
630
        }
1258
5.85k
      val &= 0xffff;
1259
5.85k
      doneany = 0;
1260
76.3k
      for (regno = 0; regno < 16; ++regno)
1261
70.4k
        if (val & (1 << regno))
1262
20.5k
    {
1263
20.5k
      int first_regno;
1264
1265
20.5k
      if (doneany)
1266
14.7k
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1267
14.7k
              "/");
1268
20.5k
      doneany = 1;
1269
20.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1270
20.5k
            "%s", reg_names[regno]);
1271
20.5k
      first_regno = regno;
1272
43.7k
      while (val & (1 << (regno + 1)))
1273
23.1k
        ++regno;
1274
20.5k
      if (regno > first_regno)
1275
9.98k
        {
1276
9.98k
          (*info->fprintf_styled_func) (info->stream,
1277
9.98k
                dis_style_text, "-");
1278
9.98k
          (*info->fprintf_styled_func) (info->stream,
1279
9.98k
                dis_style_register, "%s",
1280
9.98k
                reg_names[regno]);
1281
9.98k
        }
1282
20.5k
    }
1283
5.85k
    }
1284
1.24k
  else if (place == '3')
1285
588
    {
1286
      /* `fmovem' insn.  */
1287
588
      char doneany;
1288
1289
588
      FETCH_ARG (8, val);
1290
588
      if (val == 0)
1291
102
        {
1292
102
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1293
102
                "#0");
1294
102
    break;
1295
102
        }
1296
486
      if (*d == 'l')
1297
84
        {
1298
84
    int newval = 0;
1299
1300
756
    for (regno = 0; regno < 8; ++regno)
1301
672
      if (val & (0x80 >> regno))
1302
309
        newval |= 1 << regno;
1303
84
    val = newval;
1304
84
        }
1305
486
      val &= 0xff;
1306
486
      doneany = 0;
1307
3.36k
      for (regno = 0; regno < 8; ++regno)
1308
2.87k
        if (val & (1 << regno))
1309
1.09k
    {
1310
1.09k
      int first_regno;
1311
1.09k
      if (doneany)
1312
607
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1313
607
              "/");
1314
1.09k
      doneany = 1;
1315
1.09k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1316
1.09k
            "%%fp%d", regno);
1317
1.09k
      first_regno = regno;
1318
2.10k
      while (val & (1 << (regno + 1)))
1319
1.01k
        ++regno;
1320
1.09k
      if (regno > first_regno)
1321
235
        {
1322
235
          (*info->fprintf_styled_func) (info->stream,
1323
235
                dis_style_text, "-");
1324
235
          (*info->fprintf_styled_func) (info->stream,
1325
235
                dis_style_register,
1326
235
                "%%fp%d", regno);
1327
235
        }
1328
1.09k
    }
1329
486
    }
1330
656
  else if (place == '8')
1331
656
    {
1332
656
      FETCH_ARG (3, val);
1333
      /* fmoveml for FP status registers.  */
1334
656
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1335
656
            "%s", fpcr_names[val]);
1336
656
    }
1337
0
  else
1338
0
    return PRINT_INSN_ARG_INVALID_OP_TABLE;
1339
6.99k
      break;
1340
1341
6.99k
    case 'X':
1342
196
      place = '8';
1343
      /* Fall through.  */
1344
393
    case 'Y':
1345
411
    case 'Z':
1346
1.63k
    case 'W':
1347
1.70k
    case '0':
1348
2.43k
    case '1':
1349
3.77k
    case '2':
1350
3.80k
    case '3':
1351
3.80k
      {
1352
3.80k
  char *name = 0;
1353
1354
3.80k
  FETCH_ARG (5, val);
1355
3.80k
  switch (val)
1356
3.80k
    {
1357
16
    case 2: name = "%tt0"; break;
1358
7
    case 3: name = "%tt1"; break;
1359
69
    case 0x10: name = "%tc"; break;
1360
26
    case 0x11: name = "%drp"; break;
1361
78
    case 0x12: name = "%srp"; break;
1362
2
    case 0x13: name = "%crp"; break;
1363
8
    case 0x14: name = "%cal"; break;
1364
994
    case 0x15: name = "%val"; break;
1365
8
    case 0x16: name = "%scc"; break;
1366
2.18k
    case 0x17: name = "%ac"; break;
1367
297
    case 0x18: name = "%psr"; break;
1368
18
    case 0x19: name = "%pcsr"; break;
1369
75
    case 0x1c:
1370
93
    case 0x1d:
1371
93
      {
1372
93
        int break_reg = ((buffer[3] >> 2) & 7);
1373
1374
93
        (*info->fprintf_styled_func)
1375
93
    (info->stream, dis_style_register,
1376
93
     val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
1377
93
      }
1378
93
      break;
1379
3
    default:
1380
3
      (*info->fprintf_styled_func) (info->stream, dis_style_text,
1381
3
            "<mmu register %d>", val);
1382
3.80k
    }
1383
3.80k
  if (name)
1384
3.70k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1385
3.70k
          "%s", name);
1386
3.80k
      }
1387
0
      break;
1388
1389
40
    case 'f':
1390
40
      {
1391
40
  int fc;
1392
1393
40
  FETCH_ARG (5, fc);
1394
40
  if (fc == 1)
1395
3
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1396
3
          "%%dfc");
1397
37
  else if (fc == 0)
1398
37
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1399
37
          "%%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
40
      }
1405
0
      break;
1406
1407
19
    case 'V':
1408
19
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
1409
19
      break;
1410
1411
678
    case 't':
1412
678
      {
1413
678
  int level;
1414
1415
678
  FETCH_ARG (3, level);
1416
678
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1417
678
              "%d", level);
1418
678
      }
1419
0
      break;
1420
1421
21.0k
    case 'u':
1422
21.0k
      {
1423
21.0k
  short is_upper = 0;
1424
21.0k
  int reg;
1425
1426
21.0k
  FETCH_ARG (5, reg);
1427
21.0k
  if (reg & 0x10)
1428
7.13k
    {
1429
7.13k
      is_upper = 1;
1430
7.13k
      reg &= 0xf;
1431
7.13k
    }
1432
21.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
1433
21.0k
              reg_half_names[reg],
1434
21.0k
              is_upper ? "u" : "l");
1435
21.0k
      }
1436
0
      break;
1437
1438
0
    default:
1439
0
      return PRINT_INSN_ARG_INVALID_OP_TABLE;
1440
3.10M
    }
1441
1442
2.88M
  return p - p0;
1443
3.10M
}
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
929k
{
1454
929k
  unsigned char *save_p;
1455
929k
  unsigned char *p;
1456
929k
  const char *d;
1457
929k
  const char *args = best->args;
1458
1459
929k
  struct private *priv = (struct private *) info->private_data;
1460
929k
  bfd_byte *buffer = priv->the_buffer;
1461
929k
  fprintf_styled_ftype save_printer = info->fprintf_styled_func;
1462
929k
  void (* save_print_address) (bfd_vma, struct disassemble_info *)
1463
929k
    = info->print_address_func;
1464
1465
929k
  if (*args == '.')
1466
18.2k
    args++;
1467
1468
  /* Point at first word of argument data,
1469
     and at descriptor for first argument.  */
1470
929k
  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
2.76M
  for (d = args; *d; d += 2)
1477
1.83M
    {
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
1.83M
      if (d[0] == '#')
1481
276k
  {
1482
276k
    if (d[1] == 'l' && p - buffer < 6)
1483
12.5k
      p = buffer + 6;
1484
263k
    else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8')
1485
263k
      p = buffer + 4;
1486
276k
  }
1487
1488
1.83M
      if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
1489
6.42k
  p = buffer + 4;
1490
1491
1.83M
      switch (d[1])
1492
1.83M
  {
1493
22.9k
  case '1':
1494
24.0k
  case '2':
1495
44.9k
  case '3':
1496
46.3k
  case '7':
1497
51.9k
  case '8':
1498
52.0k
  case '9':
1499
56.9k
  case 'i':
1500
56.9k
    if (p - buffer < 4)
1501
32.3k
      p = buffer + 4;
1502
56.9k
    break;
1503
35
  case '4':
1504
70
  case '5':
1505
105
  case '6':
1506
105
    if (p - buffer < 6)
1507
35
      p = buffer + 6;
1508
105
    break;
1509
1.77M
  default:
1510
1.77M
    break;
1511
1.83M
  }
1512
1.83M
    }
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
929k
  if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
1517
11.1k
    p = buffer + 4;
1518
1519
  /* lpstop is another exception.  It takes a one word argument but is
1520
     three words long.  */
1521
929k
  if (p - buffer < 6
1522
929k
      && (best->match & 0xffff) == 0xffff
1523
929k
      && args[0] == '#'
1524
929k
      && args[1] == 'w')
1525
9
    {
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
9
      p = buffer + 6;
1531
9
      if (!FETCH_DATA (info, p))
1532
0
  return -1;
1533
9
      buffer[2] = buffer[4];
1534
9
      buffer[3] = buffer[5];
1535
9
    }
1536
1537
929k
  if (!FETCH_DATA (info, p))
1538
125
    return -1;
1539
1540
929k
  save_p = p;
1541
929k
  info->print_address_func = dummy_print_address;
1542
929k
  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
2.43M
  for (d = args; *d; d += 2)
1547
1.71M
    {
1548
1.71M
      int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1549
1550
1.71M
      if (eaten >= 0)
1551
1.50M
  p += eaten;
1552
214k
      else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
1553
214k
         || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
1554
214k
  {
1555
214k
    info->fprintf_styled_func = save_printer;
1556
214k
    info->print_address_func = save_print_address;
1557
214k
    return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
1558
214k
  }
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
1.71M
    }
1572
1573
714k
  p = save_p;
1574
714k
  info->fprintf_styled_func = save_printer;
1575
714k
  info->print_address_func = save_print_address;
1576
1577
714k
  d = args;
1578
1579
714k
  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
1580
1581
714k
  if (*d)
1582
714k
    info->fprintf_styled_func (info->stream, dis_style_text, " ");
1583
1584
2.09M
  while (*d)
1585
1.38M
    {
1586
1.38M
      p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1587
1.38M
      d += 2;
1588
1589
1.38M
      if (*d && *(d - 2) != 'I' && *d != 'k')
1590
664k
  info->fprintf_styled_func (info->stream, dis_style_text, ",");
1591
1.38M
    }
1592
1593
714k
  return p - buffer;
1594
929k
}
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
1.13M
{
1606
1.13M
  int i;
1607
1.13M
  const char *d;
1608
1.13M
  static const struct m68k_opcode **opcodes[16];
1609
1.13M
  static int numopcodes[16];
1610
1.13M
  int val;
1611
1.13M
  int major_opcode;
1612
1613
1.13M
  struct private *priv = (struct private *) info->private_data;
1614
1.13M
  bfd_byte *buffer = priv->the_buffer;
1615
1616
1.13M
  if (!opcodes[0])
1617
2
    {
1618
      /* Speed up the matching by sorting the opcode
1619
   table on the upper four bits of the opcode.  */
1620
2
      const struct m68k_opcode **opc_pointer[16];
1621
1622
      /* First count how many opcodes are in each of the sixteen buckets.  */
1623
3.81k
      for (i = 0; i < m68k_numopcodes; i++)
1624
3.81k
  numopcodes[(m68k_opcodes[i].opcode >> 28) & 15]++;
1625
1626
      /* Then create a sorted table of pointers
1627
   that point into the unsorted table.  */
1628
2
      opc_pointer[0] = xmalloc (sizeof (struct m68k_opcode *)
1629
2
        * m68k_numopcodes);
1630
2
      opcodes[0] = opc_pointer[0];
1631
1632
32
      for (i = 1; i < 16; i++)
1633
30
  {
1634
30
    opc_pointer[i] = opc_pointer[i - 1] + numopcodes[i - 1];
1635
30
    opcodes[i] = opc_pointer[i];
1636
30
  }
1637
1638
3.81k
      for (i = 0; i < m68k_numopcodes; i++)
1639
3.81k
  *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i];
1640
2
    }
1641
1642
1.13M
  if (!FETCH_DATA (info, buffer + 2))
1643
361
    return -1;
1644
1.13M
  major_opcode = (buffer[0] >> 4) & 15;
1645
1646
237M
  for (i = 0; i < numopcodes[major_opcode]; i++)
1647
236M
    {
1648
236M
      const struct m68k_opcode *opc = opcodes[major_opcode][i];
1649
236M
      unsigned long opcode = opc->opcode;
1650
236M
      unsigned long match = opc->match;
1651
236M
      const char *args = opc->args;
1652
1653
236M
      if (*args == '.')
1654
2.57M
  args++;
1655
1656
236M
      if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
1657
236M
    && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
1658
    /* Only fetch the next two bytes if we need to.  */
1659
236M
    && (((0xffff & match) == 0)
1660
11.7M
        ||
1661
11.7M
        (FETCH_DATA (info, buffer + 4)
1662
10.6M
         && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
1663
10.6M
         && ((0xff & buffer[3] & match) == (0xff & opcode)))
1664
11.7M
        )
1665
236M
    && (opc->arch & arch_mask) != 0)
1666
951k
  {
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
2.83M
    for (d = args; *d; d += 2)
1671
1.88M
      if (d[1] == 'D')
1672
395
        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
951k
    if (*d == '\0')
1678
2.83M
      for (d = args; *d; d += 2)
1679
1.87M
        if (d[1] == 't')
1680
350
    break;
1681
1682
    /* Don't match fmovel with more than one register;
1683
       wait for fmoveml.  */
1684
951k
    if (*d == '\0')
1685
950k
      {
1686
2.82M
        for (d = args; *d; d += 2)
1687
1.87M
    {
1688
1.87M
      if (d[0] == 's' && d[1] == '8')
1689
1.29k
        {
1690
1.29k
          val = fetch_arg (buffer, d[1], 3, info);
1691
1.29k
          if (val < 0)
1692
0
      return 0;
1693
1.29k
          if ((val & (val - 1)) != 0)
1694
102
      break;
1695
1.29k
        }
1696
1.87M
    }
1697
950k
      }
1698
1699
    /* Don't match FPU insns with non-default coprocessor ID.  */
1700
951k
    if (*d == '\0')
1701
950k
      {
1702
2.78M
        for (d = args; *d; d += 2)
1703
1.85M
    {
1704
1.85M
      if (d[0] == 'I')
1705
27.3k
        {
1706
27.3k
          val = fetch_arg (buffer, 'd', 3, info);
1707
27.3k
          if (val != 1)
1708
20.6k
      break;
1709
27.3k
        }
1710
1.85M
    }
1711
950k
      }
1712
1713
951k
    if (*d == '\0')
1714
929k
      if ((val = match_insn_m68k (memaddr, info, opc)))
1715
715k
        return val;
1716
951k
  }
1717
236M
    }
1718
414k
  return 0;
1719
1.13M
}
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
934k
{
1727
934k
  unsigned int arch_mask;
1728
934k
  struct private priv;
1729
934k
  int val;
1730
1731
934k
  bfd_byte *buffer = priv.the_buffer;
1732
1733
934k
  info->private_data = & priv;
1734
  /* Tell objdump to use two bytes per chunk
1735
     and six bytes per line for displaying raw data.  */
1736
934k
  info->bytes_per_chunk = 2;
1737
934k
  info->bytes_per_line = 6;
1738
934k
  info->display_endian = BFD_ENDIAN_BIG;
1739
934k
  priv.max_fetched = priv.the_buffer;
1740
934k
  priv.insn_start = memaddr;
1741
1742
934k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
1743
934k
  if (!arch_mask)
1744
816k
    {
1745
      /* First try printing an m680x0 instruction.  Try printing a Coldfire
1746
   one if that fails.  */
1747
816k
      val = m68k_scan_mask (memaddr, info, m68k_mask);
1748
816k
      if (val <= 0)
1749
196k
  val = m68k_scan_mask (memaddr, info, mcf_mask);
1750
816k
    }
1751
117k
  else
1752
117k
    {
1753
117k
      val = m68k_scan_mask (memaddr, info, arch_mask);
1754
117k
    }
1755
1756
934k
  if (val == 0)
1757
219k
    {
1758
      /* Handle undefined instructions.  */
1759
219k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
1760
219k
         ".short");
1761
219k
      info->fprintf_styled_func (info->stream, dis_style_text, " ");
1762
219k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
1763
219k
         "0x%04x", (buffer[0] << 8) + buffer[1]);
1764
219k
    }
1765
1766
934k
  return val ? val : 2;
1767
934k
}