Coverage Report

Created: 2026-03-10 08:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/m68k-dis.c
Line
Count
Source
1
/* Print Motorola 68k instructions.
2
   Copyright (C) 1986-2026 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
432k
#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
333k
  do            \
77
333k
    {           \
78
333k
      p += 2;         \
79
333k
      if (!FETCH_DATA (info, p))   \
80
333k
  return PRINT_INSN_ARG_MEMORY_ERROR; \
81
333k
      val = COERCE_SIGNED_CHAR (p[-1]);   \
82
333k
    }           \
83
333k
  while (0)
84
85
/* Get a 2 byte signed integer.  */
86
302k
#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
87
88
#define NEXTWORD(p, val, ret_val)   \
89
302k
  do            \
90
302k
    {           \
91
302k
      p += 2;         \
92
302k
      if (!FETCH_DATA (info, p))   \
93
302k
  return ret_val;       \
94
302k
      val = COERCE16 ((p[-2] << 8) + p[-1]);  \
95
302k
    }            \
96
302k
  while (0)
97
98
/* Get a 4 byte signed integer.  */
99
60.4k
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000)
100
101
#define NEXTLONG(p, val, ret_val)         \
102
60.5k
  do                  \
103
60.5k
    {                 \
104
60.5k
      p += 4;               \
105
60.5k
      if (!FETCH_DATA (info, p))         \
106
60.5k
  return ret_val;             \
107
60.5k
      val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8)  \
108
60.4k
      + p[-2]) << 8) + p[-1]);      \
109
60.4k
    }                  \
110
60.5k
  while (0)
111
112
/* Get a 4 byte unsigned integer.  */
113
#define NEXTULONG(p, val)           \
114
13.4k
  do                  \
115
13.4k
    {                 \
116
13.4k
      p += 4;               \
117
13.4k
      if (!FETCH_DATA (info, p))         \
118
13.4k
  return PRINT_INSN_ARG_MEMORY_ERROR;       \
119
13.4k
      val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8)     \
120
13.3k
         + p[-2]) << 8) + p[-1]);         \
121
13.3k
    }                  \
122
13.4k
  while (0)
123
124
/* Get a single precision float.  */
125
#define NEXTSINGLE(val, p)          \
126
296
  do                \
127
296
    {               \
128
296
      p += 4;             \
129
296
      if (!FETCH_DATA (info, p))       \
130
296
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
131
296
      floatformat_to_double (& floatformat_ieee_single_big, \
132
296
           (char *) p - 4, & val);    \
133
296
    }                \
134
296
  while (0)
135
136
/* Get a double precision float.  */
137
#define NEXTDOUBLE(val, p)          \
138
1.14k
  do                \
139
1.14k
    {               \
140
1.14k
      p += 8;             \
141
1.14k
      if (!FETCH_DATA (info, p))       \
142
1.14k
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
143
1.14k
      floatformat_to_double (& floatformat_ieee_double_big, \
144
1.14k
           (char *) p - 8, & val);    \
145
1.14k
    }                \
146
1.14k
  while (0)
147
148
/* Get an extended precision float.  */
149
#define NEXTEXTEND(val, p)        \
150
967
  do              \
151
967
    {             \
152
967
      p += 12;            \
153
967
      if (!FETCH_DATA (info, p))     \
154
967
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
155
967
      floatformat_to_double (& floatformat_m68881_ext,  \
156
966
           (char *) p - 12, & val); \
157
966
    }              \
158
967
  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
722
  do            \
166
722
    {           \
167
722
      p += 12;          \
168
722
      if (!FETCH_DATA (info, p))   \
169
722
  return PRINT_INSN_ARG_MEMORY_ERROR; \
170
722
      val = 0.0;        \
171
720
    }            \
172
722
  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
31.1M
  ((addr) <= ((struct private *) (info->private_data))->max_fetched \
191
31.1M
   ? 1 : fetch_data ((info), (addr)))
192
193
static int
194
fetch_data (struct disassemble_info *info, bfd_byte *addr)
195
1.31M
{
196
1.31M
  int status;
197
1.31M
  struct private *priv = (struct private *)info->private_data;
198
1.31M
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
199
200
1.31M
  status = (*info->read_memory_func) (start,
201
1.31M
              priv->max_fetched,
202
1.31M
              addr - priv->max_fetched,
203
1.31M
              info);
204
1.31M
  if (status != 0)
205
18.7k
    {
206
18.7k
      (*info->memory_error_func) (status, start, info);
207
18.7k
      return 0;
208
18.7k
    }
209
1.29M
  else
210
1.29M
    priv->max_fetched = addr;
211
1.29M
  return 1;
212
1.31M
}
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.05M
{
221
2.05M
  return 0;
222
2.05M
}
223
224
static void
225
dummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,
226
         struct disassemble_info *info ATTRIBUTE_UNUSED)
227
75.6k
{
228
75.6k
}
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.34M
{
242
2.34M
  int val = 0;
243
244
2.34M
  switch (code)
245
2.34M
    {
246
5.90k
    case '/': /* MAC/EMAC mask bit.  */
247
5.90k
      val = buffer[3] >> 5;
248
5.90k
      break;
249
250
740
    case 'G': /* EMAC ACC load.  */
251
740
      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);
252
740
      break;
253
254
622
    case 'H': /* EMAC ACC !load.  */
255
622
      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);
256
622
      break;
257
258
426
    case ']': /* EMAC ACCEXT bit.  */
259
426
      val = buffer[0] >> 2;
260
426
      break;
261
262
11.4k
    case 'I': /* MAC/EMAC scale factor.  */
263
11.4k
      val = buffer[2] >> 1;
264
11.4k
      break;
265
266
626
    case 'F': /* EMAC ACCx.  */
267
626
      val = buffer[0] >> 1;
268
626
      break;
269
270
266
    case 'f':
271
266
      val = buffer[1];
272
266
      break;
273
274
1.35M
    case 's':
275
1.35M
      val = buffer[1];
276
1.35M
      break;
277
278
578k
    case 'd':     /* Destination, for register or quick.  */
279
578k
      val = (buffer[0] << 8) + buffer[1];
280
578k
      val >>= 9;
281
578k
      break;
282
283
197k
    case 'x':     /* Destination, for general arg.  */
284
197k
      val = (buffer[0] << 8) + buffer[1];
285
197k
      val >>= 6;
286
197k
      break;
287
288
52
    case 'k':
289
52
      if (! FETCH_DATA (info, buffer + 3))
290
0
  return -1;
291
52
      val = (buffer[3] >> 4);
292
52
      break;
293
294
294
    case 'C':
295
294
      if (! FETCH_DATA (info, buffer + 3))
296
0
  return -1;
297
294
      val = buffer[3];
298
294
      break;
299
300
49.2k
    case '1':
301
49.2k
      if (! FETCH_DATA (info, buffer + 3))
302
0
  return -1;
303
49.2k
      val = (buffer[2] << 8) + buffer[3];
304
49.2k
      val >>= 12;
305
49.2k
      break;
306
307
2.28k
    case '2':
308
2.28k
      if (! FETCH_DATA (info, buffer + 3))
309
0
  return -1;
310
2.28k
      val = (buffer[2] << 8) + buffer[3];
311
2.28k
      val >>= 6;
312
2.28k
      break;
313
314
41.2k
    case '3':
315
43.4k
    case 'j':
316
43.4k
      if (! FETCH_DATA (info, buffer + 3))
317
0
  return -1;
318
43.4k
      val = (buffer[2] << 8) + buffer[3];
319
43.4k
      break;
320
321
898
    case '4':
322
898
      if (! FETCH_DATA (info, buffer + 5))
323
0
  return -1;
324
898
      val = (buffer[4] << 8) + buffer[5];
325
898
      val >>= 12;
326
898
      break;
327
328
898
    case '5':
329
898
      if (! FETCH_DATA (info, buffer + 5))
330
0
  return -1;
331
898
      val = (buffer[4] << 8) + buffer[5];
332
898
      val >>= 6;
333
898
      break;
334
335
898
    case '6':
336
898
      if (! FETCH_DATA (info, buffer + 5))
337
0
  return -1;
338
898
      val = (buffer[4] << 8) + buffer[5];
339
898
      break;
340
341
5.01k
    case '7':
342
5.01k
      if (! FETCH_DATA (info, buffer + 3))
343
0
  return -1;
344
5.01k
      val = (buffer[2] << 8) + buffer[3];
345
5.01k
      val >>= 7;
346
5.01k
      break;
347
348
7.53k
    case '8':
349
7.53k
      if (! FETCH_DATA (info, buffer + 3))
350
0
  return -1;
351
7.53k
      val = (buffer[2] << 8) + buffer[3];
352
7.53k
      val >>= 10;
353
7.53k
      break;
354
355
122
    case '9':
356
122
      if (! FETCH_DATA (info, buffer + 3))
357
0
  return -1;
358
122
      val = (buffer[2] << 8) + buffer[3];
359
122
      val >>= 5;
360
122
      break;
361
362
4.64k
    case 'e':
363
4.64k
      val = (buffer[1] >> 6);
364
4.64k
      break;
365
366
37.7k
    case 'E':
367
37.7k
      if (! FETCH_DATA (info, buffer + 3))
368
0
  return -1;
369
37.7k
      val = (buffer[2] >> 1);
370
37.7k
      break;
371
372
6.45k
    case 'm':
373
6.45k
      val = (buffer[1] & 0x40 ? 0x8 : 0)
374
6.45k
  | ((buffer[0] >> 1) & 0x7)
375
6.45k
  | (buffer[3] & 0x80 ? 0x10 : 0);
376
6.45k
      break;
377
378
5.90k
    case 'n':
379
5.90k
      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
380
5.90k
      break;
381
382
9.60k
    case 'o':
383
9.60k
      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
384
9.60k
      break;
385
386
6.45k
    case 'M':
387
6.45k
      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
388
6.45k
      break;
389
390
9.60k
    case 'N':
391
9.60k
      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
392
9.60k
      break;
393
394
728
    case 'h':
395
728
      val = buffer[2] >> 2;
396
728
      break;
397
398
0
    default:
399
0
      abort ();
400
2.34M
    }
401
402
  /* bits is never too big.  */
403
2.34M
  return val & ((1 << bits) - 1);
404
2.34M
}
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.41M
{
416
1.41M
  int mode, mask;
417
1.41M
#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \
418
1.41M
  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \
419
1.41M
   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)
420
421
1.41M
  switch (code)
422
1.41M
    {
423
252k
    case '*':
424
252k
      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);
425
252k
      break;
426
62.0k
    case '~':
427
62.0k
      mask = M (0,0,1,1,1,1,1,1,1,0,0,0);
428
62.0k
      break;
429
201k
    case '%':
430
201k
      mask = M (1,1,1,1,1,1,1,1,1,0,0,0);
431
201k
      break;
432
222k
    case ';':
433
222k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,1);
434
222k
      break;
435
5.79k
    case '@':
436
5.79k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,0);
437
5.79k
      break;
438
10.8k
    case '!':
439
10.8k
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
440
10.8k
      break;
441
3.67k
    case '&':
442
3.67k
      mask = M (0,0,1,0,0,1,1,1,1,0,0,0);
443
3.67k
      break;
444
525k
    case '$':
445
525k
      mask = M (1,0,1,1,1,1,1,1,1,0,0,0);
446
525k
      break;
447
897
    case '?':
448
897
      mask = M (1,0,1,0,0,1,1,1,1,0,0,0);
449
897
      break;
450
713
    case '/':
451
713
      mask = M (1,0,1,0,0,1,1,1,1,1,1,0);
452
713
      break;
453
214
    case '|':
454
214
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
455
214
      break;
456
3.10k
    case '>':
457
3.10k
      mask = M (0,0,1,0,1,1,1,1,1,0,0,0);
458
3.10k
      break;
459
2.99k
    case '<':
460
2.99k
      mask = M (0,0,1,1,0,1,1,1,1,1,1,0);
461
2.99k
      break;
462
23.5k
    case 'm':
463
23.5k
      mask = M (1,1,1,1,1,0,0,0,0,0,0,0);
464
23.5k
      break;
465
22.0k
    case 'n':
466
22.0k
      mask = M (0,0,0,0,0,1,0,0,0,1,0,0);
467
22.0k
      break;
468
15.7k
    case 'o':
469
15.7k
      mask = M (0,0,0,0,0,0,1,1,1,0,1,1);
470
15.7k
      break;
471
46.2k
    case 'p':
472
46.2k
      mask = M (1,1,1,1,1,1,0,0,0,0,0,0);
473
46.2k
      break;
474
3.23k
    case 'q':
475
3.23k
      mask = M (1,0,1,1,1,1,0,0,0,0,0,0);
476
3.23k
      break;
477
2.12k
    case 'v':
478
2.12k
      mask = M (1,0,1,1,1,1,0,1,1,0,0,0);
479
2.12k
      break;
480
64
    case 'b':
481
64
      mask = M (1,0,1,1,1,1,0,0,0,1,0,0);
482
64
      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
1.03k
    case 'y':
487
1.03k
      mask = M (0,0,1,0,0,1,0,0,0,0,0,0);
488
1.03k
      break;
489
80
    case 'z':
490
80
      mask = M (0,0,1,0,0,1,0,0,0,1,0,0);
491
80
      break;
492
7.33k
    case '4':
493
7.33k
      mask = M (0,0,1,1,1,1,0,0,0,0,0,0);
494
7.33k
      break;
495
0
    default:
496
0
      abort ();
497
1.41M
    }
498
1.41M
#undef M
499
500
1.41M
  mode = (val >> 3) & 7;
501
1.41M
  if (mode == 7)
502
160k
    mode += val & 7;
503
1.41M
  return (mask & (1 << mode)) != 0;
504
1.41M
}
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
99.1k
{
512
99.1k
  if (regno == -1)
513
6.77k
    {
514
6.77k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
515
6.77k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
516
6.77k
      (*info->print_address_func) (disp, info);
517
6.77k
    }
518
92.4k
  else
519
92.4k
    {
520
92.4k
      if (regno == -3)
521
1.17k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
522
1.17k
              "%%zpc");
523
91.2k
      else if (regno != -2)
524
77.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
525
77.4k
              "%s", reg_names[regno]);
526
92.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
527
92.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
528
92.4k
            "%" PRIx64, (uint64_t) disp);
529
92.4k
    }
530
99.1k
}
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
79.0k
{
538
79.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
539
79.0k
        "%s", reg_names[(ext >> 12) & 0xf]);
540
79.0k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
541
79.0k
        ":%c", ext & 0x800 ? 'l' : 'w');
542
79.0k
  if ((ext >> 9) & 3)
543
48.5k
    {
544
48.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
545
48.5k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
546
48.5k
            "%d", 1 << ((ext >> 9) & 3));
547
48.5k
    }
548
79.0k
}
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
99.3k
{
561
99.3k
  int word;
562
99.3k
  bfd_vma base_disp;
563
99.3k
  bfd_vma outer_disp;
564
99.3k
  bool print_index = true;
565
566
99.3k
  NEXTWORD (p, word, NULL);
567
568
  /* Handle the 68000 style of indexing.  */
569
570
99.2k
  if ((word & 0x100) == 0)
571
55.3k
    {
572
55.3k
      base_disp = word & 0xff;
573
55.3k
      if ((base_disp & 0x80) != 0)
574
18.2k
  base_disp -= 0x100;
575
55.3k
      if (basereg == -1)
576
2.42k
  base_disp += addr;
577
55.3k
      print_base (basereg, base_disp, info);
578
55.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
579
55.3k
      print_index_register (word, info);
580
55.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
581
55.3k
      return p;
582
55.3k
    }
583
584
  /* Handle the generalized kind.  */
585
  /* First, compute the displacement to add to the base register.  */
586
43.9k
  if (word & 0200)
587
15.0k
    {
588
15.0k
      if (basereg == -1)
589
1.17k
  basereg = -3;
590
13.8k
      else
591
13.8k
  basereg = -2;
592
15.0k
    }
593
43.9k
  if (word & 0100)
594
20.2k
    print_index = false;
595
43.9k
  base_disp = 0;
596
43.9k
  switch ((word >> 4) & 3)
597
43.9k
    {
598
9.77k
    case 2:
599
9.77k
      NEXTWORD (p, base_disp, NULL);
600
9.77k
      break;
601
18.7k
    case 3:
602
18.7k
      NEXTLONG (p, base_disp, NULL);
603
43.9k
    }
604
43.9k
  if (basereg == -1)
605
4.35k
    base_disp += addr;
606
607
  /* Handle single-level case (not indirect).  */
608
43.9k
  if ((word & 7) == 0)
609
7.36k
    {
610
7.36k
      print_base (basereg, base_disp, info);
611
7.36k
      if (print_index)
612
5.59k
  {
613
5.59k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
614
5.59k
    print_index_register (word, info);
615
5.59k
  }
616
7.36k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
617
7.36k
      return p;
618
7.36k
    }
619
620
  /* Two level.  Compute displacement to add after indirection.  */
621
36.5k
  outer_disp = 0;
622
36.5k
  switch (word & 3)
623
36.5k
    {
624
9.20k
    case 2:
625
9.20k
      NEXTWORD (p, outer_disp, NULL);
626
9.19k
      break;
627
12.3k
    case 3:
628
12.3k
      NEXTLONG (p, outer_disp, NULL);
629
36.5k
    }
630
631
36.4k
  print_base (basereg, base_disp, info);
632
36.4k
  if ((word & 4) == 0 && print_index)
633
9.71k
    {
634
9.71k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
635
9.71k
      print_index_register (word, info);
636
9.71k
      print_index = false;
637
9.71k
    }
638
36.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
639
36.4k
        ")@(");
640
36.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
641
36.4k
        "%" PRIx64, (uint64_t) outer_disp);
642
36.4k
  if (print_index)
643
8.40k
    {
644
8.40k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
645
8.40k
      print_index_register (word, info);
646
8.40k
    }
647
36.4k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
648
649
36.4k
  return p;
650
36.5k
}
651
652
#define FETCH_ARG(size, val)        \
653
888k
  do              \
654
888k
    {             \
655
888k
      val = fetch_arg (buffer, place, size, info);  \
656
888k
      if (val < 0)         \
657
888k
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
658
888k
    }             \
659
888k
  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
2.83M
{
672
2.83M
  int val = 0;
673
2.83M
  int place = d[1];
674
2.83M
  unsigned char *p = p0;
675
2.83M
  int regno;
676
2.83M
  const char *regname;
677
2.83M
  unsigned char *p1;
678
2.83M
  double flval;
679
2.83M
  int flt_p;
680
2.83M
  bfd_signed_vma disp;
681
2.83M
  unsigned int uval;
682
683
2.83M
  switch (*d)
684
2.83M
    {
685
4.64k
    case 'c':   /* Cache identifier.  */
686
4.64k
      {
687
4.64k
        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
688
4.64k
        FETCH_ARG (2, val);
689
4.64k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
690
4.64k
              "%s", cacheFieldName[val]);
691
4.64k
        break;
692
4.64k
      }
693
694
6.96k
    case 'a':   /* Address register indirect only. Cf. case '+'.  */
695
6.96k
      {
696
6.96k
  FETCH_ARG (3, val);
697
6.96k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
698
6.96k
              reg_names[val + 8]);
699
6.96k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
700
6.96k
        break;
701
6.96k
      }
702
703
1.29k
    case '_':   /* 32-bit absolute address for move16.  */
704
1.29k
      {
705
1.29k
        NEXTULONG (p, uval);
706
1.29k
  (*info->print_address_func) (uval, info);
707
1.29k
        break;
708
1.29k
      }
709
710
2.55k
    case 'C':
711
2.55k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
712
2.55k
      break;
713
714
1.74k
    case 'S':
715
1.74k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
716
1.74k
      break;
717
718
140
    case 'U':
719
140
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
720
140
      break;
721
722
642
    case 'E':
723
642
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
724
642
      break;
725
726
444
    case 'G':
727
444
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
728
444
      break;
729
730
2.02k
    case 'H':
731
2.02k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
732
2.02k
      break;
733
734
2.16k
    case 'J':
735
2.16k
      {
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
2.16k
  struct regname { char * name; int value; };
740
2.16k
  static const struct regname names[] =
741
2.16k
    {
742
2.16k
      {"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
743
2.16k
      {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
744
2.16k
      {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
745
2.16k
      {"%rgpiobar", 0x009}, {"%acr4",0x00c},
746
2.16k
      {"%acr5",0x00d}, {"%acr6",0x00e}, {"%acr7", 0x00f},
747
2.16k
      {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
748
2.16k
      {"%msp", 0x803}, {"%isp", 0x804},
749
2.16k
      {"%pc", 0x80f},
750
      /* Reg c04 is sometimes called flashbar or rambar.
751
         Reg c05 is also sometimes called rambar.  */
752
2.16k
      {"%rambar0", 0xc04}, {"%rambar1", 0xc05},
753
754
      /* reg c0e is sometimes called mbar2 or secmbar.
755
         reg c0f is sometimes called mbar.  */
756
2.16k
      {"%mbar0", 0xc0e}, {"%mbar1", 0xc0f},
757
758
      /* Should we be calling this psr like we do in case 'Y'?  */
759
2.16k
      {"%mmusr",0x805},
760
761
2.16k
      {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808},
762
763
      /* Fido added these.  */
764
2.16k
      {"%cac", 0xffe}, {"%mbo", 0xfff}
765
2.16k
  };
766
  /* Alternate names for v4e (MCF5407/5445x/MCF547x/MCF548x), at least.  */
767
2.16k
  static const struct regname names_v4e[] =
768
2.16k
    {
769
2.16k
      {"%asid",0x003}, {"%acr0",0x004}, {"%acr1",0x005},
770
2.16k
      {"%acr2",0x006}, {"%acr3",0x007}, {"%mmubar",0x008},
771
2.16k
    };
772
2.16k
  unsigned int arch_mask;
773
774
2.16k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
775
2.16k
  FETCH_ARG (12, val);
776
2.16k
  if (arch_mask & (mcfisa_b | mcfisa_c))
777
510
    {
778
3.53k
      for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
779
3.06k
        if (names_v4e[regno].value == val)
780
34
    {
781
34
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
782
34
                 "%s", names_v4e[regno].name);
783
34
      break;
784
34
    }
785
510
      if (regno >= 0)
786
34
        break;
787
510
    }
788
63.9k
  for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
789
62.1k
    if (names[regno].value == val)
790
356
      {
791
356
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
792
356
              "%s", names[regno].name);
793
356
        break;
794
356
      }
795
2.12k
  if (regno < 0)
796
1.77k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
797
2.12k
      }
798
0
      break;
799
800
99.1k
    case 'Q':
801
99.1k
      FETCH_ARG (3, val);
802
      /* 0 means 8, except for the bkpt instruction... */
803
99.1k
      if (val == 0 && d[1] != 's')
804
5.76k
  val = 8;
805
99.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
806
99.1k
            "#%d", val);
807
99.1k
      break;
808
809
4.50k
    case 'x':
810
4.50k
      FETCH_ARG (3, val);
811
      /* 0 means -1.  */
812
4.50k
      if (val == 0)
813
585
  val = -1;
814
4.50k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
815
4.50k
            "#%d", val);
816
4.50k
      break;
817
818
37.7k
    case 'j':
819
37.7k
      FETCH_ARG (3, val);
820
37.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
821
37.7k
            "#%d", val+1);
822
37.7k
      break;
823
824
37.2k
    case 'K':
825
37.2k
      FETCH_ARG (9, val);
826
37.2k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
827
37.2k
            "#%d", val);
828
37.2k
      break;
829
830
40.2k
    case 'M':
831
40.2k
      if (place == 'h')
832
728
  {
833
728
    static char *const scalefactor_name[] = { "<<", ">>" };
834
835
728
    FETCH_ARG (1, val);
836
728
    (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
837
728
          "%s", scalefactor_name[val]);
838
728
  }
839
39.4k
      else
840
39.4k
  {
841
39.4k
    FETCH_ARG (8, val);
842
39.4k
    if (val & 0x80)
843
9.91k
      val = val - 0x100;
844
39.4k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
845
39.4k
          "#%d", val);
846
39.4k
  }
847
40.2k
      break;
848
849
40.2k
    case 'T':
850
1.50k
      FETCH_ARG (4, val);
851
1.50k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
852
1.50k
            "#%d", val);
853
1.50k
      break;
854
855
434k
    case 'D':
856
434k
      FETCH_ARG (3, val);
857
434k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
858
434k
            "%s", reg_names[val]);
859
434k
      break;
860
861
60.6k
    case 'A':
862
60.6k
      FETCH_ARG (3, val);
863
60.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
864
60.6k
            "%s", reg_names[val + 010]);
865
60.6k
      break;
866
867
69.0k
    case 'R':
868
69.0k
      FETCH_ARG (4, val);
869
69.0k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
870
69.0k
            "%s", reg_names[val]);
871
69.0k
      break;
872
873
1.79k
    case 'r':
874
1.79k
      FETCH_ARG (4, regno);
875
1.79k
      if (regno > 7)
876
88
  {
877
88
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
878
88
          "%s", reg_names[regno]);
879
88
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
880
88
  }
881
1.70k
      else
882
1.70k
  {
883
1.70k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
884
1.70k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
885
1.70k
          "%s", reg_names[regno]);
886
1.70k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
887
1.70k
  }
888
1.79k
      break;
889
890
6.03k
    case 'F':
891
6.03k
      FETCH_ARG (3, val);
892
6.03k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
893
6.03k
            "%%fp%d", val);
894
6.03k
      break;
895
896
2.57k
    case 'O':
897
2.57k
      FETCH_ARG (6, val);
898
2.57k
      if (val & 0x20)
899
1.36k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
900
1.36k
              "%s", reg_names[val & 7]);
901
1.21k
      else
902
1.21k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
903
1.21k
              "%d", val);
904
2.57k
      break;
905
906
6.63k
    case '+':
907
6.63k
      FETCH_ARG (3, val);
908
6.63k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
909
6.63k
            "%s", reg_names[val + 8]);
910
6.63k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
911
6.63k
      break;
912
913
14.4k
    case '-':
914
14.4k
      FETCH_ARG (3, val);
915
14.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
916
14.4k
            "%s", reg_names[val + 8]);
917
14.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
918
14.4k
      break;
919
920
132
    case 'k':
921
132
      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
132
      else if (place == 'C')
930
132
  {
931
132
    FETCH_ARG (7, val);
932
132
    if (val > 63)    /* This is a signed constant.  */
933
68
      val -= 128;
934
132
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
935
132
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
936
132
          "#%d", val);
937
132
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
938
132
  }
939
0
      else
940
0
  return PRINT_INSN_ARG_INVALID_OPERAND;
941
132
      break;
942
943
400k
    case '#':
944
401k
    case '^':
945
401k
      p1 = buffer + (*d == '#' ? 2 : 4);
946
401k
      if (place == 's')
947
0
  FETCH_ARG (4, val);
948
401k
      else if (place == 'C')
949
162
  FETCH_ARG (7, val);
950
401k
      else if (place == '8')
951
0
  FETCH_ARG (3, val);
952
401k
      else if (place == '3')
953
368
  FETCH_ARG (8, val);
954
400k
      else if (place == 'b')
955
331k
  NEXTBYTE (p1, val);
956
69.0k
      else if (place == 'w' || place == 'W')
957
47.5k
  NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
958
21.5k
      else if (place == 'l')
959
21.5k
  NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
960
0
      else
961
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
962
963
401k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
964
401k
            "#%d", val);
965
401k
      break;
966
967
112k
    case 'B':
968
112k
      if (place == 'b')
969
0
  NEXTBYTE (p, disp);
970
112k
      else if (place == 'B')
971
99.2k
  disp = COERCE_SIGNED_CHAR (buffer[1]);
972
12.9k
      else if (place == 'w' || place == 'W')
973
7.67k
  NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
974
5.26k
      else if (place == 'l' || place == 'L' || place == 'C')
975
4.44k
  NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
976
819
      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
819
      else if (place == 'c')
985
819
  {
986
819
    if (buffer[1] & 0x40)    /* If bit six is one, long offset.  */
987
463
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
988
356
    else
989
356
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
990
819
  }
991
0
      else
992
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
993
994
112k
      info->target = addr + disp;
995
996
112k
      (*info->print_address_func) (addr + disp, info);
997
112k
      break;
998
999
7.86k
    case 'd':
1000
7.86k
      {
1001
7.86k
  int val1;
1002
1003
7.86k
  NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1004
7.86k
  FETCH_ARG (3, val1);
1005
7.86k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
1006
7.86k
              "%s", reg_names[val1 + 8]);
1007
7.86k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1008
7.86k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1009
7.86k
              "%d", val);
1010
7.86k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1011
7.86k
  break;
1012
7.86k
      }
1013
1014
881
    case 's':
1015
881
      FETCH_ARG (3, val);
1016
881
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1017
881
            "%s", fpcr_names[val]);
1018
881
      break;
1019
1020
2.25k
    case 'e':
1021
2.25k
      FETCH_ARG (2, val);
1022
2.25k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1023
2.25k
            "%%acc%d", val);
1024
2.25k
      break;
1025
1026
426
    case 'g':
1027
426
      FETCH_ARG (1, val);
1028
426
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1029
426
            "%%accext%s", val == 0 ? "01" : "23");
1030
426
      break;
1031
1032
11.4k
    case 'i':
1033
11.4k
      FETCH_ARG (2, val);
1034
11.4k
      if (val == 1)
1035
3.15k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1036
3.15k
              "<<");
1037
8.28k
      else if (val == 3)
1038
3.55k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1039
3.55k
              ">>");
1040
4.73k
      else
1041
4.73k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1042
6.70k
      break;
1043
1044
11.1k
    case 'I':
1045
      /* Get coprocessor ID... */
1046
11.1k
      val = fetch_arg (buffer, 'd', 3, info);
1047
11.1k
      if (val < 0)
1048
0
  return PRINT_INSN_ARG_MEMORY_ERROR;
1049
11.1k
      if (val != 1)        /* Unusual coprocessor ID?  */
1050
0
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
1051
0
              "(cpid=%d) ", val);
1052
11.1k
      break;
1053
1054
7.33k
    case '4':
1055
259k
    case '*':
1056
321k
    case '~':
1057
523k
    case '%':
1058
746k
    case ';':
1059
752k
    case '@':
1060
763k
    case '!':
1061
1.28M
    case '$':
1062
1.28M
    case '?':
1063
1.28M
    case '/':
1064
1.29M
    case '&':
1065
1.29M
    case '|':
1066
1.29M
    case '<':
1067
1.29M
    case '>':
1068
1.32M
    case 'm':
1069
1.34M
    case 'n':
1070
1.36M
    case 'o':
1071
1.40M
    case 'p':
1072
1.41M
    case 'q':
1073
1.41M
    case 'v':
1074
1.41M
    case 'b':
1075
1.41M
    case 'w':
1076
1.41M
    case 'y':
1077
1.41M
    case 'z':
1078
1.41M
      if (place == 'd')
1079
197k
  {
1080
197k
    val = fetch_arg (buffer, 'x', 6, info);
1081
197k
    if (val < 0)
1082
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1083
197k
    val = ((val & 7) << 3) + ((val >> 3) & 7);
1084
197k
  }
1085
1.21M
      else
1086
1.21M
  {
1087
1.21M
    val = fetch_arg (buffer, 's', 6, info);
1088
1.21M
    if (val < 0)
1089
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1090
1.21M
  }
1091
1092
      /* If the <ea> is invalid for *d, then reject this match.  */
1093
1.41M
      if (!m68k_valid_ea (*d, val))
1094
208k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1095
1096
      /* Get register number assuming address register.  */
1097
1.20M
      regno = (val & 7) + 8;
1098
1.20M
      regname = reg_names[regno];
1099
1.20M
      switch (val >> 3)
1100
1.20M
  {
1101
562k
  case 0:
1102
562k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1103
562k
          "%s", reg_names[val]);
1104
562k
    break;
1105
1106
35.2k
  case 1:
1107
35.2k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1108
35.2k
          "%s", regname);
1109
35.2k
    break;
1110
1111
105k
  case 2:
1112
105k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1113
105k
          "%s", regname);
1114
105k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
1115
105k
    break;
1116
1117
122k
  case 3:
1118
122k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1119
122k
          "%s", regname);
1120
122k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
1121
122k
    break;
1122
1123
144k
  case 4:
1124
144k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1125
144k
          "%s", regname);
1126
144k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
1127
144k
    break;
1128
1129
93.9k
  case 5:
1130
93.9k
    NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1131
93.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1132
93.8k
          "%s", regname);
1133
93.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1134
93.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1135
93.8k
          "%d", val);
1136
93.8k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1137
93.8k
    break;
1138
1139
91.3k
  case 6:
1140
91.3k
    p = print_indexed (regno, p, addr, info);
1141
91.3k
    if (p == NULL)
1142
121
      return PRINT_INSN_ARG_MEMORY_ERROR;
1143
91.2k
    break;
1144
1145
91.2k
  case 7:
1146
49.5k
    switch (val & 7)
1147
49.5k
      {
1148
11.8k
      case 0:
1149
11.8k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1150
11.8k
        (*info->print_address_func) (val, info);
1151
11.8k
        break;
1152
1153
12.1k
      case 1:
1154
12.1k
        NEXTULONG (p, uval);
1155
12.0k
        (*info->print_address_func) (uval, info);
1156
12.0k
        break;
1157
1158
6.00k
      case 2:
1159
6.00k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1160
5.98k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
1161
5.98k
              "%%pc");
1162
5.98k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1163
5.98k
        (*info->print_address_func) (addr + val, info);
1164
5.98k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1165
5.98k
        break;
1166
1167
7.96k
      case 3:
1168
7.96k
        p = print_indexed (-1, p, addr, info);
1169
7.96k
        if (p == NULL)
1170
15
    return PRINT_INSN_ARG_MEMORY_ERROR;
1171
7.94k
        break;
1172
1173
11.6k
      case 4:
1174
11.6k
        flt_p = 1;  /* Assume it's a float... */
1175
11.6k
        switch (place)
1176
11.6k
        {
1177
1.98k
    case 'b':
1178
1.98k
      NEXTBYTE (p, val);
1179
1.98k
      flt_p = 0;
1180
1.98k
      break;
1181
1182
3.49k
    case 'w':
1183
3.49k
      NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1184
3.49k
      flt_p = 0;
1185
3.49k
      break;
1186
1187
3.05k
    case 'l':
1188
3.05k
      NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1189
3.04k
      flt_p = 0;
1190
3.04k
      break;
1191
1192
296
    case 'f':
1193
296
      NEXTSINGLE (flval, p);
1194
296
      break;
1195
1196
1.14k
    case 'F':
1197
1.14k
      NEXTDOUBLE (flval, p);
1198
1.14k
      break;
1199
1200
1.14k
    case 'x':
1201
967
      NEXTEXTEND (flval, p);
1202
966
      break;
1203
1204
966
    case 'p':
1205
722
      NEXTPACKED (p, flval);
1206
720
      break;
1207
1208
720
    default:
1209
0
      return PRINT_INSN_ARG_INVALID_OPERAND;
1210
11.6k
        }
1211
11.6k
        if (flt_p)  /* Print a float? */
1212
3.12k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1213
3.12k
                "#0e%g", flval);
1214
8.52k
        else
1215
8.52k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1216
8.52k
                "#%d", val);
1217
11.6k
        break;
1218
1219
0
      default:
1220
0
        return PRINT_INSN_ARG_INVALID_OPERAND;
1221
49.5k
      }
1222
1.20M
  }
1223
1224
      /* If place is '/', then this is the case of the mask bit for
1225
   mac/emac loads. Now that the arg has been printed, grab the
1226
   mask bit and if set, add a '&' to the arg.  */
1227
1.20M
      if (place == '/')
1228
5.90k
  {
1229
5.90k
    FETCH_ARG (1, val);
1230
5.90k
    if (val)
1231
4.59k
      info->fprintf_styled_func (info->stream, dis_style_text, "&");
1232
5.90k
  }
1233
1.20M
      break;
1234
1235
1.20M
    case 'L':
1236
6.20k
    case 'l':
1237
6.20k
  if (place == 'w')
1238
5.21k
    {
1239
5.21k
      char doneany;
1240
5.21k
      p1 = buffer + 2;
1241
5.21k
      NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
1242
      /* Move the pointer ahead if this point is farther ahead
1243
         than the last.  */
1244
5.21k
      p = p1 > p ? p1 : p;
1245
5.21k
      if (val == 0)
1246
213
        {
1247
213
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1248
213
                "#0");
1249
213
    break;
1250
213
        }
1251
5.00k
      if (*d == 'l')
1252
1.58k
        {
1253
1.58k
    int newval = 0;
1254
1255
26.8k
    for (regno = 0; regno < 16; ++regno)
1256
25.2k
      if (val & (0x8000 >> regno))
1257
10.1k
        newval |= 1 << regno;
1258
1.58k
    val = newval;
1259
1.58k
        }
1260
5.00k
      val &= 0xffff;
1261
5.00k
      doneany = 0;
1262
65.1k
      for (regno = 0; regno < 16; ++regno)
1263
60.1k
        if (val & (1 << regno))
1264
17.6k
    {
1265
17.6k
      int first_regno;
1266
1267
17.6k
      if (doneany)
1268
12.6k
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1269
12.6k
              "/");
1270
17.6k
      doneany = 1;
1271
17.6k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1272
17.6k
            "%s", reg_names[regno]);
1273
17.6k
      first_regno = regno;
1274
37.5k
      while (val & (1 << (regno + 1)))
1275
19.8k
        ++regno;
1276
17.6k
      if (regno > first_regno)
1277
8.92k
        {
1278
8.92k
          (*info->fprintf_styled_func) (info->stream,
1279
8.92k
                dis_style_text, "-");
1280
8.92k
          (*info->fprintf_styled_func) (info->stream,
1281
8.92k
                dis_style_register, "%s",
1282
8.92k
                reg_names[regno]);
1283
8.92k
        }
1284
17.6k
    }
1285
5.00k
    }
1286
988
  else if (place == '3')
1287
440
    {
1288
      /* `fmovem' insn.  */
1289
440
      char doneany;
1290
1291
440
      FETCH_ARG (8, val);
1292
440
      if (val == 0)
1293
30
        {
1294
30
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1295
30
                "#0");
1296
30
    break;
1297
30
        }
1298
410
      if (*d == 'l')
1299
376
        {
1300
376
    int newval = 0;
1301
1302
3.38k
    for (regno = 0; regno < 8; ++regno)
1303
3.00k
      if (val & (0x80 >> regno))
1304
870
        newval |= 1 << regno;
1305
376
    val = newval;
1306
376
        }
1307
410
      val &= 0xff;
1308
410
      doneany = 0;
1309
3.31k
      for (regno = 0; regno < 8; ++regno)
1310
2.90k
        if (val & (1 << regno))
1311
598
    {
1312
598
      int first_regno;
1313
598
      if (doneany)
1314
188
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1315
188
              "/");
1316
598
      doneany = 1;
1317
598
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1318
598
            "%%fp%d", regno);
1319
598
      first_regno = regno;
1320
972
      while (val & (1 << (regno + 1)))
1321
374
        ++regno;
1322
598
      if (regno > first_regno)
1323
158
        {
1324
158
          (*info->fprintf_styled_func) (info->stream,
1325
158
                dis_style_text, "-");
1326
158
          (*info->fprintf_styled_func) (info->stream,
1327
158
                dis_style_register,
1328
158
                "%%fp%d", regno);
1329
158
        }
1330
598
    }
1331
410
    }
1332
548
  else if (place == '8')
1333
548
    {
1334
548
      FETCH_ARG (3, val);
1335
      /* fmoveml for FP status registers.  */
1336
548
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1337
548
            "%s", fpcr_names[val]);
1338
548
    }
1339
0
  else
1340
0
    return PRINT_INSN_ARG_INVALID_OP_TABLE;
1341
5.96k
      break;
1342
1343
5.96k
    case 'X':
1344
405
      place = '8';
1345
      /* Fall through.  */
1346
675
    case 'Y':
1347
684
    case 'Z':
1348
1.88k
    case 'W':
1349
1.96k
    case '0':
1350
2.67k
    case '1':
1351
3.92k
    case '2':
1352
4.10k
    case '3':
1353
4.10k
      {
1354
4.10k
  char *name = 0;
1355
1356
4.10k
  FETCH_ARG (5, val);
1357
4.10k
  switch (val)
1358
4.10k
    {
1359
75
    case 2: name = "%tt0"; break;
1360
107
    case 3: name = "%tt1"; break;
1361
244
    case 0x10: name = "%tc"; break;
1362
2
    case 0x11: name = "%drp"; break;
1363
14
    case 0x12: name = "%srp"; break;
1364
27
    case 0x13: name = "%crp"; break;
1365
2
    case 0x14: name = "%cal"; break;
1366
818
    case 0x15: name = "%val"; break;
1367
10
    case 0x16: name = "%scc"; break;
1368
2.12k
    case 0x17: name = "%ac"; break;
1369
338
    case 0x18: name = "%psr"; break;
1370
32
    case 0x19: name = "%pcsr"; break;
1371
69
    case 0x1c:
1372
223
    case 0x1d:
1373
223
      {
1374
223
        int break_reg = ((buffer[3] >> 2) & 7);
1375
1376
223
        (*info->fprintf_styled_func)
1377
223
    (info->stream, dis_style_register,
1378
223
     val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
1379
223
      }
1380
223
      break;
1381
91
    default:
1382
91
      (*info->fprintf_styled_func) (info->stream, dis_style_text,
1383
91
            "<mmu register %d>", val);
1384
4.10k
    }
1385
4.10k
  if (name)
1386
3.79k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1387
3.79k
          "%s", name);
1388
4.10k
      }
1389
0
      break;
1390
1391
140
    case 'f':
1392
140
      {
1393
140
  int fc;
1394
1395
140
  FETCH_ARG (5, fc);
1396
140
  if (fc == 1)
1397
6
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1398
6
          "%%dfc");
1399
134
  else if (fc == 0)
1400
134
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1401
134
          "%%sfc");
1402
0
  else
1403
    /* xgettext:c-format */
1404
0
    (*info->fprintf_styled_func) (info->stream, dis_style_text,
1405
0
          _("<function code %d>"), fc);
1406
140
      }
1407
0
      break;
1408
1409
49
    case 'V':
1410
49
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
1411
49
      break;
1412
1413
2.28k
    case 't':
1414
2.28k
      {
1415
2.28k
  int level;
1416
1417
2.28k
  FETCH_ARG (3, level);
1418
2.28k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1419
2.28k
              "%d", level);
1420
2.28k
      }
1421
0
      break;
1422
1423
21.1k
    case 'u':
1424
21.1k
      {
1425
21.1k
  short is_upper = 0;
1426
21.1k
  int reg;
1427
1428
21.1k
  FETCH_ARG (5, reg);
1429
21.1k
  if (reg & 0x10)
1430
7.10k
    {
1431
7.10k
      is_upper = 1;
1432
7.10k
      reg &= 0xf;
1433
7.10k
    }
1434
21.1k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
1435
21.1k
              reg_half_names[reg],
1436
21.1k
              is_upper ? "u" : "l");
1437
21.1k
      }
1438
0
      break;
1439
1440
0
    default:
1441
0
      return PRINT_INSN_ARG_INVALID_OP_TABLE;
1442
2.83M
    }
1443
1444
2.62M
  return p - p0;
1445
2.83M
}
1446
1447
/* Return the insn type determined from the opcode information.  */
1448
1449
static enum dis_insn_type
1450
m68k_opcode_to_insn_type (const struct m68k_opcode *opc)
1451
636k
{
1452
  /* All branches have an operand in 'B' format (the 'B' place only comes
1453
     with the 'B' format).  */
1454
636k
  if (strchr (opc->args, 'B') == NULL)
1455
580k
    return dis_nonbranch;
1456
1457
  /* Most branches are conditional branches, detect the ones that aren't
1458
     from the opcode name.  */
1459
56.1k
  if (strncmp (opc->name, "bra", 3) == 0)
1460
3.71k
    return dis_branch;
1461
1462
52.3k
  if (strncmp (opc->name, "bsr", 3) == 0)
1463
5.91k
    return dis_jsr;
1464
1465
46.4k
  return dis_condbranch;
1466
52.3k
}
1467
1468
/* Try to match the current instruction to best and if so, return the
1469
   number of bytes consumed from the instruction stream, else zero.
1470
   Return -1 on memory error.  */
1471
1472
static int
1473
match_insn_m68k (bfd_vma memaddr,
1474
     disassemble_info * info,
1475
     const struct m68k_opcode * best)
1476
849k
{
1477
849k
  unsigned char *save_p;
1478
849k
  unsigned char *p;
1479
849k
  const char *d;
1480
849k
  const char *args = best->args;
1481
1482
849k
  struct private *priv = (struct private *) info->private_data;
1483
849k
  bfd_byte *buffer = priv->the_buffer;
1484
849k
  fprintf_styled_ftype save_printer = info->fprintf_styled_func;
1485
849k
  void (* save_print_address) (bfd_vma, struct disassemble_info *)
1486
849k
    = info->print_address_func;
1487
1488
849k
  if (*args == '.')
1489
25.9k
    args++;
1490
1491
  /* Point at first word of argument data,
1492
     and at descriptor for first argument.  */
1493
849k
  p = buffer + 2;
1494
1495
  /* Figure out how long the fixed-size portion of the instruction is.
1496
     The only place this is stored in the opcode table is
1497
     in the arguments--look for arguments which specify fields in the 2nd
1498
     or 3rd words of the instruction.  */
1499
2.55M
  for (d = args; *d; d += 2)
1500
1.70M
    {
1501
      /* I don't think it is necessary to be checking d[0] here;
1502
   I suspect all this could be moved to the case statement below.  */
1503
1.70M
      if (d[0] == '#')
1504
221k
  {
1505
221k
    if (d[1] == 'l' && p - buffer < 6)
1506
11.7k
      p = buffer + 6;
1507
209k
    else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8')
1508
209k
      p = buffer + 4;
1509
221k
  }
1510
1511
1.70M
      if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
1512
4.63k
  p = buffer + 4;
1513
1514
1.70M
      switch (d[1])
1515
1.70M
  {
1516
31.7k
  case '1':
1517
33.2k
  case '2':
1518
62.7k
  case '3':
1519
65.4k
  case '7':
1520
71.3k
  case '8':
1521
71.4k
  case '9':
1522
76.6k
  case 'i':
1523
76.6k
    if (p - buffer < 4)
1524
42.0k
      p = buffer + 4;
1525
76.6k
    break;
1526
449
  case '4':
1527
898
  case '5':
1528
1.34k
  case '6':
1529
1.34k
    if (p - buffer < 6)
1530
449
      p = buffer + 6;
1531
1.34k
    break;
1532
1.62M
  default:
1533
1.62M
    break;
1534
1.70M
  }
1535
1.70M
    }
1536
1537
  /* pflusha is an exceptions.  It takes no arguments but is two words
1538
     long.  Recognize it by looking at the lower 16 bits of the mask.  */
1539
849k
  if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
1540
11.4k
    p = buffer + 4;
1541
1542
  /* lpstop is another exception.  It takes a one word argument but is
1543
     three words long.  */
1544
849k
  if (p - buffer < 6
1545
837k
      && (best->match & 0xffff) == 0xffff
1546
2.21k
      && args[0] == '#'
1547
86
      && args[1] == 'w')
1548
86
    {
1549
      /* Copy the one word argument into the usual location for a one
1550
   word argument, to simplify printing it.  We can get away with
1551
   this because we know exactly what the second word is, and we
1552
   aren't going to print anything based on it.  */
1553
86
      p = buffer + 6;
1554
86
      if (!FETCH_DATA (info, p))
1555
0
  return -1;
1556
86
      buffer[2] = buffer[4];
1557
86
      buffer[3] = buffer[5];
1558
86
    }
1559
1560
849k
  if (!FETCH_DATA (info, p))
1561
231
    return -1;
1562
1563
849k
  save_p = p;
1564
849k
  info->print_address_func = dummy_print_address;
1565
849k
  info->fprintf_styled_func = dummy_printer;
1566
1567
  /* We scan the operands twice.  The first time we don't print anything,
1568
     but look for errors.  */
1569
2.22M
  for (d = args; *d; d += 2)
1570
1.58M
    {
1571
1.58M
      int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1572
1573
1.58M
      if (eaten >= 0)
1574
1.37M
  p += eaten;
1575
213k
      else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
1576
329
         || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
1577
213k
  {
1578
213k
    info->fprintf_styled_func = save_printer;
1579
213k
    info->print_address_func = save_print_address;
1580
213k
    return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
1581
213k
  }
1582
0
      else
1583
0
  {
1584
    /* We must restore the print functions before trying to print the
1585
       error message.  */
1586
0
    info->fprintf_styled_func = save_printer;
1587
0
    info->print_address_func = save_print_address;
1588
0
    info->fprintf_styled_func (info->stream, dis_style_text,
1589
             /* xgettext:c-format */
1590
0
             _("<internal error in opcode table: %s %s>\n"),
1591
0
             best->name, best->args);
1592
0
    return 2;
1593
0
  }
1594
1.58M
    }
1595
1596
636k
  p = save_p;
1597
636k
  info->fprintf_styled_func = save_printer;
1598
636k
  info->print_address_func = save_print_address;
1599
636k
  info->insn_type = m68k_opcode_to_insn_type (best);
1600
1601
636k
  d = args;
1602
1603
636k
  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
1604
1605
636k
  if (*d)
1606
636k
    info->fprintf_styled_func (info->stream, dis_style_text, " ");
1607
1608
1.88M
  while (*d)
1609
1.24M
    {
1610
1.24M
      p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1611
1.24M
      d += 2;
1612
1613
1.24M
      if (*d && *(d - 2) != 'I' && *d != 'k')
1614
607k
  info->fprintf_styled_func (info->stream, dis_style_text, ",");
1615
1.24M
    }
1616
1617
636k
  return p - buffer;
1618
849k
}
1619
1620
/* Try to interpret the instruction at address MEMADDR as one that
1621
   can execute on a processor with the features given by ARCH_MASK.
1622
   If successful, print the instruction to INFO->STREAM and return
1623
   its length in bytes.  Return 0 otherwise.  Return -1 on memory
1624
   error.  */
1625
1626
static int
1627
m68k_scan_mask (bfd_vma memaddr, disassemble_info *info,
1628
    unsigned int arch_mask)
1629
1.06M
{
1630
1.06M
  int i;
1631
1.06M
  const char *d;
1632
1.06M
  static const struct m68k_opcode **opcodes[16];
1633
1.06M
  static int numopcodes[16];
1634
1.06M
  int val;
1635
1.06M
  int major_opcode;
1636
1637
1.06M
  struct private *priv = (struct private *) info->private_data;
1638
1.06M
  bfd_byte *buffer = priv->the_buffer;
1639
1640
1.06M
  if (!opcodes[0])
1641
2
    {
1642
      /* Speed up the matching by sorting the opcode
1643
   table on the upper four bits of the opcode.  */
1644
2
      const struct m68k_opcode **opc_pointer[16];
1645
1646
      /* First count how many opcodes are in each of the sixteen buckets.  */
1647
3.81k
      for (i = 0; i < m68k_numopcodes; i++)
1648
3.81k
  numopcodes[(m68k_opcodes[i].opcode >> 28) & 15]++;
1649
1650
      /* Then create a sorted table of pointers
1651
   that point into the unsorted table.  */
1652
2
      opc_pointer[0] = xmalloc (sizeof (struct m68k_opcode *)
1653
2
        * m68k_numopcodes);
1654
2
      opcodes[0] = opc_pointer[0];
1655
1656
32
      for (i = 1; i < 16; i++)
1657
30
  {
1658
30
    opc_pointer[i] = opc_pointer[i - 1] + numopcodes[i - 1];
1659
30
    opcodes[i] = opc_pointer[i];
1660
30
  }
1661
1662
3.81k
      for (i = 0; i < m68k_numopcodes; i++)
1663
3.81k
  *opc_pointer[(m68k_opcodes[i].opcode >> 28) & 15]++ = &m68k_opcodes[i];
1664
2
    }
1665
1666
1.06M
  if (!FETCH_DATA (info, buffer + 2))
1667
514
    return -1;
1668
1.06M
  major_opcode = (buffer[0] >> 4) & 15;
1669
1670
249M
  for (i = 0; i < numopcodes[major_opcode]; i++)
1671
248M
    {
1672
248M
      const struct m68k_opcode *opc = opcodes[major_opcode][i];
1673
248M
      unsigned long opcode = opc->opcode;
1674
248M
      unsigned long match = opc->match;
1675
248M
      const char *args = opc->args;
1676
1677
248M
      if (*args == '.')
1678
2.83M
  args++;
1679
1680
248M
      if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
1681
52.6M
    && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
1682
    /* Only fetch the next two bytes if we need to.  */
1683
15.2M
    && (((0xffff & match) == 0)
1684
14.1M
        ||
1685
14.1M
        (FETCH_DATA (info, buffer + 4)
1686
14.1M
         && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
1687
1.05M
         && ((0xff & buffer[3] & match) == (0xff & opcode)))
1688
15.2M
        )
1689
1.21M
    && (opc->arch & arch_mask) != 0)
1690
875k
  {
1691
    /* Don't use for printout the variants of divul and divsl
1692
       that have the same register number in two places.
1693
       The more general variants will match instead.  */
1694
2.63M
    for (d = args; *d; d += 2)
1695
1.75M
      if (d[1] == 'D')
1696
369
        break;
1697
1698
    /* Don't use for printout the variants of most floating
1699
       point coprocessor instructions which use the same
1700
       register number in two places, as above.  */
1701
875k
    if (*d == '\0')
1702
2.63M
      for (d = args; *d; d += 2)
1703
1.75M
        if (d[1] == 't')
1704
545
    break;
1705
1706
    /* Don't match fmovel with more than one register;
1707
       wait for fmoveml.  */
1708
875k
    if (*d == '\0')
1709
874k
      {
1710
2.62M
        for (d = args; *d; d += 2)
1711
1.75M
    {
1712
1.75M
      if (d[0] == 's' && d[1] == '8')
1713
965
        {
1714
965
          val = fetch_arg (buffer, d[1], 3, info);
1715
965
          if (val < 0)
1716
0
      return 0;
1717
965
          if ((val & (val - 1)) != 0)
1718
61
      break;
1719
965
        }
1720
1.75M
    }
1721
874k
      }
1722
1723
    /* Don't match FPU insns with non-default coprocessor ID.  */
1724
875k
    if (*d == '\0')
1725
874k
      {
1726
2.57M
        for (d = args; *d; d += 2)
1727
1.72M
    {
1728
1.72M
      if (d[0] == 'I')
1729
31.4k
        {
1730
31.4k
          val = fetch_arg (buffer, 'd', 3, info);
1731
31.4k
          if (val != 1)
1732
24.0k
      break;
1733
31.4k
        }
1734
1.72M
    }
1735
874k
      }
1736
1737
875k
    if (*d == '\0')
1738
849k
      if ((val = match_insn_m68k (memaddr, info, opc)))
1739
637k
        return val;
1740
875k
  }
1741
248M
    }
1742
431k
  return 0;
1743
1.06M
}
1744
1745
/* Print the m68k instruction at address MEMADDR in debugged memory,
1746
   on INFO->STREAM.  Returns length of the instruction, in bytes.  */
1747
1748
int
1749
print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
1750
861k
{
1751
861k
  unsigned int arch_mask;
1752
861k
  struct private priv;
1753
861k
  int val;
1754
1755
861k
  bfd_byte *buffer = priv.the_buffer;
1756
1757
861k
  info->insn_info_valid = 1;
1758
861k
  info->private_data = & priv;
1759
  /* Tell objdump to use two bytes per chunk
1760
     and six bytes per line for displaying raw data.  */
1761
861k
  info->bytes_per_chunk = 2;
1762
861k
  info->bytes_per_line = 6;
1763
861k
  info->display_endian = BFD_ENDIAN_BIG;
1764
861k
  priv.max_fetched = priv.the_buffer;
1765
861k
  priv.insn_start = memaddr;
1766
1767
861k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
1768
861k
  if (!arch_mask)
1769
748k
    {
1770
      /* First try printing an m680x0 instruction.  Try printing a Coldfire
1771
   one if that fails.  */
1772
748k
      val = m68k_scan_mask (memaddr, info, m68k_mask);
1773
748k
      if (val <= 0)
1774
207k
  val = m68k_scan_mask (memaddr, info, mcf_mask);
1775
748k
    }
1776
113k
  else
1777
113k
    {
1778
113k
      val = m68k_scan_mask (memaddr, info, arch_mask);
1779
113k
    }
1780
1781
861k
  if (val == 0)
1782
224k
    {
1783
      /* Handle undefined instructions.  */
1784
224k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
1785
224k
         ".short");
1786
224k
      info->fprintf_styled_func (info->stream, dis_style_text, " ");
1787
224k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
1788
224k
         "0x%04x", (buffer[0] << 8) + buffer[1]);
1789
1790
224k
      info->insn_type = dis_noninsn;
1791
224k
    }
1792
1793
861k
  return val ? val : 2;
1794
861k
}