Coverage Report

Created: 2026-03-10 08:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/tic54x-dis.c
Line
Count
Source
1
/* Disassembly routines for TMS320C54X architecture
2
   Copyright (C) 1999-2026 Free Software Foundation, Inc.
3
   Contributed by Timothy Wall (twall@cygnus.com)
4
5
   This file is part of the GNU opcodes library.
6
7
   This library is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this file; see the file COPYING.  If not, write to the
19
   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include <errno.h>
24
#include <math.h>
25
#include <stdlib.h>
26
#include "disassemble.h"
27
#include "opcode/tic54x.h"
28
#include "coff/tic54x.h"
29
30
static int has_lkaddr (unsigned short, const insn_template *);
31
static int get_insn_size (unsigned short, const insn_template *);
32
static int print_instruction (disassemble_info *, bfd_vma,
33
                              unsigned short, const char *,
34
                              const enum optype [], int, int);
35
static int print_parallel_instruction (disassemble_info *, bfd_vma,
36
                                       unsigned short,
37
                                       const insn_template *, int);
38
static int sprint_dual_address (disassemble_info *,char [],
39
                                unsigned short);
40
static int sprint_indirect_address (disassemble_info *,char [],
41
                                    unsigned short);
42
static int sprint_direct_address (disassemble_info *,char [],
43
                                  unsigned short);
44
static int sprint_mmr (disassemble_info *,char [],int);
45
static int sprint_condition (disassemble_info *,char *,unsigned short);
46
static int sprint_cc2 (disassemble_info *,char *,unsigned short);
47
48
int
49
print_insn_tic54x (bfd_vma memaddr, disassemble_info *info)
50
228k
{
51
228k
  bfd_byte opbuf[2];
52
228k
  unsigned short opcode;
53
228k
  int status, size;
54
228k
  const insn_template* tm;
55
56
228k
  status = (*info->read_memory_func) (memaddr, opbuf, 2, info);
57
228k
  if (status != 0)
58
111
  {
59
111
    (*info->memory_error_func) (status, memaddr, info);
60
111
    return -1;
61
111
  }
62
63
227k
  opcode = bfd_getl16 (opbuf);
64
227k
  tm = tic54x_get_insn (info, memaddr, opcode, &size);
65
66
227k
  info->bytes_per_line = 2;
67
227k
  info->bytes_per_chunk = 2;
68
227k
  info->octets_per_byte = 2;
69
227k
  info->display_endian = BFD_ENDIAN_LITTLE;
70
71
227k
  if (tm->flags & FL_PAR)
72
17.1k
  {
73
17.1k
    if (!print_parallel_instruction (info, memaddr, opcode, tm, size))
74
0
      return -1;
75
17.1k
  }
76
210k
  else
77
210k
  {
78
210k
    if (!print_instruction (info, memaddr, opcode,
79
210k
                            (char *) tm->name,
80
210k
                            tm->operand_types,
81
210k
                            size, (tm->flags & FL_EXT)))
82
60
      return -1;
83
210k
  }
84
85
227k
  return size * 2;
86
227k
}
87
88
static int
89
has_lkaddr (unsigned short memdata, const insn_template *tm)
90
215k
{
91
215k
  return (IS_LKADDR (memdata)
92
33.5k
    && (OPTYPE (tm->operand_types[0]) == OP_Smem
93
22.6k
        || OPTYPE (tm->operand_types[1]) == OP_Smem
94
21.6k
        || OPTYPE (tm->operand_types[2]) == OP_Smem
95
20.4k
        || OPTYPE (tm->operand_types[1]) == OP_Sind
96
20.2k
              || OPTYPE (tm->operand_types[0]) == OP_Lmem
97
19.6k
              || OPTYPE (tm->operand_types[1]) == OP_Lmem));
98
215k
}
99
100
/* always returns 1 (whether an insn template was found) since we provide an
101
   "unknown instruction" template */
102
const insn_template*
103
tic54x_get_insn (disassemble_info *info, bfd_vma addr,
104
                 unsigned short memdata, int *size)
105
227k
{
106
227k
  const insn_template *tm = NULL;
107
108
22.6M
  for (tm = tic54x_optab; tm->name; tm++)
109
22.6M
  {
110
22.6M
    if (tm->opcode == (memdata & tm->mask))
111
214k
    {
112
      /* a few opcodes span two words */
113
214k
      if (tm->flags & FL_EXT)
114
12.5k
        {
115
          /* if lk addressing is used, the second half of the opcode gets
116
             pushed one word later */
117
12.5k
          bfd_byte opbuf[2];
118
12.5k
          bfd_vma addr2 = addr + 1 + has_lkaddr (memdata, tm);
119
12.5k
          int status = (*info->read_memory_func) (addr2, opbuf, 2, info);
120
          /* FIXME handle errors.  */
121
12.5k
          if (status == 0)
122
12.5k
            {
123
12.5k
              unsigned short data2 = bfd_getl16 (opbuf);
124
12.5k
              if (tm->opcode2 == (data2 & tm->mask2))
125
992
                {
126
992
                  if (size) *size = get_insn_size (memdata, tm);
127
992
                  return tm;
128
992
                }
129
12.5k
            }
130
12.5k
        }
131
201k
      else
132
201k
        {
133
201k
          if (size) *size = get_insn_size (memdata, tm);
134
201k
          return tm;
135
201k
        }
136
214k
    }
137
22.6M
  }
138
245k
  for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++)
139
237k
  {
140
237k
    if (tm->opcode == (memdata & tm->mask))
141
17.1k
    {
142
17.1k
      if (size) *size = get_insn_size (memdata, tm);
143
17.1k
      return tm;
144
17.1k
    }
145
237k
  }
146
147
8.28k
  if (size) *size = 1;
148
8.28k
  return &tic54x_unknown_opcode;
149
25.4k
}
150
151
static int
152
get_insn_size (unsigned short memdata, const insn_template *insn)
153
219k
{
154
219k
  int size;
155
156
219k
  if (insn->flags & FL_PAR)
157
17.1k
    {
158
      /* only non-parallel instructions support lk addressing */
159
17.1k
      size = insn->words;
160
17.1k
    }
161
202k
  else
162
202k
    {
163
202k
      size = insn->words + has_lkaddr (memdata, insn);
164
202k
    }
165
166
219k
  return size;
167
219k
}
168
169
int
170
print_instruction (disassemble_info *info,
171
       bfd_vma memaddr,
172
       unsigned short opcode,
173
       const char *tm_name,
174
       const enum optype tm_operands[],
175
       int size,
176
       int ext)
177
245k
{
178
245k
  static int n;
179
  /* string storage for multiple operands */
180
245k
  char operand[4][64] = { {0},{0},{0},{0}, };
181
245k
  bfd_byte buf[2];
182
245k
  unsigned long opcode2 = 0;
183
245k
  unsigned long lkaddr = 0;
184
245k
  enum optype src = OP_None;
185
245k
  enum optype dst = OP_None;
186
245k
  int i, shift;
187
245k
  char *comma = "";
188
189
245k
  info->fprintf_func (info->stream, "%-7s", tm_name);
190
191
245k
  if (size > 1)
192
32.5k
    {
193
32.5k
      int status = (*info->read_memory_func) (memaddr + 1, buf, 2, info);
194
32.5k
      if (status != 0)
195
57
        return 0;
196
32.5k
      lkaddr = opcode2 = bfd_getl16 (buf);
197
32.5k
      if (size > 2)
198
2.42k
        {
199
2.42k
          status = (*info->read_memory_func) (memaddr + 2, buf, 2, info);
200
2.42k
          if (status != 0)
201
3
            return 0;
202
2.42k
          opcode2 = bfd_getl16 (buf);
203
2.42k
        }
204
32.5k
    }
205
206
765k
  for (i = 0; i < MAX_OPERANDS && OPTYPE (tm_operands[i]) != OP_None; i++)
207
520k
    {
208
520k
      char *next_comma = ",";
209
520k
      int optional = (tm_operands[i] & OPT) != 0;
210
211
520k
      switch (OPTYPE (tm_operands[i]))
212
520k
        {
213
33.1k
        case OP_Xmem:
214
33.1k
          sprint_dual_address (info, operand[i], XMEM (opcode));
215
33.1k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
216
33.1k
          break;
217
26.9k
        case OP_Ymem:
218
26.9k
          sprint_dual_address (info, operand[i], YMEM (opcode));
219
26.9k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
220
26.9k
          break;
221
139k
        case OP_Smem:
222
141k
        case OP_Sind:
223
151k
        case OP_Lmem:
224
151k
          info->fprintf_func (info->stream, "%s", comma);
225
151k
          if (INDIRECT (opcode))
226
26.2k
            {
227
26.2k
              if (MOD (opcode) >= 12)
228
11.0k
                {
229
11.0k
                  bfd_vma addr = lkaddr;
230
11.0k
                  int arf = ARF (opcode);
231
11.0k
                  int mod = MOD (opcode);
232
11.0k
                  if (mod == 15)
233
5.45k
                      info->fprintf_func (info->stream, "*(");
234
5.59k
                  else
235
5.59k
                      info->fprintf_func (info->stream, "*%sar%d(",
236
5.59k
                                          (mod == 13 || mod == 14 ? "+" : ""),
237
5.59k
                                          arf);
238
11.0k
                  (*(info->print_address_func)) ((bfd_vma) addr, info);
239
11.0k
                  info->fprintf_func (info->stream, ")%s",
240
11.0k
                                      mod == 14 ? "%" : "");
241
11.0k
                }
242
15.2k
              else
243
15.2k
                {
244
15.2k
                  sprint_indirect_address (info, operand[i], opcode);
245
15.2k
                  info->fprintf_func (info->stream, "%s", operand[i]);
246
15.2k
                }
247
26.2k
            }
248
125k
          else
249
125k
          {
250
            /* FIXME -- use labels (print_address_func) */
251
            /* in order to do this, we need to guess what DP is */
252
125k
            sprint_direct_address (info, operand[i], opcode);
253
125k
            info->fprintf_func (info->stream, "%s", operand[i]);
254
125k
          }
255
151k
          break;
256
2.77k
        case OP_dmad:
257
2.77k
          info->fprintf_func (info->stream, "%s", comma);
258
2.77k
          (*(info->print_address_func)) ((bfd_vma) opcode2, info);
259
2.77k
          break;
260
1.15k
        case OP_xpmad:
261
          /* upper 7 bits of address are in the opcode */
262
1.15k
          opcode2 += ((unsigned long) opcode & 0x7F) << 16;
263
          /* fall through */
264
6.49k
        case OP_pmad:
265
6.49k
          info->fprintf_func (info->stream, "%s", comma);
266
6.49k
          (*(info->print_address_func)) ((bfd_vma) opcode2, info);
267
6.49k
          break;
268
668
        case OP_MMRX:
269
668
          sprint_mmr (info, operand[i], MMRX (opcode));
270
668
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
271
668
          break;
272
668
        case OP_MMRY:
273
668
          sprint_mmr (info, operand[i], MMRY (opcode));
274
668
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
275
668
          break;
276
5.40k
        case OP_MMR:
277
5.40k
          sprint_mmr (info, operand[i], MMR (opcode));
278
5.40k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
279
5.40k
          break;
280
1.71k
        case OP_PA:
281
1.71k
          sprintf (operand[i], "pa%d", (unsigned) opcode2);
282
1.71k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
283
1.71k
          break;
284
33.9k
        case OP_SRC:
285
33.9k
          src = SRC (ext ? opcode2 : opcode) ? OP_B : OP_A;
286
33.9k
          sprintf (operand[i], (src == OP_B) ? "b" : "a");
287
33.9k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
288
33.9k
          break;
289
108k
        case OP_SRC1:
290
108k
          src = SRC1 (ext ? opcode2 : opcode) ? OP_B : OP_A;
291
108k
          sprintf (operand[i], (src == OP_B) ? "b" : "a");
292
108k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
293
108k
          break;
294
2.93k
        case OP_RND:
295
2.93k
          dst = DST (opcode) ? OP_B : OP_A;
296
2.93k
          sprintf (operand[i], (dst == OP_B) ? "a" : "b");
297
2.93k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
298
2.93k
          break;
299
61.5k
        case OP_DST:
300
61.5k
          dst = DST (ext ? opcode2 : opcode) ? OP_B : OP_A;
301
61.5k
          if (!optional || dst != src)
302
51.0k
            {
303
51.0k
              sprintf (operand[i], (dst == OP_B) ? "b" : "a");
304
51.0k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
305
51.0k
            }
306
10.4k
          else
307
10.4k
            next_comma = comma;
308
61.5k
          break;
309
1.57k
        case OP_B:
310
1.57k
          sprintf (operand[i], "b");
311
1.57k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
312
1.57k
          break;
313
113
        case OP_A:
314
113
          sprintf (operand[i], "a");
315
113
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
316
113
          break;
317
95
        case OP_ARX:
318
95
          sprintf (operand[i], "ar%d", (int) ARX (opcode));
319
95
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
320
95
          break;
321
4.00k
        case OP_SHIFT:
322
4.00k
          shift = SHIFT (ext ? opcode2 : opcode);
323
4.00k
          if (!optional || shift != 0)
324
2.45k
            {
325
2.45k
              sprintf (operand[i], "%d", shift);
326
2.45k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
327
2.45k
            }
328
1.54k
          else
329
1.54k
            next_comma = comma;
330
4.00k
          break;
331
4.95k
        case OP_SHFT:
332
4.95k
          shift = SHFT (opcode);
333
4.95k
          if (!optional || shift != 0)
334
4.60k
            {
335
4.60k
              sprintf (operand[i], "%d", (unsigned) shift);
336
4.60k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
337
4.60k
            }
338
349
          else
339
349
            next_comma = comma;
340
4.95k
          break;
341
11.5k
        case OP_lk:
342
11.5k
          sprintf (operand[i], "#%d", (int) (short) opcode2);
343
11.5k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
344
11.5k
          break;
345
1.80k
        case OP_T:
346
1.80k
          sprintf (operand[i], "t");
347
1.80k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
348
1.80k
          break;
349
5.94k
        case OP_TS:
350
5.94k
          sprintf (operand[i], "ts");
351
5.94k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
352
5.94k
          break;
353
772
        case OP_k8:
354
772
          sprintf (operand[i], "%d", (int) ((signed char) (opcode & 0xFF)));
355
772
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
356
772
          break;
357
6.07k
        case OP_16:
358
6.07k
          sprintf (operand[i], "16");
359
6.07k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
360
6.07k
          break;
361
2.41k
        case OP_ASM:
362
2.41k
          sprintf (operand[i], "asm");
363
2.41k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
364
2.41k
          break;
365
435
        case OP_BITC:
366
435
          sprintf (operand[i], "%d", (int) (opcode & 0xF));
367
435
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
368
435
          break;
369
18.1k
        case OP_CC:
370
          /* put all CC operands in the same operand */
371
18.1k
          sprint_condition (info, operand[i], opcode);
372
18.1k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
373
18.1k
          i = MAX_OPERANDS;
374
18.1k
          break;
375
1.56k
        case OP_CC2:
376
1.56k
          sprint_cc2 (info, operand[i], opcode);
377
1.56k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
378
1.56k
          break;
379
95
        case OP_CC3:
380
95
        {
381
95
          const char *code[] = { "eq", "lt", "gt", "neq" };
382
383
    /* Do not use sprintf with only two parameters as a
384
       compiler warning could be generated in such conditions.  */
385
95
    sprintf (operand[i], "%s", code[CC3 (opcode)]);
386
95
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
387
95
          break;
388
1.15k
        }
389
53
        case OP_123:
390
53
          {
391
53
            int code = (opcode >> 8) & 0x3;
392
53
            sprintf (operand[i], "%d", (code == 0) ? 1 : (code == 2) ? 2 : 3);
393
53
            info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
394
53
            break;
395
1.15k
          }
396
142
        case OP_k5:
397
142
          sprintf (operand[i], "#%d", ((opcode & 0x1F) ^ 0x10) - 0x10);
398
142
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
399
142
          break;
400
1.69k
        case OP_k8u:
401
1.69k
          sprintf (operand[i], "#%d", (unsigned) (opcode & 0xFF));
402
1.69k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
403
1.69k
          break;
404
56
        case OP_k3:
405
56
          sprintf (operand[i], "#%d", (int) (opcode & 0x7));
406
56
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
407
56
          break;
408
416
        case OP_lku:
409
416
          sprintf (operand[i], "#%d", (unsigned) opcode2);
410
416
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
411
416
          break;
412
200
        case OP_N:
413
200
          n = (opcode >> 9) & 0x1;
414
200
          sprintf (operand[i], "st%d", n);
415
200
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
416
200
          break;
417
200
        case OP_SBIT:
418
200
        {
419
200
          const char *status0[] = {
420
200
            "0", "1", "2", "3", "4", "5", "6", "7", "8",
421
200
            "ovb", "ova", "c", "tc", "13", "14", "15"
422
200
          };
423
200
          const char *status1[] = {
424
200
            "0", "1", "2", "3", "4",
425
200
            "cmpt", "frct", "c16", "sxm", "ovm", "10",
426
200
            "intm", "hm", "xf", "cpl", "braf"
427
200
          };
428
200
          sprintf (operand[i], "%s",
429
200
                   n ? status1[SBIT (opcode)] : status0[SBIT (opcode)]);
430
200
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
431
200
          break;
432
1.15k
        }
433
16.3k
        case OP_12:
434
16.3k
          sprintf (operand[i], "%d", (int) ((opcode >> 9) & 1) + 1);
435
16.3k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
436
16.3k
          break;
437
444
        case OP_TRN:
438
444
          sprintf (operand[i], "trn");
439
444
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
440
444
          break;
441
2.59k
        case OP_DP:
442
2.59k
          sprintf (operand[i], "dp");
443
2.59k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
444
2.59k
          break;
445
2.02k
        case OP_k9:
446
          /* FIXME-- this is DP, print the original address? */
447
2.02k
          sprintf (operand[i], "#%d", (int) (opcode & 0x1FF));
448
2.02k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
449
2.02k
          break;
450
56
        case OP_ARP:
451
56
          sprintf (operand[i], "arp");
452
56
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
453
56
          break;
454
40
        case OP_031:
455
40
          sprintf (operand[i], "%d", (int) (opcode & 0x1F));
456
40
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
457
40
          break;
458
0
        default:
459
0
          sprintf (operand[i], "??? (0x%x)", tm_operands[i]);
460
0
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
461
0
          break;
462
520k
        }
463
520k
      comma = next_comma;
464
520k
    }
465
245k
  return 1;
466
245k
}
467
468
static int
469
print_parallel_instruction (disassemble_info *info,
470
          bfd_vma memaddr,
471
          unsigned short opcode,
472
          const insn_template *ptm,
473
          int size)
474
17.1k
{
475
17.1k
  print_instruction (info, memaddr, opcode,
476
17.1k
                     ptm->name, ptm->operand_types, size, 0);
477
17.1k
  info->fprintf_func (info->stream, " || ");
478
17.1k
  return print_instruction (info, memaddr, opcode,
479
17.1k
                            ptm->parname, ptm->paroperand_types, size, 0);
480
17.1k
}
481
482
static int
483
sprint_dual_address (disassemble_info *info ATTRIBUTE_UNUSED,
484
         char buf[],
485
         unsigned short code)
486
60.1k
{
487
60.1k
  const char *formats[] = {
488
60.1k
    "*ar%d",
489
60.1k
    "*ar%d-",
490
60.1k
    "*ar%d+",
491
60.1k
    "*ar%d+0%%",
492
60.1k
  };
493
60.1k
  return sprintf (buf, formats[XMOD (code)], XARX (code));
494
60.1k
}
495
496
static int
497
sprint_indirect_address (disassemble_info *info ATTRIBUTE_UNUSED,
498
       char buf[],
499
       unsigned short opcode)
500
15.2k
{
501
15.2k
  const char *formats[] = {
502
15.2k
    "*ar%d",
503
15.2k
    "*ar%d-",
504
15.2k
    "*ar%d+",
505
15.2k
    "*+ar%d",
506
15.2k
    "*ar%d-0B",
507
15.2k
    "*ar%d-0",
508
15.2k
    "*ar%d+0",
509
15.2k
    "*ar%d+0B",
510
15.2k
    "*ar%d-%%",
511
15.2k
    "*ar%d-0%%",
512
15.2k
    "*ar%d+%%",
513
15.2k
    "*ar%d+0%%",
514
15.2k
  };
515
15.2k
  return sprintf (buf, formats[MOD (opcode)], ARF (opcode));
516
15.2k
}
517
518
static int
519
sprint_direct_address (disassemble_info *info ATTRIBUTE_UNUSED,
520
           char buf[],
521
           unsigned short opcode)
522
125k
{
523
  /* FIXME -- look up relocation if available */
524
125k
  return sprintf (buf, "DP+0x%02x", (int) (opcode & 0x7F));
525
125k
}
526
527
static int
528
sprint_mmr (disassemble_info *info ATTRIBUTE_UNUSED,
529
      char buf[],
530
      int mmr)
531
6.73k
{
532
6.73k
  const tic54x_symbol *reg = tic54x_mmregs;
533
456k
  while (reg->name != NULL)
534
453k
    {
535
453k
      if (mmr == reg->value)
536
4.16k
        {
537
4.16k
          sprintf (buf, "%s", (reg + 1)->name);
538
4.16k
          return 1;
539
4.16k
        }
540
449k
      ++reg;
541
449k
    }
542
2.57k
  sprintf (buf, "MMR(%d)", mmr); /* FIXME -- different targets.  */
543
2.57k
  return 0;
544
6.73k
}
545
546
static int
547
sprint_cc2 (disassemble_info *info ATTRIBUTE_UNUSED,
548
      char *buf,
549
      unsigned short opcode)
550
1.56k
{
551
1.56k
  const char *cc2[] = {
552
1.56k
    "??", "??", "ageq", "alt", "aneq", "aeq", "agt", "aleq",
553
1.56k
    "??", "??", "bgeq", "blt", "bneq", "beq", "bgt", "bleq",
554
1.56k
  };
555
1.56k
  return sprintf (buf, "%s", cc2[opcode & 0xF]);
556
1.56k
}
557
558
static int
559
sprint_condition (disassemble_info *info ATTRIBUTE_UNUSED,
560
      char *buf,
561
      unsigned short opcode)
562
18.1k
{
563
18.1k
  char *start = buf;
564
18.1k
  const char *cmp[] = {
565
18.1k
      "??", "??", "geq", "lt", "neq", "eq", "gt", "leq"
566
18.1k
  };
567
18.1k
  if (opcode & 0x40)
568
13.2k
    {
569
13.2k
      char acc = (opcode & 0x8) ? 'b' : 'a';
570
13.2k
      if (opcode & 0x7)
571
12.9k
          buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode & 0x7)],
572
12.9k
                          (opcode & 0x20) ? ", " : "");
573
13.2k
      if (opcode & 0x20)
574
12.4k
          buf += sprintf (buf, "%c%s", acc, (opcode & 0x10) ? "ov" : "nov");
575
13.2k
    }
576
4.89k
  else if (opcode & 0x3F)
577
3.37k
    {
578
3.37k
      if (opcode & 0x30)
579
2.12k
        buf += sprintf (buf, "%s%s",
580
2.12k
                        ((opcode & 0x30) == 0x30) ? "tc" : "ntc",
581
2.12k
                        (opcode & 0x0F) ? ", " : "");
582
3.37k
      if (opcode & 0x0C)
583
2.16k
        buf += sprintf (buf, "%s%s",
584
2.16k
                        ((opcode & 0x0C) == 0x0C) ? "c" : "nc",
585
2.16k
                        (opcode & 0x03) ? ", " : "");
586
3.37k
      if (opcode & 0x03)
587
2.30k
        buf += sprintf (buf, "%s",
588
2.30k
                        ((opcode & 0x03) == 0x03) ? "bio" : "nbio");
589
3.37k
    }
590
1.51k
  else
591
1.51k
    buf += sprintf (buf, "unc");
592
593
18.1k
  return buf - start;
594
18.1k
}