Coverage Report

Created: 2026-05-11 07:54

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