Coverage Report

Created: 2026-09-14 08:07

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
562k
#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
438k
  do            \
77
438k
    {           \
78
438k
      p += 2;         \
79
438k
      if (!FETCH_DATA (info, p))   \
80
438k
  return PRINT_INSN_ARG_MEMORY_ERROR; \
81
438k
      val = COERCE_SIGNED_CHAR (p[-1]);   \
82
438k
    }            \
83
438k
  while (0)
84
85
/* Get a 2 byte signed integer.  */
86
386k
#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
87
88
#define NEXTWORD(p, val, ret_val)   \
89
386k
  do            \
90
386k
    {           \
91
386k
      p += 2;         \
92
386k
      if (!FETCH_DATA (info, p))   \
93
386k
  return ret_val;       \
94
386k
      val = COERCE16 ((p[-2] << 8) + p[-1]);  \
95
386k
    }            \
96
386k
  while (0)
97
98
/* Get a 4 byte signed integer.  */
99
75.9k
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000)
100
101
#define NEXTLONG(p, val, ret_val)         \
102
76.0k
  do                  \
103
76.0k
    {                 \
104
76.0k
      p += 4;               \
105
76.0k
      if (!FETCH_DATA (info, p))         \
106
76.0k
  return ret_val;             \
107
76.0k
      val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8)  \
108
75.9k
      + p[-2]) << 8) + p[-1]);      \
109
75.9k
    }                  \
110
76.0k
  while (0)
111
112
/* Get a 4 byte unsigned integer.  */
113
#define NEXTULONG(p, val)           \
114
15.6k
  do                  \
115
15.6k
    {                 \
116
15.6k
      p += 4;               \
117
15.6k
      if (!FETCH_DATA (info, p))         \
118
15.6k
  return PRINT_INSN_ARG_MEMORY_ERROR;       \
119
15.6k
      val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8)     \
120
15.5k
         + p[-2]) << 8) + p[-1]);         \
121
15.5k
    }                  \
122
15.6k
  while (0)
123
124
/* Get a single precision float.  */
125
#define NEXTSINGLE(val, p)          \
126
270
  do                \
127
270
    {               \
128
270
      p += 4;             \
129
270
      if (!FETCH_DATA (info, p))       \
130
270
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
131
270
      floatformat_to_double (& floatformat_ieee_single_big, \
132
270
           (char *) p - 4, & val);    \
133
270
    }                \
134
270
  while (0)
135
136
/* Get a double precision float.  */
137
#define NEXTDOUBLE(val, p)          \
138
1.06k
  do                \
139
1.06k
    {               \
140
1.06k
      p += 8;             \
141
1.06k
      if (!FETCH_DATA (info, p))       \
142
1.06k
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
143
1.06k
      floatformat_to_double (& floatformat_ieee_double_big, \
144
1.06k
           (char *) p - 8, & val);    \
145
1.06k
    }                \
146
1.06k
  while (0)
147
148
/* Get an extended precision float.  */
149
#define NEXTEXTEND(val, p)        \
150
581
  do              \
151
581
    {             \
152
581
      p += 12;            \
153
581
      if (!FETCH_DATA (info, p))     \
154
581
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
155
581
      floatformat_to_double (& floatformat_m68881_ext,  \
156
580
           (char *) p - 12, & val); \
157
580
    }              \
158
581
  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
986
  do            \
166
986
    {           \
167
986
      p += 12;          \
168
986
      if (!FETCH_DATA (info, p))   \
169
986
  return PRINT_INSN_ARG_MEMORY_ERROR; \
170
986
      val = 0.0;        \
171
978
    }            \
172
986
  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
38.3M
  ((addr) <= ((struct private *) (info->private_data))->max_fetched \
191
38.3M
   ? 1 : fetch_data ((info), (addr)))
192
193
static int
194
fetch_data (struct disassemble_info *info, bfd_byte *addr)
195
1.67M
{
196
1.67M
  int status;
197
1.67M
  struct private *priv = (struct private *)info->private_data;
198
1.67M
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
199
200
1.67M
  status = (*info->read_memory_func) (start,
201
1.67M
              priv->max_fetched,
202
1.67M
              addr - priv->max_fetched,
203
1.67M
              info);
204
1.67M
  if (status != 0)
205
19.2k
    {
206
19.2k
      (*info->memory_error_func) (status, start, info);
207
19.2k
      return 0;
208
19.2k
    }
209
1.65M
  else
210
1.65M
    priv->max_fetched = addr;
211
1.65M
  return 1;
212
1.67M
}
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.55M
{
221
2.55M
  return 0;
222
2.55M
}
223
224
static void
225
dummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,
226
         struct disassemble_info *info ATTRIBUTE_UNUSED)
227
95.7k
{
228
95.7k
}
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.93M
{
242
2.93M
  int val = 0;
243
244
2.93M
  switch (code)
245
2.93M
    {
246
9.74k
    case '/': /* MAC/EMAC mask bit.  */
247
9.74k
      val = buffer[3] >> 5;
248
9.74k
      break;
249
250
1.23k
    case 'G': /* EMAC ACC load.  */
251
1.23k
      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);
252
1.23k
      break;
253
254
784
    case 'H': /* EMAC ACC !load.  */
255
784
      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);
256
784
      break;
257
258
406
    case ']': /* EMAC ACCEXT bit.  */
259
406
      val = buffer[0] >> 2;
260
406
      break;
261
262
15.0k
    case 'I': /* MAC/EMAC scale factor.  */
263
15.0k
      val = buffer[2] >> 1;
264
15.0k
      break;
265
266
802
    case 'F': /* EMAC ACCx.  */
267
802
      val = buffer[0] >> 1;
268
802
      break;
269
270
272
    case 'f':
271
272
      val = buffer[1];
272
272
      break;
273
274
1.72M
    case 's':
275
1.72M
      val = buffer[1];
276
1.72M
      break;
277
278
720k
    case 'd':     /* Destination, for register or quick.  */
279
720k
      val = (buffer[0] << 8) + buffer[1];
280
720k
      val >>= 9;
281
720k
      break;
282
283
240k
    case 'x':     /* Destination, for general arg.  */
284
240k
      val = (buffer[0] << 8) + buffer[1];
285
240k
      val >>= 6;
286
240k
      break;
287
288
164
    case 'k':
289
164
      if (! FETCH_DATA (info, buffer + 3))
290
0
  return -1;
291
164
      val = (buffer[3] >> 4);
292
164
      break;
293
294
844
    case 'C':
295
844
      if (! FETCH_DATA (info, buffer + 3))
296
0
  return -1;
297
844
      val = buffer[3];
298
844
      break;
299
300
52.5k
    case '1':
301
52.5k
      if (! FETCH_DATA (info, buffer + 3))
302
0
  return -1;
303
52.5k
      val = (buffer[2] << 8) + buffer[3];
304
52.5k
      val >>= 12;
305
52.5k
      break;
306
307
2.57k
    case '2':
308
2.57k
      if (! FETCH_DATA (info, buffer + 3))
309
0
  return -1;
310
2.57k
      val = (buffer[2] << 8) + buffer[3];
311
2.57k
      val >>= 6;
312
2.57k
      break;
313
314
45.7k
    case '3':
315
47.9k
    case 'j':
316
47.9k
      if (! FETCH_DATA (info, buffer + 3))
317
0
  return -1;
318
47.9k
      val = (buffer[2] << 8) + buffer[3];
319
47.9k
      break;
320
321
554
    case '4':
322
554
      if (! FETCH_DATA (info, buffer + 5))
323
0
  return -1;
324
554
      val = (buffer[4] << 8) + buffer[5];
325
554
      val >>= 12;
326
554
      break;
327
328
554
    case '5':
329
554
      if (! FETCH_DATA (info, buffer + 5))
330
0
  return -1;
331
554
      val = (buffer[4] << 8) + buffer[5];
332
554
      val >>= 6;
333
554
      break;
334
335
554
    case '6':
336
554
      if (! FETCH_DATA (info, buffer + 5))
337
0
  return -1;
338
554
      val = (buffer[4] << 8) + buffer[5];
339
554
      break;
340
341
5.45k
    case '7':
342
5.45k
      if (! FETCH_DATA (info, buffer + 3))
343
0
  return -1;
344
5.45k
      val = (buffer[2] << 8) + buffer[3];
345
5.45k
      val >>= 7;
346
5.45k
      break;
347
348
10.5k
    case '8':
349
10.5k
      if (! FETCH_DATA (info, buffer + 3))
350
0
  return -1;
351
10.5k
      val = (buffer[2] << 8) + buffer[3];
352
10.5k
      val >>= 10;
353
10.5k
      break;
354
355
927
    case '9':
356
927
      if (! FETCH_DATA (info, buffer + 3))
357
0
  return -1;
358
927
      val = (buffer[2] << 8) + buffer[3];
359
927
      val >>= 5;
360
927
      break;
361
362
3.14k
    case 'e':
363
3.14k
      val = (buffer[1] >> 6);
364
3.14k
      break;
365
366
39.7k
    case 'E':
367
39.7k
      if (! FETCH_DATA (info, buffer + 3))
368
0
  return -1;
369
39.7k
      val = (buffer[2] >> 1);
370
39.7k
      break;
371
372
7.24k
    case 'm':
373
7.24k
      val = (buffer[1] & 0x40 ? 0x8 : 0)
374
7.24k
  | ((buffer[0] >> 1) & 0x7)
375
7.24k
  | (buffer[3] & 0x80 ? 0x10 : 0);
376
7.24k
      break;
377
378
9.74k
    case 'n':
379
9.74k
      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
380
9.74k
      break;
381
382
14.0k
    case 'o':
383
14.0k
      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
384
14.0k
      break;
385
386
7.24k
    case 'M':
387
7.24k
      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
388
7.24k
      break;
389
390
14.0k
    case 'N':
391
14.0k
      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
392
14.0k
      break;
393
394
858
    case 'h':
395
858
      val = buffer[2] >> 2;
396
858
      break;
397
398
0
    default:
399
0
      abort ();
400
2.93M
    }
401
402
  /* bits is never too big.  */
403
2.93M
  return val & ((1 << bits) - 1);
404
2.93M
}
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.78M
{
416
1.78M
  int mode, mask;
417
1.78M
#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \
418
1.78M
  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \
419
1.78M
   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)
420
421
1.78M
  switch (code)
422
1.78M
    {
423
317k
    case '*':
424
317k
      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);
425
317k
      break;
426
74.2k
    case '~':
427
74.2k
      mask = M (0,0,1,1,1,1,1,1,1,0,0,0);
428
74.2k
      break;
429
256k
    case '%':
430
256k
      mask = M (1,1,1,1,1,1,1,1,1,0,0,0);
431
256k
      break;
432
271k
    case ';':
433
271k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,1);
434
271k
      break;
435
7.69k
    case '@':
436
7.69k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,0);
437
7.69k
      break;
438
11.9k
    case '!':
439
11.9k
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
440
11.9k
      break;
441
3.40k
    case '&':
442
3.40k
      mask = M (0,0,1,0,0,1,1,1,1,0,0,0);
443
3.40k
      break;
444
664k
    case '$':
445
664k
      mask = M (1,0,1,1,1,1,1,1,1,0,0,0);
446
664k
      break;
447
1.22k
    case '?':
448
1.22k
      mask = M (1,0,1,0,0,1,1,1,1,0,0,0);
449
1.22k
      break;
450
1.10k
    case '/':
451
1.10k
      mask = M (1,0,1,0,0,1,1,1,1,1,1,0);
452
1.10k
      break;
453
126
    case '|':
454
126
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
455
126
      break;
456
1.76k
    case '>':
457
1.76k
      mask = M (0,0,1,0,1,1,1,1,1,0,0,0);
458
1.76k
      break;
459
3.77k
    case '<':
460
3.77k
      mask = M (0,0,1,1,0,1,1,1,1,1,1,0);
461
3.77k
      break;
462
43.5k
    case 'm':
463
43.5k
      mask = M (1,1,1,1,1,0,0,0,0,0,0,0);
464
43.5k
      break;
465
33.3k
    case 'n':
466
33.3k
      mask = M (0,0,0,0,0,1,0,0,0,1,0,0);
467
33.3k
      break;
468
28.4k
    case 'o':
469
28.4k
      mask = M (0,0,0,0,0,0,1,1,1,0,1,1);
470
28.4k
      break;
471
48.9k
    case 'p':
472
48.9k
      mask = M (1,1,1,1,1,1,0,0,0,0,0,0);
473
48.9k
      break;
474
3.72k
    case 'q':
475
3.72k
      mask = M (1,0,1,1,1,1,0,0,0,0,0,0);
476
3.72k
      break;
477
2.18k
    case 'v':
478
2.18k
      mask = M (1,0,1,1,1,1,0,1,1,0,0,0);
479
2.18k
      break;
480
74
    case 'b':
481
74
      mask = M (1,0,1,1,1,1,0,0,0,1,0,0);
482
74
      break;
483
95
    case 'w':
484
95
      mask = M (0,0,1,1,1,1,0,0,0,1,0,0);
485
95
      break;
486
1.69k
    case 'y':
487
1.69k
      mask = M (0,0,1,0,0,1,0,0,0,0,0,0);
488
1.69k
      break;
489
344
    case 'z':
490
344
      mask = M (0,0,1,0,0,1,0,0,0,1,0,0);
491
344
      break;
492
11.3k
    case '4':
493
11.3k
      mask = M (0,0,1,1,1,1,0,0,0,0,0,0);
494
11.3k
      break;
495
0
    default:
496
0
      abort ();
497
1.78M
    }
498
1.78M
#undef M
499
500
1.78M
  mode = (val >> 3) & 7;
501
1.78M
  if (mode == 7)
502
211k
    mode += val & 7;
503
1.78M
  return (mask & (1 << mode)) != 0;
504
1.78M
}
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
130k
{
512
130k
  if (regno == -1)
513
7.00k
    {
514
7.00k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
515
7.00k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
516
7.00k
      (*info->print_address_func) (disp, info);
517
7.00k
    }
518
123k
  else
519
123k
    {
520
123k
      if (regno == -3)
521
1.63k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
522
1.63k
              "%%zpc");
523
121k
      else if (regno != -2)
524
102k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
525
102k
              "%s", reg_names[regno]);
526
123k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
527
123k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
528
123k
            "%" PRIx64, (uint64_t) disp);
529
123k
    }
530
130k
}
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
104k
{
538
104k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
539
104k
        "%s", reg_names[(ext >> 12) & 0xf]);
540
104k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
541
104k
        ":%c", ext & 0x800 ? 'l' : 'w');
542
104k
  if ((ext >> 9) & 3)
543
62.9k
    {
544
62.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
545
62.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
546
62.9k
            "%d", 1 << ((ext >> 9) & 3));
547
62.9k
    }
548
104k
}
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
130k
{
561
130k
  int word;
562
130k
  bfd_vma base_disp;
563
130k
  bfd_vma outer_disp;
564
130k
  bool print_index = true;
565
566
130k
  NEXTWORD (p, word, NULL);
567
568
  /* Handle the 68000 style of indexing.  */
569
570
130k
  if ((word & 0x100) == 0)
571
72.9k
    {
572
72.9k
      base_disp = word & 0xff;
573
72.9k
      if ((base_disp & 0x80) != 0)
574
23.0k
  base_disp -= 0x100;
575
72.9k
      if (basereg == -1)
576
3.06k
  base_disp += addr;
577
72.9k
      print_base (basereg, base_disp, info);
578
72.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
579
72.9k
      print_index_register (word, info);
580
72.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
581
72.9k
      return p;
582
72.9k
    }
583
584
  /* Handle the generalized kind.  */
585
  /* First, compute the displacement to add to the base register.  */
586
57.6k
  if (word & 0200)
587
21.3k
    {
588
21.3k
      if (basereg == -1)
589
1.63k
  basereg = -3;
590
19.7k
      else
591
19.7k
  basereg = -2;
592
21.3k
    }
593
57.6k
  if (word & 0100)
594
25.8k
    print_index = false;
595
57.6k
  base_disp = 0;
596
57.6k
  switch ((word >> 4) & 3)
597
57.6k
    {
598
12.8k
    case 2:
599
12.8k
      NEXTWORD (p, base_disp, NULL);
600
12.8k
      break;
601
23.3k
    case 3:
602
23.3k
      NEXTLONG (p, base_disp, NULL);
603
57.6k
    }
604
57.6k
  if (basereg == -1)
605
3.95k
    base_disp += addr;
606
607
  /* Handle single-level case (not indirect).  */
608
57.6k
  if ((word & 7) == 0)
609
10.2k
    {
610
10.2k
      print_base (basereg, base_disp, info);
611
10.2k
      if (print_index)
612
7.43k
  {
613
7.43k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
614
7.43k
    print_index_register (word, info);
615
7.43k
  }
616
10.2k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
617
10.2k
      return p;
618
10.2k
    }
619
620
  /* Two level.  Compute displacement to add after indirection.  */
621
47.3k
  outer_disp = 0;
622
47.3k
  switch (word & 3)
623
47.3k
    {
624
12.9k
    case 2:
625
12.9k
      NEXTWORD (p, outer_disp, NULL);
626
12.8k
      break;
627
14.7k
    case 3:
628
14.7k
      NEXTLONG (p, outer_disp, NULL);
629
47.3k
    }
630
631
47.2k
  print_base (basereg, base_disp, info);
632
47.2k
  if ((word & 4) == 0 && print_index)
633
12.3k
    {
634
12.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
635
12.3k
      print_index_register (word, info);
636
12.3k
      print_index = false;
637
12.3k
    }
638
47.2k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
639
47.2k
        ")@(");
640
47.2k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
641
47.2k
        "%" PRIx64, (uint64_t) outer_disp);
642
47.2k
  if (print_index)
643
11.9k
    {
644
11.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
645
11.9k
      print_index_register (word, info);
646
11.9k
    }
647
47.2k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
648
649
47.2k
  return p;
650
47.3k
}
651
652
#define FETCH_ARG(size, val)        \
653
1.08M
  do              \
654
1.08M
    {             \
655
1.08M
      val = fetch_arg (buffer, place, size, info);  \
656
1.08M
      if (val < 0)         \
657
1.08M
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
658
1.08M
    }             \
659
1.08M
  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.55M
{
672
3.55M
  int val = 0;
673
3.55M
  int place = d[1];
674
3.55M
  unsigned char *p = p0;
675
3.55M
  int regno;
676
3.55M
  const char *regname;
677
3.55M
  unsigned char *p1;
678
3.55M
  double flval;
679
3.55M
  int flt_p;
680
3.55M
  bfd_signed_vma disp;
681
3.55M
  unsigned int uval;
682
683
3.55M
  switch (*d)
684
3.55M
    {
685
3.14k
    case 'c':   /* Cache identifier.  */
686
3.14k
      {
687
3.14k
        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
688
3.14k
        FETCH_ARG (2, val);
689
3.14k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
690
3.14k
              "%s", cacheFieldName[val]);
691
3.14k
        break;
692
3.14k
      }
693
694
5.82k
    case 'a':   /* Address register indirect only. Cf. case '+'.  */
695
5.82k
      {
696
5.82k
  FETCH_ARG (3, val);
697
5.82k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
698
5.82k
              reg_names[val + 8]);
699
5.82k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
700
5.82k
        break;
701
5.82k
      }
702
703
1.43k
    case '_':   /* 32-bit absolute address for move16.  */
704
1.43k
      {
705
1.43k
        NEXTULONG (p, uval);
706
1.42k
  (*info->print_address_func) (uval, info);
707
1.42k
        break;
708
1.43k
      }
709
710
2.78k
    case 'C':
711
2.78k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
712
2.78k
      break;
713
714
2.30k
    case 'S':
715
2.30k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
716
2.30k
      break;
717
718
614
    case 'U':
719
614
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
720
614
      break;
721
722
1.05k
    case 'E':
723
1.05k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
724
1.05k
      break;
725
726
548
    case 'G':
727
548
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
728
548
      break;
729
730
2.16k
    case 'H':
731
2.16k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
732
2.16k
      break;
733
734
2.20k
    case 'J':
735
2.20k
      {
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.20k
  struct regname { char * name; int value; };
740
2.20k
  static const struct regname names[] =
741
2.20k
    {
742
2.20k
      {"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
743
2.20k
      {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
744
2.20k
      {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
745
2.20k
      {"%rgpiobar", 0x009}, {"%acr4",0x00c},
746
2.20k
      {"%acr5",0x00d}, {"%acr6",0x00e}, {"%acr7", 0x00f},
747
2.20k
      {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
748
2.20k
      {"%msp", 0x803}, {"%isp", 0x804},
749
2.20k
      {"%pc", 0x80f},
750
      /* Reg c04 is sometimes called flashbar or rambar.
751
         Reg c05 is also sometimes called rambar.  */
752
2.20k
      {"%rambar0", 0xc04}, {"%rambar1", 0xc05},
753
754
      /* reg c0e is sometimes called mbar2 or secmbar.
755
         reg c0f is sometimes called mbar.  */
756
2.20k
      {"%mbar0", 0xc0e}, {"%mbar1", 0xc0f},
757
758
      /* Should we be calling this psr like we do in case 'Y'?  */
759
2.20k
      {"%mmusr",0x805},
760
761
2.20k
      {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808},
762
763
      /* Fido added these.  */
764
2.20k
      {"%cac", 0xffe}, {"%mbo", 0xfff}
765
2.20k
  };
766
  /* Alternate names for v4e (MCF5407/5445x/MCF547x/MCF548x), at least.  */
767
2.20k
  static const struct regname names_v4e[] =
768
2.20k
    {
769
2.20k
      {"%asid",0x003}, {"%acr0",0x004}, {"%acr1",0x005},
770
2.20k
      {"%acr2",0x006}, {"%acr3",0x007}, {"%mmubar",0x008},
771
2.20k
    };
772
2.20k
  unsigned int arch_mask;
773
774
2.20k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
775
2.20k
  FETCH_ARG (12, val);
776
2.20k
  if (arch_mask & (mcfisa_b | mcfisa_c))
777
838
    {
778
5.77k
      for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
779
5.02k
        if (names_v4e[regno].value == val)
780
94
    {
781
94
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
782
94
                 "%s", names_v4e[regno].name);
783
94
      break;
784
94
    }
785
838
      if (regno >= 0)
786
94
        break;
787
838
    }
788
62.7k
  for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
789
61.1k
    if (names[regno].value == val)
790
468
      {
791
468
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
792
468
              "%s", names[regno].name);
793
468
        break;
794
468
      }
795
2.11k
  if (regno < 0)
796
1.64k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
797
2.11k
      }
798
0
      break;
799
800
129k
    case 'Q':
801
129k
      FETCH_ARG (3, val);
802
      /* 0 means 8, except for the bkpt instruction... */
803
129k
      if (val == 0 && d[1] != 's')
804
7.56k
  val = 8;
805
129k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
806
129k
            "#%d", val);
807
129k
      break;
808
809
5.18k
    case 'x':
810
5.18k
      FETCH_ARG (3, val);
811
      /* 0 means -1.  */
812
5.18k
      if (val == 0)
813
1.07k
  val = -1;
814
5.18k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
815
5.18k
            "#%d", val);
816
5.18k
      break;
817
818
39.7k
    case 'j':
819
39.7k
      FETCH_ARG (3, val);
820
39.7k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
821
39.7k
            "#%d", val+1);
822
39.7k
      break;
823
824
38.9k
    case 'K':
825
38.9k
      FETCH_ARG (9, val);
826
38.9k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
827
38.9k
            "#%d", val);
828
38.9k
      break;
829
830
52.1k
    case 'M':
831
52.1k
      if (place == 'h')
832
858
  {
833
858
    static char *const scalefactor_name[] = { "<<", ">>" };
834
835
858
    FETCH_ARG (1, val);
836
858
    (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
837
858
          "%s", scalefactor_name[val]);
838
858
  }
839
51.2k
      else
840
51.2k
  {
841
51.2k
    FETCH_ARG (8, val);
842
51.2k
    if (val & 0x80)
843
13.7k
      val = val - 0x100;
844
51.2k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
845
51.2k
          "#%d", val);
846
51.2k
  }
847
52.1k
      break;
848
849
52.1k
    case 'T':
850
7.69k
      FETCH_ARG (4, val);
851
7.69k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
852
7.69k
            "#%d", val);
853
7.69k
      break;
854
855
532k
    case 'D':
856
532k
      FETCH_ARG (3, val);
857
532k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
858
532k
            "%s", reg_names[val]);
859
532k
      break;
860
861
72.1k
    case 'A':
862
72.1k
      FETCH_ARG (3, val);
863
72.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
864
72.1k
            "%s", reg_names[val + 010]);
865
72.1k
      break;
866
867
84.1k
    case 'R':
868
84.1k
      FETCH_ARG (4, val);
869
84.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
870
84.1k
            "%s", reg_names[val]);
871
84.1k
      break;
872
873
1.10k
    case 'r':
874
1.10k
      FETCH_ARG (4, regno);
875
1.10k
      if (regno > 7)
876
208
  {
877
208
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
878
208
          "%s", reg_names[regno]);
879
208
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
880
208
  }
881
900
      else
882
900
  {
883
900
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
884
900
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
885
900
          "%s", reg_names[regno]);
886
900
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
887
900
  }
888
1.10k
      break;
889
890
6.73k
    case 'F':
891
6.73k
      FETCH_ARG (3, val);
892
6.73k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
893
6.73k
            "%%fp%d", val);
894
6.73k
      break;
895
896
3.86k
    case 'O':
897
3.86k
      FETCH_ARG (6, val);
898
3.86k
      if (val & 0x20)
899
1.60k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
900
1.60k
              "%s", reg_names[val & 7]);
901
2.25k
      else
902
2.25k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
903
2.25k
              "%d", val);
904
3.86k
      break;
905
906
5.92k
    case '+':
907
5.92k
      FETCH_ARG (3, val);
908
5.92k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
909
5.92k
            "%s", reg_names[val + 8]);
910
5.92k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
911
5.92k
      break;
912
913
16.8k
    case '-':
914
16.8k
      FETCH_ARG (3, val);
915
16.8k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
916
16.8k
            "%s", reg_names[val + 8]);
917
16.8k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
918
16.8k
      break;
919
920
642
    case 'k':
921
642
      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
642
      else if (place == 'C')
930
642
  {
931
642
    FETCH_ARG (7, val);
932
642
    if (val > 63)    /* This is a signed constant.  */
933
506
      val -= 128;
934
642
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
935
642
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
936
642
          "#%d", val);
937
642
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
938
642
  }
939
0
      else
940
0
  return PRINT_INSN_ARG_INVALID_OPERAND;
941
642
      break;
942
943
523k
    case '#':
944
524k
    case '^':
945
524k
      p1 = buffer + (*d == '#' ? 2 : 4);
946
524k
      if (place == 's')
947
0
  FETCH_ARG (4, val);
948
524k
      else if (place == 'C')
949
202
  FETCH_ARG (7, val);
950
524k
      else if (place == '8')
951
0
  FETCH_ARG (3, val);
952
524k
      else if (place == '3')
953
626
  FETCH_ARG (8, val);
954
523k
      else if (place == 'b')
955
435k
  NEXTBYTE (p1, val);
956
88.6k
      else if (place == 'w' || place == 'W')
957
58.7k
  NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
958
29.8k
      else if (place == 'l')
959
29.8k
  NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
960
0
      else
961
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
962
963
524k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
964
524k
            "#%d", val);
965
524k
      break;
966
967
141k
    case 'B':
968
141k
      if (place == 'b')
969
0
  NEXTBYTE (p, disp);
970
141k
      else if (place == 'B')
971
123k
  disp = COERCE_SIGNED_CHAR (buffer[1]);
972
17.7k
      else if (place == 'w' || place == 'W')
973
10.9k
  NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
974
6.80k
      else if (place == 'l' || place == 'L' || place == 'C')
975
4.96k
  NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
976
1.83k
      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
1.83k
      else if (place == 'c')
985
1.83k
  {
986
1.83k
    if (buffer[1] & 0x40)    /* If bit six is one, long offset.  */
987
1.02k
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
988
815
    else
989
815
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
990
1.83k
  }
991
0
      else
992
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
993
994
141k
      info->target = addr + disp;
995
996
141k
      (*info->print_address_func) (addr + disp, info);
997
141k
      break;
998
999
10.5k
    case 'd':
1000
10.5k
      {
1001
10.5k
  int val1;
1002
1003
10.5k
  NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1004
10.5k
  FETCH_ARG (3, val1);
1005
10.5k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
1006
10.5k
              "%s", reg_names[val1 + 8]);
1007
10.5k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1008
10.5k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1009
10.5k
              "%d", val);
1010
10.5k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1011
10.5k
  break;
1012
10.5k
      }
1013
1014
962
    case 's':
1015
962
      FETCH_ARG (3, val);
1016
962
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1017
962
            "%s", fpcr_names[val]);
1018
962
      break;
1019
1020
3.09k
    case 'e':
1021
3.09k
      FETCH_ARG (2, val);
1022
3.09k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1023
3.09k
            "%%acc%d", val);
1024
3.09k
      break;
1025
1026
406
    case 'g':
1027
406
      FETCH_ARG (1, val);
1028
406
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1029
406
            "%%accext%s", val == 0 ? "01" : "23");
1030
406
      break;
1031
1032
15.0k
    case 'i':
1033
15.0k
      FETCH_ARG (2, val);
1034
15.0k
      if (val == 1)
1035
4.89k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1036
4.89k
              "<<");
1037
10.1k
      else if (val == 3)
1038
4.28k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1039
4.28k
              ">>");
1040
5.89k
      else
1041
5.89k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1042
9.18k
      break;
1043
1044
13.9k
    case 'I':
1045
      /* Get coprocessor ID... */
1046
13.9k
      val = fetch_arg (buffer, 'd', 3, info);
1047
13.9k
      if (val < 0)
1048
0
  return PRINT_INSN_ARG_MEMORY_ERROR;
1049
13.9k
      if (val != 1)        /* Unusual coprocessor ID?  */
1050
0
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
1051
0
              "(cpid=%d) ", val);
1052
13.9k
      break;
1053
1054
11.3k
    case '4':
1055
328k
    case '*':
1056
402k
    case '~':
1057
659k
    case '%':
1058
931k
    case ';':
1059
938k
    case '@':
1060
950k
    case '!':
1061
1.61M
    case '$':
1062
1.61M
    case '?':
1063
1.61M
    case '/':
1064
1.62M
    case '&':
1065
1.62M
    case '|':
1066
1.62M
    case '<':
1067
1.62M
    case '>':
1068
1.67M
    case 'm':
1069
1.70M
    case 'n':
1070
1.73M
    case 'o':
1071
1.78M
    case 'p':
1072
1.78M
    case 'q':
1073
1.78M
    case 'v':
1074
1.78M
    case 'b':
1075
1.78M
    case 'w':
1076
1.78M
    case 'y':
1077
1.78M
    case 'z':
1078
1.78M
      if (place == 'd')
1079
240k
  {
1080
240k
    val = fetch_arg (buffer, 'x', 6, info);
1081
240k
    if (val < 0)
1082
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1083
240k
    val = ((val & 7) << 3) + ((val >> 3) & 7);
1084
240k
  }
1085
1.54M
      else
1086
1.54M
  {
1087
1.54M
    val = fetch_arg (buffer, 's', 6, info);
1088
1.54M
    if (val < 0)
1089
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1090
1.54M
  }
1091
1092
      /* If the <ea> is invalid for *d, then reject this match.  */
1093
1.78M
      if (!m68k_valid_ea (*d, val))
1094
268k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1095
1096
      /* Get register number assuming address register.  */
1097
1.52M
      regno = (val & 7) + 8;
1098
1.52M
      regname = reg_names[regno];
1099
1.52M
      switch (val >> 3)
1100
1.52M
  {
1101
725k
  case 0:
1102
725k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1103
725k
          "%s", reg_names[val]);
1104
725k
    break;
1105
1106
38.2k
  case 1:
1107
38.2k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1108
38.2k
          "%s", regname);
1109
38.2k
    break;
1110
1111
116k
  case 2:
1112
116k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1113
116k
          "%s", regname);
1114
116k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
1115
116k
    break;
1116
1117
168k
  case 3:
1118
168k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1119
168k
          "%s", regname);
1120
168k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
1121
168k
    break;
1122
1123
174k
  case 4:
1124
174k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1125
174k
          "%s", regname);
1126
174k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
1127
174k
    break;
1128
1129
111k
  case 5:
1130
111k
    NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1131
111k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1132
111k
          "%s", regname);
1133
111k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1134
111k
    (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1135
111k
          "%d", val);
1136
111k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1137
111k
    break;
1138
1139
122k
  case 6:
1140
122k
    p = print_indexed (regno, p, addr, info);
1141
122k
    if (p == NULL)
1142
207
      return PRINT_INSN_ARG_MEMORY_ERROR;
1143
121k
    break;
1144
1145
121k
  case 7:
1146
63.5k
    switch (val & 7)
1147
63.5k
      {
1148
15.6k
      case 0:
1149
15.6k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1150
15.6k
        (*info->print_address_func) (val, info);
1151
15.6k
        break;
1152
1153
14.1k
      case 1:
1154
14.1k
        NEXTULONG (p, uval);
1155
14.1k
        (*info->print_address_func) (uval, info);
1156
14.1k
        break;
1157
1158
10.4k
      case 2:
1159
10.4k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1160
10.3k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
1161
10.3k
              "%%pc");
1162
10.3k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1163
10.3k
        (*info->print_address_func) (addr + val, info);
1164
10.3k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1165
10.3k
        break;
1166
1167
8.66k
      case 3:
1168
8.66k
        p = print_indexed (-1, p, addr, info);
1169
8.66k
        if (p == NULL)
1170
23
    return PRINT_INSN_ARG_MEMORY_ERROR;
1171
8.64k
        break;
1172
1173
14.6k
      case 4:
1174
14.6k
        flt_p = 1;  /* Assume it's a float... */
1175
14.6k
        switch (place)
1176
14.6k
        {
1177
2.97k
    case 'b':
1178
2.97k
      NEXTBYTE (p, val);
1179
2.97k
      flt_p = 0;
1180
2.97k
      break;
1181
1182
6.66k
    case 'w':
1183
6.66k
      NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1184
6.64k
      flt_p = 0;
1185
6.64k
      break;
1186
1187
2.08k
    case 'l':
1188
2.08k
      NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1189
2.06k
      flt_p = 0;
1190
2.06k
      break;
1191
1192
270
    case 'f':
1193
270
      NEXTSINGLE (flval, p);
1194
270
      break;
1195
1196
1.06k
    case 'F':
1197
1.06k
      NEXTDOUBLE (flval, p);
1198
1.06k
      break;
1199
1200
1.06k
    case 'x':
1201
581
      NEXTEXTEND (flval, p);
1202
580
      break;
1203
1204
986
    case 'p':
1205
986
      NEXTPACKED (p, flval);
1206
978
      break;
1207
1208
978
    default:
1209
0
      return PRINT_INSN_ARG_INVALID_OPERAND;
1210
14.6k
        }
1211
14.5k
        if (flt_p)  /* Print a float? */
1212
2.88k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1213
2.88k
                "#0e%g", flval);
1214
11.6k
        else
1215
11.6k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1216
11.6k
                "#%d", val);
1217
14.5k
        break;
1218
1219
0
      default:
1220
0
        return PRINT_INSN_ARG_INVALID_OPERAND;
1221
63.5k
      }
1222
1.52M
  }
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.51M
      if (place == '/')
1228
9.74k
  {
1229
9.74k
    FETCH_ARG (1, val);
1230
9.74k
    if (val)
1231
8.00k
      info->fprintf_styled_func (info->stream, dis_style_text, "&");
1232
9.74k
  }
1233
1.51M
      break;
1234
1235
1.51M
    case 'L':
1236
6.28k
    case 'l':
1237
6.28k
  if (place == 'w')
1238
4.39k
    {
1239
4.39k
      char doneany;
1240
4.39k
      p1 = buffer + 2;
1241
4.39k
      NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
1242
      /* Move the pointer ahead if this point is farther ahead
1243
         than the last.  */
1244
4.39k
      p = p1 > p ? p1 : p;
1245
4.39k
      if (val == 0)
1246
252
        {
1247
252
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1248
252
                "#0");
1249
252
    break;
1250
252
        }
1251
4.14k
      if (*d == 'l')
1252
1.35k
        {
1253
1.35k
    int newval = 0;
1254
1255
23.0k
    for (regno = 0; regno < 16; ++regno)
1256
21.6k
      if (val & (0x8000 >> regno))
1257
7.27k
        newval |= 1 << regno;
1258
1.35k
    val = newval;
1259
1.35k
        }
1260
4.14k
      val &= 0xffff;
1261
4.14k
      doneany = 0;
1262
56.1k
      for (regno = 0; regno < 16; ++regno)
1263
51.9k
        if (val & (1 << regno))
1264
13.3k
    {
1265
13.3k
      int first_regno;
1266
1267
13.3k
      if (doneany)
1268
9.21k
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1269
9.21k
              "/");
1270
13.3k
      doneany = 1;
1271
13.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1272
13.3k
            "%s", reg_names[regno]);
1273
13.3k
      first_regno = regno;
1274
27.7k
      while (val & (1 << (regno + 1)))
1275
14.3k
        ++regno;
1276
13.3k
      if (regno > first_regno)
1277
6.27k
        {
1278
6.27k
          (*info->fprintf_styled_func) (info->stream,
1279
6.27k
                dis_style_text, "-");
1280
6.27k
          (*info->fprintf_styled_func) (info->stream,
1281
6.27k
                dis_style_register, "%s",
1282
6.27k
                reg_names[regno]);
1283
6.27k
        }
1284
13.3k
    }
1285
4.14k
    }
1286
1.89k
  else if (place == '3')
1287
1.15k
    {
1288
      /* `fmovem' insn.  */
1289
1.15k
      char doneany;
1290
1291
1.15k
      FETCH_ARG (8, val);
1292
1.15k
      if (val == 0)
1293
82
        {
1294
82
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1295
82
                "#0");
1296
82
    break;
1297
82
        }
1298
1.06k
      if (*d == 'l')
1299
994
        {
1300
994
    int newval = 0;
1301
1302
8.94k
    for (regno = 0; regno < 8; ++regno)
1303
7.95k
      if (val & (0x80 >> regno))
1304
4.96k
        newval |= 1 << regno;
1305
994
    val = newval;
1306
994
        }
1307
1.06k
      val &= 0xff;
1308
1.06k
      doneany = 0;
1309
6.43k
      for (regno = 0; regno < 8; ++regno)
1310
5.36k
        if (val & (1 << regno))
1311
2.00k
    {
1312
2.00k
      int first_regno;
1313
2.00k
      if (doneany)
1314
932
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1315
932
              "/");
1316
2.00k
      doneany = 1;
1317
2.00k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1318
2.00k
            "%%fp%d", regno);
1319
2.00k
      first_regno = regno;
1320
5.18k
      while (val & (1 << (regno + 1)))
1321
3.18k
        ++regno;
1322
2.00k
      if (regno > first_regno)
1323
580
        {
1324
580
          (*info->fprintf_styled_func) (info->stream,
1325
580
                dis_style_text, "-");
1326
580
          (*info->fprintf_styled_func) (info->stream,
1327
580
                dis_style_register,
1328
580
                "%%fp%d", regno);
1329
580
        }
1330
2.00k
    }
1331
1.06k
    }
1332
741
  else if (place == '8')
1333
741
    {
1334
741
      FETCH_ARG (3, val);
1335
      /* fmoveml for FP status registers.  */
1336
741
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1337
741
            "%s", fpcr_names[val]);
1338
741
    }
1339
0
  else
1340
0
    return PRINT_INSN_ARG_INVALID_OP_TABLE;
1341
5.95k
      break;
1342
1343
5.95k
    case 'X':
1344
1.06k
      place = '8';
1345
      /* Fall through.  */
1346
1.35k
    case 'Y':
1347
1.42k
    case 'Z':
1348
2.46k
    case 'W':
1349
2.82k
    case '0':
1350
3.31k
    case '1':
1351
5.31k
    case '2':
1352
5.97k
    case '3':
1353
5.97k
      {
1354
5.97k
  char *name = 0;
1355
1356
5.97k
  FETCH_ARG (5, val);
1357
5.97k
  switch (val)
1358
5.97k
    {
1359
506
    case 2: name = "%tt0"; break;
1360
159
    case 3: name = "%tt1"; break;
1361
265
    case 0x10: name = "%tc"; break;
1362
262
    case 0x11: name = "%drp"; break;
1363
634
    case 0x12: name = "%srp"; break;
1364
330
    case 0x13: name = "%crp"; break;
1365
362
    case 0x14: name = "%cal"; break;
1366
526
    case 0x15: name = "%val"; break;
1367
34
    case 0x16: name = "%scc"; break;
1368
1.47k
    case 0x17: name = "%ac"; break;
1369
380
    case 0x18: name = "%psr"; break;
1370
152
    case 0x19: name = "%pcsr"; break;
1371
154
    case 0x1c:
1372
647
    case 0x1d:
1373
647
      {
1374
647
        int break_reg = ((buffer[3] >> 2) & 7);
1375
1376
647
        (*info->fprintf_styled_func)
1377
647
    (info->stream, dis_style_register,
1378
647
     val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
1379
647
      }
1380
647
      break;
1381
250
    default:
1382
250
      (*info->fprintf_styled_func) (info->stream, dis_style_text,
1383
250
            "<mmu register %d>", val);
1384
5.97k
    }
1385
5.97k
  if (name)
1386
5.08k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1387
5.08k
          "%s", name);
1388
5.97k
      }
1389
0
      break;
1390
1391
277
    case 'f':
1392
277
      {
1393
277
  int fc;
1394
1395
277
  FETCH_ARG (5, fc);
1396
277
  if (fc == 1)
1397
96
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1398
96
          "%%dfc");
1399
181
  else if (fc == 0)
1400
181
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1401
181
          "%%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
277
      }
1407
0
      break;
1408
1409
55
    case 'V':
1410
55
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
1411
55
      break;
1412
1413
3.34k
    case 't':
1414
3.34k
      {
1415
3.34k
  int level;
1416
1417
3.34k
  FETCH_ARG (3, level);
1418
3.34k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1419
3.34k
              "%d", level);
1420
3.34k
      }
1421
0
      break;
1422
1423
24.5k
    case 'u':
1424
24.5k
      {
1425
24.5k
  short is_upper = 0;
1426
24.5k
  int reg;
1427
1428
24.5k
  FETCH_ARG (5, reg);
1429
24.5k
  if (reg & 0x10)
1430
8.11k
    {
1431
8.11k
      is_upper = 1;
1432
8.11k
      reg &= 0xf;
1433
8.11k
    }
1434
24.5k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
1435
24.5k
              reg_half_names[reg],
1436
24.5k
              is_upper ? "u" : "l");
1437
24.5k
      }
1438
0
      break;
1439
1440
0
    default:
1441
0
      return PRINT_INSN_ARG_INVALID_OP_TABLE;
1442
3.55M
    }
1443
1444
3.28M
  return p - p0;
1445
3.55M
}
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
804k
{
1452
  /* All branches have an operand in 'B' format (the 'B' place only comes
1453
     with the 'B' format).  */
1454
804k
  if (strchr (opc->args, 'B') == NULL)
1455
733k
    return dis_nonbranch;
1456
1457
  /* Most branches are conditional branches, detect the ones that aren't
1458
     from the opcode name.  */
1459
70.7k
  if (strncmp (opc->name, "bra", 3) == 0)
1460
4.65k
    return dis_branch;
1461
1462
66.0k
  if (strncmp (opc->name, "bsr", 3) == 0)
1463
5.75k
    return dis_jsr;
1464
1465
60.3k
  return dis_condbranch;
1466
66.0k
}
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
1.08M
{
1477
1.08M
  unsigned char *save_p;
1478
1.08M
  unsigned char *p;
1479
1.08M
  const char *d;
1480
1.08M
  const char *args = best->args;
1481
1482
1.08M
  struct private *priv = (struct private *) info->private_data;
1483
1.08M
  bfd_byte *buffer = priv->the_buffer;
1484
1.08M
  fprintf_styled_ftype save_printer = info->fprintf_styled_func;
1485
1.08M
  void (* save_print_address) (bfd_vma, struct disassemble_info *)
1486
1.08M
    = info->print_address_func;
1487
1488
1.08M
  if (*args == '.')
1489
27.2k
    args++;
1490
1491
  /* Point at first word of argument data,
1492
     and at descriptor for first argument.  */
1493
1.08M
  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
3.23M
  for (d = args; *d; d += 2)
1500
2.15M
    {
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
2.15M
      if (d[0] == '#')
1504
286k
  {
1505
286k
    if (d[1] == 'l' && p - buffer < 6)
1506
16.3k
      p = buffer + 6;
1507
270k
    else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8')
1508
269k
      p = buffer + 4;
1509
286k
  }
1510
1511
2.15M
      if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
1512
4.17k
  p = buffer + 4;
1513
1514
2.15M
      switch (d[1])
1515
2.15M
  {
1516
33.7k
  case '1':
1517
35.5k
  case '2':
1518
68.6k
  case '3':
1519
71.6k
  case '7':
1520
78.3k
  case '8':
1521
78.9k
  case '9':
1522
86.2k
  case 'i':
1523
86.2k
    if (p - buffer < 4)
1524
47.5k
      p = buffer + 4;
1525
86.2k
    break;
1526
277
  case '4':
1527
554
  case '5':
1528
831
  case '6':
1529
831
    if (p - buffer < 6)
1530
277
      p = buffer + 6;
1531
831
    break;
1532
2.06M
  default:
1533
2.06M
    break;
1534
2.15M
  }
1535
2.15M
    }
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
1.08M
  if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
1540
14.8k
    p = buffer + 4;
1541
1542
  /* lpstop is another exception.  It takes a one word argument but is
1543
     three words long.  */
1544
1.08M
  if (p - buffer < 6
1545
1.06M
      && (best->match & 0xffff) == 0xffff
1546
2.74k
      && args[0] == '#'
1547
75
      && args[1] == 'w')
1548
75
    {
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
75
      p = buffer + 6;
1554
75
      if (!FETCH_DATA (info, p))
1555
2
  return -1;
1556
73
      buffer[2] = buffer[4];
1557
73
      buffer[3] = buffer[5];
1558
73
    }
1559
1560
1.08M
  if (!FETCH_DATA (info, p))
1561
329
    return -1;
1562
1563
1.08M
  save_p = p;
1564
1.08M
  info->print_address_func = dummy_print_address;
1565
1.08M
  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.79M
  for (d = args; *d; d += 2)
1570
1.99M
    {
1571
1.99M
      int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1572
1573
1.99M
      if (eaten >= 0)
1574
1.71M
  p += eaten;
1575
275k
      else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
1576
557
         || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
1577
275k
  {
1578
275k
    info->fprintf_styled_func = save_printer;
1579
275k
    info->print_address_func = save_print_address;
1580
275k
    return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
1581
275k
  }
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.99M
    }
1595
1596
804k
  p = save_p;
1597
804k
  info->fprintf_styled_func = save_printer;
1598
804k
  info->print_address_func = save_print_address;
1599
804k
  info->insn_type = m68k_opcode_to_insn_type (best);
1600
1601
804k
  d = args;
1602
1603
804k
  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
1604
1605
804k
  if (*d)
1606
804k
    info->fprintf_styled_func (info->stream, dis_style_text, " ");
1607
1608
2.37M
  while (*d)
1609
1.56M
    {
1610
1.56M
      p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1611
1.56M
      d += 2;
1612
1613
1.56M
      if (*d && *(d - 2) != 'I' && *d != 'k')
1614
760k
  info->fprintf_styled_func (info->stream, dis_style_text, ",");
1615
1.56M
    }
1616
1617
804k
  return p - buffer;
1618
1.08M
}
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.35M
{
1630
1.35M
  int i;
1631
1.35M
  const char *d;
1632
1.35M
  static const struct m68k_opcode **opcodes[16];
1633
1.35M
  static int numopcodes[16];
1634
1.35M
  int val;
1635
1.35M
  int major_opcode;
1636
1637
1.35M
  struct private *priv = (struct private *) info->private_data;
1638
1.35M
  bfd_byte *buffer = priv->the_buffer;
1639
1640
1.35M
  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.35M
  if (!FETCH_DATA (info, buffer + 2))
1667
945
    return -1;
1668
1.35M
  major_opcode = (buffer[0] >> 4) & 15;
1669
1670
315M
  for (i = 0; i < numopcodes[major_opcode]; i++)
1671
315M
    {
1672
315M
      const struct m68k_opcode *opc = opcodes[major_opcode][i];
1673
315M
      unsigned long opcode = opc->opcode;
1674
315M
      unsigned long match = opc->match;
1675
315M
      const char *args = opc->args;
1676
1677
315M
      if (*args == '.')
1678
3.53M
  args++;
1679
1680
315M
      if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
1681
73.0M
    && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
1682
    /* Only fetch the next two bytes if we need to.  */
1683
18.8M
    && (((0xffff & match) == 0)
1684
17.4M
        ||
1685
17.4M
        (FETCH_DATA (info, buffer + 4)
1686
17.3M
         && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
1687
1.25M
         && ((0xff & buffer[3] & match) == (0xff & opcode)))
1688
18.8M
        )
1689
1.56M
    && (opc->arch & arch_mask) != 0)
1690
1.11M
  {
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
3.33M
    for (d = args; *d; d += 2)
1695
2.22M
      if (d[1] == 'D')
1696
496
        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
1.11M
    if (*d == '\0')
1702
3.33M
      for (d = args; *d; d += 2)
1703
2.22M
        if (d[1] == 't')
1704
706
    break;
1705
1706
    /* Don't match fmovel with more than one register;
1707
       wait for fmoveml.  */
1708
1.11M
    if (*d == '\0')
1709
1.11M
      {
1710
3.33M
        for (d = args; *d; d += 2)
1711
2.22M
    {
1712
2.22M
      if (d[0] == 's' && d[1] == '8')
1713
1.49k
        {
1714
1.49k
          val = fetch_arg (buffer, d[1], 3, info);
1715
1.49k
          if (val < 0)
1716
0
      return 0;
1717
1.49k
          if ((val & (val - 1)) != 0)
1718
454
      break;
1719
1.49k
        }
1720
2.22M
    }
1721
1.11M
      }
1722
1723
    /* Don't match FPU insns with non-default coprocessor ID.  */
1724
1.11M
    if (*d == '\0')
1725
1.11M
      {
1726
3.26M
        for (d = args; *d; d += 2)
1727
2.18M
    {
1728
2.18M
      if (d[0] == 'I')
1729
40.8k
        {
1730
40.8k
          val = fetch_arg (buffer, 'd', 3, info);
1731
40.8k
          if (val != 1)
1732
31.5k
      break;
1733
40.8k
        }
1734
2.18M
    }
1735
1.11M
      }
1736
1737
1.11M
    if (*d == '\0')
1738
1.08M
      if ((val = match_insn_m68k (memaddr, info, opc)))
1739
805k
        return val;
1740
1.11M
  }
1741
315M
    }
1742
552k
  return 0;
1743
1.35M
}
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
1.10M
{
1751
1.10M
  unsigned int arch_mask;
1752
1.10M
  struct private priv;
1753
1.10M
  int val;
1754
1755
1.10M
  bfd_byte *buffer = priv.the_buffer;
1756
1757
1.10M
  info->insn_info_valid = 1;
1758
1.10M
  info->private_data = & priv;
1759
  /* Tell objdump to use two bytes per chunk
1760
     and six bytes per line for displaying raw data.  */
1761
1.10M
  info->bytes_per_chunk = 2;
1762
1.10M
  info->bytes_per_line = 6;
1763
1.10M
  info->display_endian = BFD_ENDIAN_BIG;
1764
1.10M
  priv.max_fetched = priv.the_buffer;
1765
1.10M
  priv.insn_start = memaddr;
1766
1767
1.10M
  arch_mask = bfd_m68k_mach_to_features (info->mach);
1768
1.10M
  if (!arch_mask)
1769
938k
    {
1770
      /* First try printing an m680x0 instruction.  Try printing a Coldfire
1771
   one if that fails.  */
1772
938k
      val = m68k_scan_mask (memaddr, info, m68k_mask);
1773
938k
      if (val <= 0)
1774
255k
  val = m68k_scan_mask (memaddr, info, mcf_mask);
1775
938k
    }
1776
164k
  else
1777
164k
    {
1778
164k
      val = m68k_scan_mask (memaddr, info, arch_mask);
1779
164k
    }
1780
1781
1.10M
  if (val == 0)
1782
298k
    {
1783
      /* Handle undefined instructions.  */
1784
298k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
1785
298k
         ".short");
1786
298k
      info->fprintf_styled_func (info->stream, dis_style_text, " ");
1787
298k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
1788
298k
         "0x%04x", (buffer[0] << 8) + buffer[1]);
1789
1790
298k
      info->insn_type = dis_noninsn;
1791
298k
    }
1792
1793
1.10M
  return val ? val : 2;
1794
1.10M
}