Coverage Report

Created: 2023-08-28 06:31

/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
2.53M
#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
2.14M
  do            \
77
2.14M
    {           \
78
2.14M
      p += 2;         \
79
2.14M
      if (!FETCH_DATA (info, p))   \
80
2.14M
  return PRINT_INSN_ARG_MEMORY_ERROR; \
81
2.14M
      val = COERCE_SIGNED_CHAR (p[-1]);   \
82
2.14M
    }            \
83
2.14M
  while (0)
84
85
/* Get a 2 byte signed integer.  */
86
1.59M
#define COERCE16(x) ((int) (((x) ^ 0x8000) - 0x8000))
87
88
#define NEXTWORD(p, val, ret_val)   \
89
1.59M
  do            \
90
1.59M
    {           \
91
1.59M
      p += 2;         \
92
1.59M
      if (!FETCH_DATA (info, p))   \
93
1.59M
  return ret_val;       \
94
1.59M
      val = COERCE16 ((p[-2] << 8) + p[-1]);  \
95
1.59M
    }            \
96
1.59M
  while (0)
97
98
/* Get a 4 byte signed integer.  */
99
252k
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000)
100
101
#define NEXTLONG(p, val, ret_val)         \
102
252k
  do                  \
103
252k
    {                 \
104
252k
      p += 4;               \
105
252k
      if (!FETCH_DATA (info, p))         \
106
252k
  return ret_val;             \
107
252k
      val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8)  \
108
252k
      + p[-2]) << 8) + p[-1]);      \
109
252k
    }                  \
110
252k
  while (0)
111
112
/* Get a 4 byte unsigned integer.  */
113
#define NEXTULONG(p, val)           \
114
74.6k
  do                  \
115
74.6k
    {                 \
116
74.6k
      p += 4;               \
117
74.6k
      if (!FETCH_DATA (info, p))         \
118
74.6k
  return PRINT_INSN_ARG_MEMORY_ERROR;       \
119
74.6k
      val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8)     \
120
74.5k
         + p[-2]) << 8) + p[-1]);         \
121
74.5k
    }                  \
122
74.6k
  while (0)
123
124
/* Get a single precision float.  */
125
#define NEXTSINGLE(val, p)          \
126
397
  do                \
127
397
    {               \
128
397
      p += 4;             \
129
397
      if (!FETCH_DATA (info, p))       \
130
397
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
131
397
      floatformat_to_double (& floatformat_ieee_single_big, \
132
396
           (char *) p - 4, & val);    \
133
396
    }                \
134
397
  while (0)
135
136
/* Get a double precision float.  */
137
#define NEXTDOUBLE(val, p)          \
138
1.20k
  do                \
139
1.20k
    {               \
140
1.20k
      p += 8;             \
141
1.20k
      if (!FETCH_DATA (info, p))       \
142
1.20k
  return PRINT_INSN_ARG_MEMORY_ERROR;     \
143
1.20k
      floatformat_to_double (& floatformat_ieee_double_big, \
144
1.20k
           (char *) p - 8, & val);    \
145
1.20k
    }                \
146
1.20k
  while (0)
147
148
/* Get an extended precision float.  */
149
#define NEXTEXTEND(val, p)        \
150
1.00k
  do              \
151
1.00k
    {             \
152
1.00k
      p += 12;            \
153
1.00k
      if (!FETCH_DATA (info, p))     \
154
1.00k
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
155
1.00k
      floatformat_to_double (& floatformat_m68881_ext,  \
156
1.00k
           (char *) p - 12, & val); \
157
1.00k
    }              \
158
1.00k
  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
600
  do            \
166
600
    {           \
167
600
      p += 12;          \
168
600
      if (!FETCH_DATA (info, p))   \
169
600
  return PRINT_INSN_ARG_MEMORY_ERROR; \
170
600
      val = 0.0;        \
171
600
    }            \
172
600
  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
81.2M
  ((addr) <= ((struct private *) (info->private_data))->max_fetched \
191
81.2M
   ? 1 : fetch_data ((info), (addr)))
192
193
static int
194
fetch_data (struct disassemble_info *info, bfd_byte *addr)
195
6.26M
{
196
6.26M
  int status;
197
6.26M
  struct private *priv = (struct private *)info->private_data;
198
6.26M
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
199
200
6.26M
  status = (*info->read_memory_func) (start,
201
6.26M
              priv->max_fetched,
202
6.26M
              addr - priv->max_fetched,
203
6.26M
              info);
204
6.26M
  if (status != 0)
205
39.2k
    {
206
39.2k
      (*info->memory_error_func) (status, start, info);
207
39.2k
      return 0;
208
39.2k
    }
209
6.23M
  else
210
6.23M
    priv->max_fetched = addr;
211
6.23M
  return 1;
212
6.26M
}
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
10.0M
{
221
10.0M
  return 0;
222
10.0M
}
223
224
static void
225
dummy_print_address (bfd_vma vma ATTRIBUTE_UNUSED,
226
         struct disassemble_info *info ATTRIBUTE_UNUSED)
227
331k
{
228
331k
}
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
10.8M
{
242
10.8M
  int val = 0;
243
244
10.8M
  switch (code)
245
10.8M
    {
246
12.9k
    case '/': /* MAC/EMAC mask bit.  */
247
12.9k
      val = buffer[3] >> 5;
248
12.9k
      break;
249
250
2.31k
    case 'G': /* EMAC ACC load.  */
251
2.31k
      val = ((buffer[3] >> 3) & 0x2) | ((~buffer[1] >> 7) & 0x1);
252
2.31k
      break;
253
254
910
    case 'H': /* EMAC ACC !load.  */
255
910
      val = ((buffer[3] >> 3) & 0x2) | ((buffer[1] >> 7) & 0x1);
256
910
      break;
257
258
68
    case ']': /* EMAC ACCEXT bit.  */
259
68
      val = buffer[0] >> 2;
260
68
      break;
261
262
30.5k
    case 'I': /* MAC/EMAC scale factor.  */
263
30.5k
      val = buffer[2] >> 1;
264
30.5k
      break;
265
266
174
    case 'F': /* EMAC ACCx.  */
267
174
      val = buffer[0] >> 1;
268
174
      break;
269
270
54
    case 'f':
271
54
      val = buffer[1];
272
54
      break;
273
274
6.77M
    case 's':
275
6.77M
      val = buffer[1];
276
6.77M
      break;
277
278
2.66M
    case 'd':     /* Destination, for register or quick.  */
279
2.66M
      val = (buffer[0] << 8) + buffer[1];
280
2.66M
      val >>= 9;
281
2.66M
      break;
282
283
869k
    case 'x':     /* Destination, for general arg.  */
284
869k
      val = (buffer[0] << 8) + buffer[1];
285
869k
      val >>= 6;
286
869k
      break;
287
288
122
    case 'k':
289
122
      if (! FETCH_DATA (info, buffer + 3))
290
0
  return -1;
291
122
      val = (buffer[3] >> 4);
292
122
      break;
293
294
610
    case 'C':
295
610
      if (! FETCH_DATA (info, buffer + 3))
296
0
  return -1;
297
610
      val = buffer[3];
298
610
      break;
299
300
112k
    case '1':
301
112k
      if (! FETCH_DATA (info, buffer + 3))
302
0
  return -1;
303
112k
      val = (buffer[2] << 8) + buffer[3];
304
112k
      val >>= 12;
305
112k
      break;
306
307
5.57k
    case '2':
308
5.57k
      if (! FETCH_DATA (info, buffer + 3))
309
0
  return -1;
310
5.57k
      val = (buffer[2] << 8) + buffer[3];
311
5.57k
      val >>= 6;
312
5.57k
      break;
313
314
95.0k
    case '3':
315
97.7k
    case 'j':
316
97.7k
      if (! FETCH_DATA (info, buffer + 3))
317
0
  return -1;
318
97.7k
      val = (buffer[2] << 8) + buffer[3];
319
97.7k
      break;
320
321
130
    case '4':
322
130
      if (! FETCH_DATA (info, buffer + 5))
323
0
  return -1;
324
130
      val = (buffer[4] << 8) + buffer[5];
325
130
      val >>= 12;
326
130
      break;
327
328
130
    case '5':
329
130
      if (! FETCH_DATA (info, buffer + 5))
330
0
  return -1;
331
130
      val = (buffer[4] << 8) + buffer[5];
332
130
      val >>= 6;
333
130
      break;
334
335
130
    case '6':
336
130
      if (! FETCH_DATA (info, buffer + 5))
337
0
  return -1;
338
130
      val = (buffer[4] << 8) + buffer[5];
339
130
      break;
340
341
5.00k
    case '7':
342
5.00k
      if (! FETCH_DATA (info, buffer + 3))
343
0
  return -1;
344
5.00k
      val = (buffer[2] << 8) + buffer[3];
345
5.00k
      val >>= 7;
346
5.00k
      break;
347
348
11.2k
    case '8':
349
11.2k
      if (! FETCH_DATA (info, buffer + 3))
350
0
  return -1;
351
11.2k
      val = (buffer[2] << 8) + buffer[3];
352
11.2k
      val >>= 10;
353
11.2k
      break;
354
355
348
    case '9':
356
348
      if (! FETCH_DATA (info, buffer + 3))
357
0
  return -1;
358
348
      val = (buffer[2] << 8) + buffer[3];
359
348
      val >>= 5;
360
348
      break;
361
362
10.7k
    case 'e':
363
10.7k
      val = (buffer[1] >> 6);
364
10.7k
      break;
365
366
85.3k
    case 'E':
367
85.3k
      if (! FETCH_DATA (info, buffer + 3))
368
0
  return -1;
369
85.3k
      val = (buffer[2] >> 1);
370
85.3k
      break;
371
372
23.5k
    case 'm':
373
23.5k
      val = (buffer[1] & 0x40 ? 0x8 : 0)
374
23.5k
  | ((buffer[0] >> 1) & 0x7)
375
23.5k
  | (buffer[3] & 0x80 ? 0x10 : 0);
376
23.5k
      break;
377
378
12.9k
    case 'n':
379
12.9k
      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
380
12.9k
      break;
381
382
27.6k
    case 'o':
383
27.6k
      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
384
27.6k
      break;
385
386
23.5k
    case 'M':
387
23.5k
      val = (buffer[1] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
388
23.5k
      break;
389
390
27.6k
    case 'N':
391
27.6k
      val = (buffer[3] & 0xf) | (buffer[3] & 0x40 ? 0x10 : 0);
392
27.6k
      break;
393
394
3.60k
    case 'h':
395
3.60k
      val = buffer[2] >> 2;
396
3.60k
      break;
397
398
0
    default:
399
0
      abort ();
400
10.8M
    }
401
402
  /* bits is never too big.  */
403
10.8M
  return val & ((1 << bits) - 1);
404
10.8M
}
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
6.99M
{
416
6.99M
  int mode, mask;
417
6.99M
#define M(n0,n1,n2,n3,n4,n5,n6,n70,n71,n72,n73,n74) \
418
6.99M
  (n0 | n1 << 1 | n2 << 2 | n3 << 3 | n4 << 4 | n5 << 5 | n6 << 6 \
419
6.99M
   | n70 << 7 | n71 << 8 | n72 << 9 | n73 << 10 | n74 << 11)
420
421
6.99M
  switch (code)
422
6.99M
    {
423
1.14M
    case '*':
424
1.14M
      mask = M (1,1,1,1,1,1,1,1,1,1,1,1);
425
1.14M
      break;
426
331k
    case '~':
427
331k
      mask = M (0,0,1,1,1,1,1,1,1,0,0,0);
428
331k
      break;
429
730k
    case '%':
430
730k
      mask = M (1,1,1,1,1,1,1,1,1,0,0,0);
431
730k
      break;
432
1.12M
    case ';':
433
1.12M
      mask = M (1,0,1,1,1,1,1,1,1,1,1,1);
434
1.12M
      break;
435
17.8k
    case '@':
436
17.8k
      mask = M (1,0,1,1,1,1,1,1,1,1,1,0);
437
17.8k
      break;
438
53.0k
    case '!':
439
53.0k
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
440
53.0k
      break;
441
14.2k
    case '&':
442
14.2k
      mask = M (0,0,1,0,0,1,1,1,1,0,0,0);
443
14.2k
      break;
444
3.17M
    case '$':
445
3.17M
      mask = M (1,0,1,1,1,1,1,1,1,0,0,0);
446
3.17M
      break;
447
2.58k
    case '?':
448
2.58k
      mask = M (1,0,1,0,0,1,1,1,1,0,0,0);
449
2.58k
      break;
450
4.32k
    case '/':
451
4.32k
      mask = M (1,0,1,0,0,1,1,1,1,1,1,0);
452
4.32k
      break;
453
206
    case '|':
454
206
      mask = M (0,0,1,0,0,1,1,1,1,1,1,0);
455
206
      break;
456
14.8k
    case '>':
457
14.8k
      mask = M (0,0,1,0,1,1,1,1,1,0,0,0);
458
14.8k
      break;
459
16.1k
    case '<':
460
16.1k
      mask = M (0,0,1,1,0,1,1,1,1,1,1,0);
461
16.1k
      break;
462
61.6k
    case 'm':
463
61.6k
      mask = M (1,1,1,1,1,0,0,0,0,0,0,0);
464
61.6k
      break;
465
93.5k
    case 'n':
466
93.5k
      mask = M (0,0,0,0,0,1,0,0,0,1,0,0);
467
93.5k
      break;
468
58.9k
    case 'o':
469
58.9k
      mask = M (0,0,0,0,0,0,1,1,1,0,1,1);
470
58.9k
      break;
471
103k
    case 'p':
472
103k
      mask = M (1,1,1,1,1,1,0,0,0,0,0,0);
473
103k
      break;
474
9.60k
    case 'q':
475
9.60k
      mask = M (1,0,1,1,1,1,0,0,0,0,0,0);
476
9.60k
      break;
477
6.27k
    case 'v':
478
6.27k
      mask = M (1,0,1,1,1,1,0,1,1,0,0,0);
479
6.27k
      break;
480
160
    case 'b':
481
160
      mask = M (1,0,1,1,1,1,0,0,0,1,0,0);
482
160
      break;
483
13
    case 'w':
484
13
      mask = M (0,0,1,1,1,1,0,0,0,1,0,0);
485
13
      break;
486
3.69k
    case 'y':
487
3.69k
      mask = M (0,0,1,0,0,1,0,0,0,0,0,0);
488
3.69k
      break;
489
101
    case 'z':
490
101
      mask = M (0,0,1,0,0,1,0,0,0,1,0,0);
491
101
      break;
492
18.9k
    case '4':
493
18.9k
      mask = M (0,0,1,1,1,1,0,0,0,0,0,0);
494
18.9k
      break;
495
0
    default:
496
0
      abort ();
497
6.99M
    }
498
6.99M
#undef M
499
500
6.99M
  mode = (val >> 3) & 7;
501
6.99M
  if (mode == 7)
502
587k
    mode += val & 7;
503
6.99M
  return (mask & (1 << mode)) != 0;
504
6.99M
}
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
510k
{
512
510k
  if (regno == -1)
513
20.4k
    {
514
20.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%pc");
515
20.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
516
20.4k
      (*info->print_address_func) (disp, info);
517
20.4k
    }
518
489k
  else
519
489k
    {
520
489k
      if (regno == -3)
521
5.29k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
522
5.29k
              "%%zpc");
523
484k
      else if (regno != -2)
524
393k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
525
393k
              "%s", reg_names[regno]);
526
489k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
527
489k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
528
489k
            "%" PRIx64, (uint64_t) disp);
529
489k
    }
530
510k
}
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
404k
{
538
404k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
539
404k
        "%s", reg_names[(ext >> 12) & 0xf]);
540
404k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
541
404k
        ":%c", ext & 0x800 ? 'l' : 'w');
542
404k
  if ((ext >> 9) & 3)
543
257k
    {
544
257k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ":");
545
257k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
546
257k
            "%d", 1 << ((ext >> 9) & 3));
547
257k
    }
548
404k
}
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
510k
{
561
510k
  int word;
562
510k
  bfd_vma base_disp;
563
510k
  bfd_vma outer_disp;
564
510k
  bool print_index = true;
565
566
510k
  NEXTWORD (p, word, NULL);
567
568
  /* Handle the 68000 style of indexing.  */
569
570
510k
  if ((word & 0x100) == 0)
571
291k
    {
572
291k
      base_disp = word & 0xff;
573
291k
      if ((base_disp & 0x80) != 0)
574
97.0k
  base_disp -= 0x100;
575
291k
      if (basereg == -1)
576
12.4k
  base_disp += addr;
577
291k
      print_base (basereg, base_disp, info);
578
291k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
579
291k
      print_index_register (word, info);
580
291k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
581
291k
      return p;
582
291k
    }
583
584
  /* Handle the generalized kind.  */
585
  /* First, compute the displacement to add to the base register.  */
586
219k
  if (word & 0200)
587
96.7k
    {
588
96.7k
      if (basereg == -1)
589
5.29k
  basereg = -3;
590
91.4k
      else
591
91.4k
  basereg = -2;
592
96.7k
    }
593
219k
  if (word & 0100)
594
105k
    print_index = false;
595
219k
  base_disp = 0;
596
219k
  switch ((word >> 4) & 3)
597
219k
    {
598
59.5k
    case 2:
599
59.5k
      NEXTWORD (p, base_disp, NULL);
600
59.5k
      break;
601
59.5k
    case 3:
602
56.6k
      NEXTLONG (p, base_disp, NULL);
603
219k
    }
604
219k
  if (basereg == -1)
605
8.08k
    base_disp += addr;
606
607
  /* Handle single-level case (not indirect).  */
608
219k
  if ((word & 7) == 0)
609
34.0k
    {
610
34.0k
      print_base (basereg, base_disp, info);
611
34.0k
      if (print_index)
612
22.6k
  {
613
22.6k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
614
22.6k
    print_index_register (word, info);
615
22.6k
  }
616
34.0k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
617
34.0k
      return p;
618
34.0k
    }
619
620
  /* Two level.  Compute displacement to add after indirection.  */
621
185k
  outer_disp = 0;
622
185k
  switch (word & 3)
623
185k
    {
624
56.1k
    case 2:
625
56.1k
      NEXTWORD (p, outer_disp, NULL);
626
56.1k
      break;
627
56.1k
    case 3:
628
52.6k
      NEXTLONG (p, outer_disp, NULL);
629
185k
    }
630
631
184k
  print_base (basereg, base_disp, info);
632
184k
  if ((word & 4) == 0 && print_index)
633
39.3k
    {
634
39.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
635
39.3k
      print_index_register (word, info);
636
39.3k
      print_index = false;
637
39.3k
    }
638
184k
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
639
184k
        ")@(");
640
184k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
641
184k
        "%" PRIx64, (uint64_t) outer_disp);
642
184k
  if (print_index)
643
51.1k
    {
644
51.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, ",");
645
51.1k
      print_index_register (word, info);
646
51.1k
    }
647
184k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
648
649
184k
  return p;
650
185k
}
651
652
#define FETCH_ARG(size, val)        \
653
3.70M
  do              \
654
3.70M
    {             \
655
3.70M
      val = fetch_arg (buffer, place, size, info);  \
656
3.70M
      if (val < 0)         \
657
3.70M
  return PRINT_INSN_ARG_MEMORY_ERROR;   \
658
3.70M
    }             \
659
3.70M
  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
13.7M
{
672
13.7M
  int val = 0;
673
13.7M
  int place = d[1];
674
13.7M
  unsigned char *p = p0;
675
13.7M
  int regno;
676
13.7M
  const char *regname;
677
13.7M
  unsigned char *p1;
678
13.7M
  double flval;
679
13.7M
  int flt_p;
680
13.7M
  bfd_signed_vma disp;
681
13.7M
  unsigned int uval;
682
683
13.7M
  switch (*d)
684
13.7M
    {
685
10.7k
    case 'c':   /* Cache identifier.  */
686
10.7k
      {
687
10.7k
        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
688
10.7k
        FETCH_ARG (2, val);
689
10.7k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
690
10.7k
              "%s", cacheFieldName[val]);
691
10.7k
        break;
692
10.7k
      }
693
694
15.7k
    case 'a':   /* Address register indirect only. Cf. case '+'.  */
695
15.7k
      {
696
15.7k
  FETCH_ARG (3, val);
697
15.7k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s",
698
15.7k
              reg_names[val + 8]);
699
15.7k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
700
15.7k
        break;
701
15.7k
      }
702
703
3.13k
    case '_':   /* 32-bit absolute address for move16.  */
704
3.13k
      {
705
3.13k
        NEXTULONG (p, uval);
706
3.13k
  (*info->print_address_func) (uval, info);
707
3.13k
        break;
708
3.13k
      }
709
710
8.14k
    case 'C':
711
8.14k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%ccr");
712
8.14k
      break;
713
714
8.76k
    case 'S':
715
8.76k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%sr");
716
8.76k
      break;
717
718
552
    case 'U':
719
552
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%usp");
720
552
      break;
721
722
1.16k
    case 'E':
723
1.16k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%acc");
724
1.16k
      break;
725
726
2.45k
    case 'G':
727
2.45k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%macsr");
728
2.45k
      break;
729
730
3.75k
    case 'H':
731
3.75k
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%mask");
732
3.75k
      break;
733
734
2.64k
    case 'J':
735
2.64k
      {
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.64k
  struct regname { char * name; int value; };
740
2.64k
  static const struct regname names[] =
741
2.64k
    {
742
2.64k
      {"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
743
2.64k
      {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
744
2.64k
      {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
745
2.64k
      {"%rgpiobar", 0x009}, {"%acr4",0x00c},
746
2.64k
      {"%acr5",0x00d}, {"%acr6",0x00e}, {"%acr7", 0x00f},
747
2.64k
      {"%usp", 0x800}, {"%vbr", 0x801}, {"%caar", 0x802},
748
2.64k
      {"%msp", 0x803}, {"%isp", 0x804},
749
2.64k
      {"%pc", 0x80f},
750
      /* Reg c04 is sometimes called flashbar or rambar.
751
         Reg c05 is also sometimes called rambar.  */
752
2.64k
      {"%rambar0", 0xc04}, {"%rambar1", 0xc05},
753
754
      /* reg c0e is sometimes called mbar2 or secmbar.
755
         reg c0f is sometimes called mbar.  */
756
2.64k
      {"%mbar0", 0xc0e}, {"%mbar1", 0xc0f},
757
758
      /* Should we be calling this psr like we do in case 'Y'?  */
759
2.64k
      {"%mmusr",0x805},
760
761
2.64k
      {"%urp", 0x806}, {"%srp", 0x807}, {"%pcr", 0x808},
762
763
      /* Fido added these.  */
764
2.64k
      {"%cac", 0xffe}, {"%mbo", 0xfff}
765
2.64k
  };
766
  /* Alternate names for v4e (MCF5407/5445x/MCF547x/MCF548x), at least.  */
767
2.64k
  static const struct regname names_v4e[] =
768
2.64k
    {
769
2.64k
      {"%asid",0x003}, {"%acr0",0x004}, {"%acr1",0x005},
770
2.64k
      {"%acr2",0x006}, {"%acr3",0x007}, {"%mmubar",0x008},
771
2.64k
    };
772
2.64k
  unsigned int arch_mask;
773
774
2.64k
  arch_mask = bfd_m68k_mach_to_features (info->mach);
775
2.64k
  FETCH_ARG (12, val);
776
2.64k
  if (arch_mask & (mcfisa_b | mcfisa_c))
777
376
    {
778
2.62k
      for (regno = ARRAY_SIZE (names_v4e); --regno >= 0;)
779
2.25k
        if (names_v4e[regno].value == val)
780
8
    {
781
8
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
782
8
                 "%s", names_v4e[regno].name);
783
8
      break;
784
8
    }
785
376
      if (regno >= 0)
786
8
        break;
787
376
    }
788
80.0k
  for (regno = ARRAY_SIZE (names) - 1; regno >= 0; regno--)
789
78.5k
    if (names[regno].value == val)
790
1.10k
      {
791
1.10k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
792
1.10k
              "%s", names[regno].name);
793
1.10k
        break;
794
1.10k
      }
795
2.63k
  if (regno < 0)
796
1.52k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "0x%x", val);
797
2.63k
      }
798
0
      break;
799
800
370k
    case 'Q':
801
370k
      FETCH_ARG (3, val);
802
      /* 0 means 8, except for the bkpt instruction... */
803
370k
      if (val == 0 && d[1] != 's')
804
47.3k
  val = 8;
805
370k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
806
370k
            "#%d", val);
807
370k
      break;
808
809
21.4k
    case 'x':
810
21.4k
      FETCH_ARG (3, val);
811
      /* 0 means -1.  */
812
21.4k
      if (val == 0)
813
2.23k
  val = -1;
814
21.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
815
21.4k
            "#%d", val);
816
21.4k
      break;
817
818
85.3k
    case 'j':
819
85.3k
      FETCH_ARG (3, val);
820
85.3k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
821
85.3k
            "#%d", val+1);
822
85.3k
      break;
823
824
85.0k
    case 'K':
825
85.0k
      FETCH_ARG (9, val);
826
85.0k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
827
85.0k
            "#%d", val);
828
85.0k
      break;
829
830
197k
    case 'M':
831
197k
      if (place == 'h')
832
3.60k
  {
833
3.60k
    static char *const scalefactor_name[] = { "<<", ">>" };
834
835
3.60k
    FETCH_ARG (1, val);
836
3.60k
    (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
837
3.60k
          "%s", scalefactor_name[val]);
838
3.60k
  }
839
194k
      else
840
194k
  {
841
194k
    FETCH_ARG (8, val);
842
194k
    if (val & 0x80)
843
54.8k
      val = val - 0x100;
844
194k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
845
194k
          "#%d", val);
846
194k
  }
847
197k
      break;
848
849
197k
    case 'T':
850
3.92k
      FETCH_ARG (4, val);
851
3.92k
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
852
3.92k
            "#%d", val);
853
3.92k
      break;
854
855
2.17M
    case 'D':
856
2.17M
      FETCH_ARG (3, val);
857
2.17M
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
858
2.17M
            "%s", reg_names[val]);
859
2.17M
      break;
860
861
277k
    case 'A':
862
277k
      FETCH_ARG (3, val);
863
277k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
864
277k
            "%s", reg_names[val + 010]);
865
277k
      break;
866
867
170k
    case 'R':
868
170k
      FETCH_ARG (4, val);
869
170k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
870
170k
            "%s", reg_names[val]);
871
170k
      break;
872
873
260
    case 'r':
874
260
      FETCH_ARG (4, regno);
875
260
      if (regno > 7)
876
52
  {
877
52
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
878
52
          "%s", reg_names[regno]);
879
52
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
880
52
  }
881
208
      else
882
208
  {
883
208
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
884
208
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
885
208
          "%s", reg_names[regno]);
886
208
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
887
208
  }
888
260
      break;
889
890
5.83k
    case 'F':
891
5.83k
      FETCH_ARG (3, val);
892
5.83k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
893
5.83k
            "%%fp%d", val);
894
5.83k
      break;
895
896
10.4k
    case 'O':
897
10.4k
      FETCH_ARG (6, val);
898
10.4k
      if (val & 0x20)
899
3.43k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
900
3.43k
              "%s", reg_names[val & 7]);
901
7.04k
      else
902
7.04k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
903
7.04k
              "%d", val);
904
10.4k
      break;
905
906
27.4k
    case '+':
907
27.4k
      FETCH_ARG (3, val);
908
27.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
909
27.4k
            "%s", reg_names[val + 8]);
910
27.4k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
911
27.4k
      break;
912
913
92.8k
    case '-':
914
92.8k
      FETCH_ARG (3, val);
915
92.8k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
916
92.8k
            "%s", reg_names[val + 8]);
917
92.8k
      (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
918
92.8k
      break;
919
920
608
    case 'k':
921
608
      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
608
      else if (place == 'C')
930
608
  {
931
608
    FETCH_ARG (7, val);
932
608
    if (val > 63)    /* This is a signed constant.  */
933
506
      val -= 128;
934
608
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "{");
935
608
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
936
608
          "#%d", val);
937
608
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "}");
938
608
  }
939
0
      else
940
0
  return PRINT_INSN_ARG_INVALID_OPERAND;
941
608
      break;
942
943
2.49M
    case '#':
944
2.49M
    case '^':
945
2.49M
      p1 = buffer + (*d == '#' ? 2 : 4);
946
2.49M
      if (place == 's')
947
0
  FETCH_ARG (4, val);
948
2.49M
      else if (place == 'C')
949
2
  FETCH_ARG (7, val);
950
2.49M
      else if (place == '8')
951
0
  FETCH_ARG (3, val);
952
2.49M
      else if (place == '3')
953
34
  FETCH_ARG (8, val);
954
2.49M
      else if (place == 'b')
955
2.13M
  NEXTBYTE (p1, val);
956
359k
      else if (place == 'w' || place == 'W')
957
228k
  NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
958
131k
      else if (place == 'l')
959
131k
  NEXTLONG (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
960
0
      else
961
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
962
963
2.49M
      (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
964
2.49M
            "#%d", val);
965
2.49M
      break;
966
967
470k
    case 'B':
968
470k
      if (place == 'b')
969
0
  NEXTBYTE (p, disp);
970
470k
      else if (place == 'B')
971
385k
  disp = COERCE_SIGNED_CHAR (buffer[1]);
972
84.7k
      else if (place == 'w' || place == 'W')
973
76.1k
  NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
974
8.62k
      else if (place == 'l' || place == 'L' || place == 'C')
975
5.41k
  NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
976
3.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
3.20k
      else if (place == 'c')
985
3.20k
  {
986
3.20k
    if (buffer[1] & 0x40)    /* If bit six is one, long offset.  */
987
1.46k
      NEXTLONG (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
988
1.74k
    else
989
1.74k
      NEXTWORD (p, disp, PRINT_INSN_ARG_MEMORY_ERROR);
990
3.20k
  }
991
0
      else
992
0
  return PRINT_INSN_ARG_INVALID_OP_TABLE;
993
994
470k
      (*info->print_address_func) (addr + disp, info);
995
470k
      break;
996
997
32.9k
    case 'd':
998
32.9k
      {
999
32.9k
  int val1;
1000
1001
32.9k
  NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1002
32.9k
  FETCH_ARG (3, val1);
1003
32.9k
  (*info->fprintf_styled_func) (info->stream, dis_style_register,
1004
32.9k
              "%s", reg_names[val1 + 8]);
1005
32.9k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1006
32.9k
  (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1007
32.9k
              "%d", val);
1008
32.9k
  (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1009
32.9k
  break;
1010
32.9k
      }
1011
1012
1.26k
    case 's':
1013
1.26k
      FETCH_ARG (3, val);
1014
1.26k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1015
1.26k
            "%s", fpcr_names[val]);
1016
1.26k
      break;
1017
1018
3.45k
    case 'e':
1019
3.45k
      FETCH_ARG (2, val);
1020
3.45k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1021
3.45k
            "%%acc%d", val);
1022
3.45k
      break;
1023
1024
68
    case 'g':
1025
68
      FETCH_ARG (1, val);
1026
68
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1027
68
            "%%accext%s", val == 0 ? "01" : "23");
1028
68
      break;
1029
1030
30.5k
    case 'i':
1031
30.5k
      FETCH_ARG (2, val);
1032
30.5k
      if (val == 1)
1033
7.71k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1034
7.71k
              "<<");
1035
22.8k
      else if (val == 3)
1036
5.55k
  (*info->fprintf_styled_func) (info->stream, dis_style_sub_mnemonic,
1037
5.55k
              ">>");
1038
17.3k
      else
1039
17.3k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1040
13.2k
      break;
1041
1042
18.6k
    case 'I':
1043
      /* Get coprocessor ID... */
1044
18.6k
      val = fetch_arg (buffer, 'd', 3, info);
1045
18.6k
      if (val < 0)
1046
0
  return PRINT_INSN_ARG_MEMORY_ERROR;
1047
18.6k
      if (val != 1)        /* Unusual coprocessor ID?  */
1048
0
  (*info->fprintf_styled_func) (info->stream, dis_style_text,
1049
0
              "(cpid=%d) ", val);
1050
18.6k
      break;
1051
1052
18.9k
    case '4':
1053
1.16M
    case '*':
1054
1.49M
    case '~':
1055
2.22M
    case '%':
1056
3.35M
    case ';':
1057
3.37M
    case '@':
1058
3.42M
    case '!':
1059
6.60M
    case '$':
1060
6.60M
    case '?':
1061
6.61M
    case '/':
1062
6.62M
    case '&':
1063
6.62M
    case '|':
1064
6.64M
    case '<':
1065
6.65M
    case '>':
1066
6.71M
    case 'm':
1067
6.81M
    case 'n':
1068
6.87M
    case 'o':
1069
6.97M
    case 'p':
1070
6.98M
    case 'q':
1071
6.99M
    case 'v':
1072
6.99M
    case 'b':
1073
6.99M
    case 'w':
1074
6.99M
    case 'y':
1075
6.99M
    case 'z':
1076
6.99M
      if (place == 'd')
1077
869k
  {
1078
869k
    val = fetch_arg (buffer, 'x', 6, info);
1079
869k
    if (val < 0)
1080
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1081
869k
    val = ((val & 7) << 3) + ((val >> 3) & 7);
1082
869k
  }
1083
6.12M
      else
1084
6.12M
  {
1085
6.12M
    val = fetch_arg (buffer, 's', 6, info);
1086
6.12M
    if (val < 0)
1087
0
      return PRINT_INSN_ARG_MEMORY_ERROR;
1088
6.12M
  }
1089
1090
      /* If the <ea> is invalid for *d, then reject this match.  */
1091
6.99M
      if (!m68k_valid_ea (*d, val))
1092
881k
  return PRINT_INSN_ARG_INVALID_OPERAND;
1093
1094
      /* Get register number assuming address register.  */
1095
6.11M
      regno = (val & 7) + 8;
1096
6.11M
      regname = reg_names[regno];
1097
6.11M
      switch (val >> 3)
1098
6.11M
  {
1099
3.04M
  case 0:
1100
3.04M
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1101
3.04M
          "%s", reg_names[val]);
1102
3.04M
    break;
1103
1104
163k
  case 1:
1105
163k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1106
163k
          "%s", regname);
1107
163k
    break;
1108
1109
648k
  case 2:
1110
648k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1111
648k
          "%s", regname);
1112
648k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@");
1113
648k
    break;
1114
1115
460k
  case 3:
1116
460k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1117
460k
          "%s", regname);
1118
460k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@+");
1119
460k
    break;
1120
1121
592k
  case 4:
1122
592k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1123
592k
          "%s", regname);
1124
592k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@-");
1125
592k
    break;
1126
1127
507k
  case 5:
1128
507k
    NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1129
507k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1130
507k
          "%s", regname);
1131
507k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1132
507k
    (*info->fprintf_styled_func) (info->stream, dis_style_address_offset,
1133
507k
          "%d", val);
1134
507k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1135
507k
    break;
1136
1137
485k
  case 6:
1138
485k
    p = print_indexed (regno, p, addr, info);
1139
485k
    if (p == NULL)
1140
350
      return PRINT_INSN_ARG_MEMORY_ERROR;
1141
484k
    break;
1142
1143
484k
  case 7:
1144
211k
    switch (val & 7)
1145
211k
      {
1146
61.6k
      case 0:
1147
61.6k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1148
61.6k
        (*info->print_address_func) (val, info);
1149
61.6k
        break;
1150
1151
71.5k
      case 1:
1152
71.5k
        NEXTULONG (p, uval);
1153
71.4k
        (*info->print_address_func) (uval, info);
1154
71.4k
        break;
1155
1156
27.1k
      case 2:
1157
27.1k
        NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1158
27.1k
        (*info->fprintf_styled_func) (info->stream, dis_style_register,
1159
27.1k
              "%%pc");
1160
27.1k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, "@(");
1161
27.1k
        (*info->print_address_func) (addr + val, info);
1162
27.1k
        (*info->fprintf_styled_func) (info->stream, dis_style_text, ")");
1163
27.1k
        break;
1164
1165
25.8k
      case 3:
1166
25.8k
        p = print_indexed (-1, p, addr, info);
1167
25.8k
        if (p == NULL)
1168
29
    return PRINT_INSN_ARG_MEMORY_ERROR;
1169
25.7k
        break;
1170
1171
25.7k
      case 4:
1172
25.2k
        flt_p = 1;  /* Assume it's a float... */
1173
25.2k
        switch (place)
1174
25.2k
        {
1175
6.24k
    case 'b':
1176
6.24k
      NEXTBYTE (p, val);
1177
6.23k
      flt_p = 0;
1178
6.23k
      break;
1179
1180
10.4k
    case 'w':
1181
10.4k
      NEXTWORD (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1182
10.4k
      flt_p = 0;
1183
10.4k
      break;
1184
1185
5.26k
    case 'l':
1186
5.26k
      NEXTLONG (p, val, PRINT_INSN_ARG_MEMORY_ERROR);
1187
5.25k
      flt_p = 0;
1188
5.25k
      break;
1189
1190
397
    case 'f':
1191
397
      NEXTSINGLE (flval, p);
1192
396
      break;
1193
1194
1.20k
    case 'F':
1195
1.20k
      NEXTDOUBLE (flval, p);
1196
1.20k
      break;
1197
1198
1.20k
    case 'x':
1199
1.00k
      NEXTEXTEND (flval, p);
1200
1.00k
      break;
1201
1202
1.00k
    case 'p':
1203
600
      NEXTPACKED (p, flval);
1204
600
      break;
1205
1206
600
    default:
1207
0
      return PRINT_INSN_ARG_INVALID_OPERAND;
1208
25.2k
        }
1209
25.1k
        if (flt_p)  /* Print a float? */
1210
3.20k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1211
3.20k
                "#0e%g", flval);
1212
21.9k
        else
1213
21.9k
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1214
21.9k
                "#%d", val);
1215
25.1k
        break;
1216
1217
0
      default:
1218
0
        return PRINT_INSN_ARG_INVALID_OPERAND;
1219
211k
      }
1220
6.11M
  }
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
6.11M
      if (place == '/')
1226
12.9k
  {
1227
12.9k
    FETCH_ARG (1, val);
1228
12.9k
    if (val)
1229
6.91k
      info->fprintf_styled_func (info->stream, dis_style_text, "&");
1230
12.9k
  }
1231
6.11M
      break;
1232
1233
6.11M
    case 'L':
1234
20.2k
    case 'l':
1235
20.2k
  if (place == 'w')
1236
19.2k
    {
1237
19.2k
      char doneany;
1238
19.2k
      p1 = buffer + 2;
1239
19.2k
      NEXTWORD (p1, val, PRINT_INSN_ARG_MEMORY_ERROR);
1240
      /* Move the pointer ahead if this point is farther ahead
1241
         than the last.  */
1242
19.2k
      p = p1 > p ? p1 : p;
1243
19.2k
      if (val == 0)
1244
292
        {
1245
292
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1246
292
                "#0");
1247
292
    break;
1248
292
        }
1249
18.9k
      if (*d == 'l')
1250
1.40k
        {
1251
1.40k
    int newval = 0;
1252
1253
23.9k
    for (regno = 0; regno < 16; ++regno)
1254
22.4k
      if (val & (0x8000 >> regno))
1255
13.0k
        newval |= 1 << regno;
1256
1.40k
    val = newval;
1257
1.40k
        }
1258
18.9k
      val &= 0xffff;
1259
18.9k
      doneany = 0;
1260
253k
      for (regno = 0; regno < 16; ++regno)
1261
234k
        if (val & (1 << regno))
1262
77.1k
    {
1263
77.1k
      int first_regno;
1264
1265
77.1k
      if (doneany)
1266
58.2k
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1267
58.2k
              "/");
1268
77.1k
      doneany = 1;
1269
77.1k
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1270
77.1k
            "%s", reg_names[regno]);
1271
77.1k
      first_regno = regno;
1272
145k
      while (val & (1 << (regno + 1)))
1273
68.5k
        ++regno;
1274
77.1k
      if (regno > first_regno)
1275
35.6k
        {
1276
35.6k
          (*info->fprintf_styled_func) (info->stream,
1277
35.6k
                dis_style_text, "-");
1278
35.6k
          (*info->fprintf_styled_func) (info->stream,
1279
35.6k
                dis_style_register, "%s",
1280
35.6k
                reg_names[regno]);
1281
35.6k
        }
1282
77.1k
    }
1283
18.9k
    }
1284
1.04k
  else if (place == '3')
1285
393
    {
1286
      /* `fmovem' insn.  */
1287
393
      char doneany;
1288
1289
393
      FETCH_ARG (8, val);
1290
393
      if (val == 0)
1291
55
        {
1292
55
    (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1293
55
                "#0");
1294
55
    break;
1295
55
        }
1296
338
      if (*d == 'l')
1297
72
        {
1298
72
    int newval = 0;
1299
1300
648
    for (regno = 0; regno < 8; ++regno)
1301
576
      if (val & (0x80 >> regno))
1302
319
        newval |= 1 << regno;
1303
72
    val = newval;
1304
72
        }
1305
338
      val &= 0xff;
1306
338
      doneany = 0;
1307
2.31k
      for (regno = 0; regno < 8; ++regno)
1308
1.97k
        if (val & (1 << regno))
1309
820
    {
1310
820
      int first_regno;
1311
820
      if (doneany)
1312
482
        (*info->fprintf_styled_func) (info->stream, dis_style_text,
1313
482
              "/");
1314
820
      doneany = 1;
1315
820
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1316
820
            "%%fp%d", regno);
1317
820
      first_regno = regno;
1318
1.55k
      while (val & (1 << (regno + 1)))
1319
731
        ++regno;
1320
820
      if (regno > first_regno)
1321
388
        {
1322
388
          (*info->fprintf_styled_func) (info->stream,
1323
388
                dis_style_text, "-");
1324
388
          (*info->fprintf_styled_func) (info->stream,
1325
388
                dis_style_register,
1326
388
                "%%fp%d", regno);
1327
388
        }
1328
820
    }
1329
338
    }
1330
654
  else if (place == '8')
1331
654
    {
1332
654
      FETCH_ARG (3, val);
1333
      /* fmoveml for FP status registers.  */
1334
654
      (*info->fprintf_styled_func) (info->stream, dis_style_register,
1335
654
            "%s", fpcr_names[val]);
1336
654
    }
1337
0
  else
1338
0
    return PRINT_INSN_ARG_INVALID_OP_TABLE;
1339
19.9k
      break;
1340
1341
19.9k
    case 'X':
1342
519
      place = '8';
1343
      /* Fall through.  */
1344
695
    case 'Y':
1345
753
    case 'Z':
1346
2.38k
    case 'W':
1347
2.80k
    case '0':
1348
3.88k
    case '1':
1349
6.16k
    case '2':
1350
6.22k
    case '3':
1351
6.22k
      {
1352
6.22k
  char *name = 0;
1353
1354
6.22k
  FETCH_ARG (5, val);
1355
6.22k
  switch (val)
1356
6.22k
    {
1357
33
    case 2: name = "%tt0"; break;
1358
23
    case 3: name = "%tt1"; break;
1359
59
    case 0x10: name = "%tc"; break;
1360
277
    case 0x11: name = "%drp"; break;
1361
630
    case 0x12: name = "%srp"; break;
1362
12
    case 0x13: name = "%crp"; break;
1363
18
    case 0x14: name = "%cal"; break;
1364
1.11k
    case 0x15: name = "%val"; break;
1365
77
    case 0x16: name = "%scc"; break;
1366
3.22k
    case 0x17: name = "%ac"; break;
1367
339
    case 0x18: name = "%psr"; break;
1368
73
    case 0x19: name = "%pcsr"; break;
1369
139
    case 0x1c:
1370
174
    case 0x1d:
1371
174
      {
1372
174
        int break_reg = ((buffer[3] >> 2) & 7);
1373
1374
174
        (*info->fprintf_styled_func)
1375
174
    (info->stream, dis_style_register,
1376
174
     val == 0x1c ? "%%bad%d" : "%%bac%d", break_reg);
1377
174
      }
1378
174
      break;
1379
167
    default:
1380
167
      (*info->fprintf_styled_func) (info->stream, dis_style_text,
1381
167
            "<mmu register %d>", val);
1382
6.22k
    }
1383
6.22k
  if (name)
1384
5.88k
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1385
5.88k
          "%s", name);
1386
6.22k
      }
1387
0
      break;
1388
1389
122
    case 'f':
1390
122
      {
1391
122
  int fc;
1392
1393
122
  FETCH_ARG (5, fc);
1394
122
  if (fc == 1)
1395
26
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1396
26
          "%%dfc");
1397
96
  else if (fc == 0)
1398
96
    (*info->fprintf_styled_func) (info->stream, dis_style_register,
1399
96
          "%%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
122
      }
1405
0
      break;
1406
1407
21
    case 'V':
1408
21
      (*info->fprintf_styled_func) (info->stream, dis_style_register, "%%val");
1409
21
      break;
1410
1411
1.67k
    case 't':
1412
1.67k
      {
1413
1.67k
  int level;
1414
1415
1.67k
  FETCH_ARG (3, level);
1416
1.67k
  (*info->fprintf_styled_func) (info->stream, dis_style_immediate,
1417
1.67k
              "%d", level);
1418
1.67k
      }
1419
0
      break;
1420
1421
57.8k
    case 'u':
1422
57.8k
      {
1423
57.8k
  short is_upper = 0;
1424
57.8k
  int reg;
1425
1426
57.8k
  FETCH_ARG (5, reg);
1427
57.8k
  if (reg & 0x10)
1428
22.2k
    {
1429
22.2k
      is_upper = 1;
1430
22.2k
      reg &= 0xf;
1431
22.2k
    }
1432
57.8k
  (*info->fprintf_styled_func) (info->stream, dis_style_register, "%s%s",
1433
57.8k
              reg_half_names[reg],
1434
57.8k
              is_upper ? "u" : "l");
1435
57.8k
      }
1436
0
      break;
1437
1438
0
    default:
1439
0
      return PRINT_INSN_ARG_INVALID_OP_TABLE;
1440
13.7M
    }
1441
1442
12.8M
  return p - p0;
1443
13.7M
}
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
4.09M
{
1454
4.09M
  unsigned char *save_p;
1455
4.09M
  unsigned char *p;
1456
4.09M
  const char *d;
1457
4.09M
  const char *args = best->args;
1458
1459
4.09M
  struct private *priv = (struct private *) info->private_data;
1460
4.09M
  bfd_byte *buffer = priv->the_buffer;
1461
4.09M
  fprintf_styled_ftype save_printer = info->fprintf_styled_func;
1462
4.09M
  void (* save_print_address) (bfd_vma, struct disassemble_info *)
1463
4.09M
    = info->print_address_func;
1464
1465
4.09M
  if (*args == '.')
1466
54.4k
    args++;
1467
1468
  /* Point at first word of argument data,
1469
     and at descriptor for first argument.  */
1470
4.09M
  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
12.1M
  for (d = args; *d; d += 2)
1477
8.01M
    {
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
8.01M
      if (d[0] == '#')
1481
1.34M
  {
1482
1.34M
    if (d[1] == 'l' && p - buffer < 6)
1483
73.6k
      p = buffer + 6;
1484
1.26M
    else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8')
1485
1.26M
      p = buffer + 4;
1486
1.34M
  }
1487
1488
8.01M
      if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4)
1489
20.1k
  p = buffer + 4;
1490
1491
8.01M
      switch (d[1])
1492
8.01M
  {
1493
72.1k
  case '1':
1494
76.6k
  case '2':
1495
139k
  case '3':
1496
141k
  case '7':
1497
149k
  case '8':
1498
149k
  case '9':
1499
155k
  case 'i':
1500
155k
    if (p - buffer < 4)
1501
85.4k
      p = buffer + 4;
1502
155k
    break;
1503
65
  case '4':
1504
130
  case '5':
1505
195
  case '6':
1506
195
    if (p - buffer < 6)
1507
65
      p = buffer + 6;
1508
195
    break;
1509
7.85M
  default:
1510
7.85M
    break;
1511
8.01M
  }
1512
8.01M
    }
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
4.09M
  if (p - buffer < 4 && (best->match & 0xFFFF) != 0)
1517
37.2k
    p = buffer + 4;
1518
1519
  /* lpstop is another exception.  It takes a one word argument but is
1520
     three words long.  */
1521
4.09M
  if (p - buffer < 6
1522
4.09M
      && (best->match & 0xffff) == 0xffff
1523
4.09M
      && args[0] == '#'
1524
4.09M
      && args[1] == 'w')
1525
3
    {
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
3
      p = buffer + 6;
1531
3
      if (!FETCH_DATA (info, p))
1532
0
  return -1;
1533
3
      buffer[2] = buffer[4];
1534
3
      buffer[3] = buffer[5];
1535
3
    }
1536
1537
4.09M
  if (!FETCH_DATA (info, p))
1538
313
    return -1;
1539
1540
4.09M
  save_p = p;
1541
4.09M
  info->print_address_func = dummy_print_address;
1542
4.09M
  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
10.7M
  for (d = args; *d; d += 2)
1547
7.56M
    {
1548
7.56M
      int eaten = print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1549
1550
7.56M
      if (eaten >= 0)
1551
6.66M
  p += eaten;
1552
899k
      else if (eaten == PRINT_INSN_ARG_INVALID_OPERAND
1553
899k
         || eaten == PRINT_INSN_ARG_MEMORY_ERROR)
1554
899k
  {
1555
899k
    info->fprintf_styled_func = save_printer;
1556
899k
    info->print_address_func = save_print_address;
1557
899k
    return eaten == PRINT_INSN_ARG_MEMORY_ERROR ? -1 : 0;
1558
899k
  }
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
7.56M
    }
1572
1573
3.19M
  p = save_p;
1574
3.19M
  info->fprintf_styled_func = save_printer;
1575
3.19M
  info->print_address_func = save_print_address;
1576
1577
3.19M
  d = args;
1578
1579
3.19M
  info->fprintf_styled_func (info->stream, dis_style_mnemonic, "%s", best->name);
1580
1581
3.19M
  if (*d)
1582
3.19M
    info->fprintf_styled_func (info->stream, dis_style_text, " ");
1583
1584
9.35M
  while (*d)
1585
6.15M
    {
1586
6.15M
      p += print_insn_arg (d, buffer, p, memaddr + (p - buffer), info);
1587
6.15M
      d += 2;
1588
1589
6.15M
      if (*d && *(d - 2) != 'I' && *d != 'k')
1590
2.95M
  info->fprintf_styled_func (info->stream, dis_style_text, ",");
1591
6.15M
    }
1592
1593
3.19M
  return p - buffer;
1594
4.09M
}
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
4.76M
{
1606
4.76M
  int i;
1607
4.76M
  const char *d;
1608
4.76M
  static const struct m68k_opcode **opcodes[16];
1609
4.76M
  static int numopcodes[16];
1610
4.76M
  int val;
1611
4.76M
  int major_opcode;
1612
1613
4.76M
  struct private *priv = (struct private *) info->private_data;
1614
4.76M
  bfd_byte *buffer = priv->the_buffer;
1615
1616
4.76M
  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
4.76M
  if (!FETCH_DATA (info, buffer + 2))
1643
909
    return -1;
1644
4.76M
  major_opcode = (buffer[0] >> 4) & 15;
1645
1646
718M
  for (i = 0; i < numopcodes[major_opcode]; i++)
1647
716M
    {
1648
716M
      const struct m68k_opcode *opc = opcodes[major_opcode][i];
1649
716M
      unsigned long opcode = opc->opcode;
1650
716M
      unsigned long match = opc->match;
1651
716M
      const char *args = opc->args;
1652
1653
716M
      if (*args == '.')
1654
6.62M
  args++;
1655
1656
716M
      if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24)))
1657
716M
    && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16)))
1658
    /* Only fetch the next two bytes if we need to.  */
1659
716M
    && (((0xffff & match) == 0)
1660
39.0M
        ||
1661
39.0M
        (FETCH_DATA (info, buffer + 4)
1662
33.9M
         && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8)))
1663
33.9M
         && ((0xff & buffer[3] & match) == (0xff & opcode)))
1664
39.0M
        )
1665
716M
    && (opc->arch & arch_mask) != 0)
1666
4.17M
  {
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
12.3M
    for (d = args; *d; d += 2)
1671
8.18M
      if (d[1] == 'D')
1672
1.38k
        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
4.17M
    if (*d == '\0')
1678
12.3M
      for (d = args; *d; d += 2)
1679
8.18M
        if (d[1] == 't')
1680
1.54k
    break;
1681
1682
    /* Don't match fmovel with more than one register;
1683
       wait for fmoveml.  */
1684
4.17M
    if (*d == '\0')
1685
4.17M
      {
1686
12.3M
        for (d = args; *d; d += 2)
1687
8.17M
    {
1688
8.17M
      if (d[0] == 's' && d[1] == '8')
1689
2.23k
        {
1690
2.23k
          val = fetch_arg (buffer, d[1], 3, info);
1691
2.23k
          if (val < 0)
1692
0
      return 0;
1693
2.23k
          if ((val & (val - 1)) != 0)
1694
1.09k
      break;
1695
2.23k
        }
1696
8.17M
    }
1697
4.17M
      }
1698
1699
    /* Don't match FPU insns with non-default coprocessor ID.  */
1700
4.17M
    if (*d == '\0')
1701
4.17M
      {
1702
12.1M
        for (d = args; *d; d += 2)
1703
8.08M
    {
1704
8.08M
      if (d[0] == 'I')
1705
90.3k
        {
1706
90.3k
          val = fetch_arg (buffer, 'd', 3, info);
1707
90.3k
          if (val != 1)
1708
78.9k
      break;
1709
90.3k
        }
1710
8.08M
    }
1711
4.17M
      }
1712
1713
4.17M
    if (*d == '\0')
1714
4.09M
      if ((val = match_insn_m68k (memaddr, info, opc)))
1715
3.19M
        return val;
1716
4.17M
  }
1717
716M
    }
1718
1.57M
  return 0;
1719
4.76M
}
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
3.92M
{
1727
3.92M
  unsigned int arch_mask;
1728
3.92M
  struct private priv;
1729
3.92M
  int val;
1730
1731
3.92M
  bfd_byte *buffer = priv.the_buffer;
1732
1733
3.92M
  info->private_data = & priv;
1734
  /* Tell objdump to use two bytes per chunk
1735
     and six bytes per line for displaying raw data.  */
1736
3.92M
  info->bytes_per_chunk = 2;
1737
3.92M
  info->bytes_per_line = 6;
1738
3.92M
  info->display_endian = BFD_ENDIAN_BIG;
1739
3.92M
  priv.max_fetched = priv.the_buffer;
1740
3.92M
  priv.insn_start = memaddr;
1741
1742
3.92M
  arch_mask = bfd_m68k_mach_to_features (info->mach);
1743
3.92M
  if (!arch_mask)
1744
3.81M
    {
1745
      /* First try printing an m680x0 instruction.  Try printing a Coldfire
1746
   one if that fails.  */
1747
3.81M
      val = m68k_scan_mask (memaddr, info, m68k_mask);
1748
3.81M
      if (val <= 0)
1749
844k
  val = m68k_scan_mask (memaddr, info, mcf_mask);
1750
3.81M
    }
1751
112k
  else
1752
112k
    {
1753
112k
      val = m68k_scan_mask (memaddr, info, arch_mask);
1754
112k
    }
1755
1756
3.92M
  if (val == 0)
1757
728k
    {
1758
      /* Handle undefined instructions.  */
1759
728k
      info->fprintf_styled_func (info->stream, dis_style_assembler_directive,
1760
728k
         ".short");
1761
728k
      info->fprintf_styled_func (info->stream, dis_style_text, " ");
1762
728k
      info->fprintf_styled_func (info->stream, dis_style_immediate,
1763
728k
         "0x%04x", (buffer[0] << 8) + buffer[1]);
1764
728k
    }
1765
1766
3.92M
  return val ? val : 2;
1767
3.92M
}