Coverage Report

Created: 2023-06-29 07:13

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