Coverage Report

Created: 2026-07-12 09:22

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