Coverage Report

Created: 2025-07-08 11:15

/src/binutils-gdb/opcodes/tic54x-dis.c
Line
Count
Source (jump to first uncovered line)
1
/* Disassembly routines for TMS320C54X architecture
2
   Copyright (C) 1999-2025 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
3.78M
{
51
3.78M
  bfd_byte opbuf[2];
52
3.78M
  unsigned short opcode;
53
3.78M
  int status, size;
54
3.78M
  const insn_template* tm;
55
56
3.78M
  status = (*info->read_memory_func) (memaddr, opbuf, 2, info);
57
3.78M
  if (status != 0)
58
153
  {
59
153
    (*info->memory_error_func) (status, memaddr, info);
60
153
    return -1;
61
153
  }
62
63
3.78M
  opcode = bfd_getl16 (opbuf);
64
3.78M
  tm = tic54x_get_insn (info, memaddr, opcode, &size);
65
66
3.78M
  info->bytes_per_line = 2;
67
3.78M
  info->bytes_per_chunk = 2;
68
3.78M
  info->octets_per_byte = 2;
69
3.78M
  info->display_endian = BFD_ENDIAN_LITTLE;
70
71
3.78M
  if (tm->flags & FL_PAR)
72
203k
  {
73
203k
    if (!print_parallel_instruction (info, memaddr, opcode, tm, size))
74
0
      return -1;
75
203k
  }
76
3.57M
  else
77
3.57M
  {
78
3.57M
    if (!print_instruction (info, memaddr, opcode,
79
3.57M
                            (char *) tm->name,
80
3.57M
                            tm->operand_types,
81
3.57M
                            size, (tm->flags & FL_EXT)))
82
134
      return -1;
83
3.57M
  }
84
85
3.78M
  return size * 2;
86
3.78M
}
87
88
static int
89
has_lkaddr (unsigned short memdata, const insn_template *tm)
90
3.61M
{
91
3.61M
  return (IS_LKADDR (memdata)
92
3.61M
    && (OPTYPE (tm->operand_types[0]) == OP_Smem
93
400k
        || OPTYPE (tm->operand_types[1]) == OP_Smem
94
400k
        || OPTYPE (tm->operand_types[2]) == OP_Smem
95
400k
        || OPTYPE (tm->operand_types[1]) == OP_Sind
96
400k
              || OPTYPE (tm->operand_types[0]) == OP_Lmem
97
400k
              || OPTYPE (tm->operand_types[1]) == OP_Lmem));
98
3.61M
}
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
3.78M
{
106
3.78M
  const insn_template *tm = NULL;
107
108
339M
  for (tm = tic54x_optab; tm->name; tm++)
109
339M
  {
110
339M
    if (tm->opcode == (memdata & tm->mask))
111
3.61M
    {
112
      /* a few opcodes span two words */
113
3.61M
      if (tm->flags & FL_EXT)
114
70.6k
        {
115
          /* if lk addressing is used, the second half of the opcode gets
116
             pushed one word later */
117
70.6k
          bfd_byte opbuf[2];
118
70.6k
          bfd_vma addr2 = addr + 1 + has_lkaddr (memdata, tm);
119
70.6k
          int status = (*info->read_memory_func) (addr2, opbuf, 2, info);
120
          /* FIXME handle errors.  */
121
70.6k
          if (status == 0)
122
70.6k
            {
123
70.6k
              unsigned short data2 = bfd_getl16 (opbuf);
124
70.6k
              if (tm->opcode2 == (data2 & tm->mask2))
125
455
                {
126
455
                  if (size) *size = get_insn_size (memdata, tm);
127
455
                  return tm;
128
455
                }
129
70.6k
            }
130
70.6k
        }
131
3.54M
      else
132
3.54M
        {
133
3.54M
          if (size) *size = get_insn_size (memdata, tm);
134
3.54M
          return tm;
135
3.54M
        }
136
3.61M
    }
137
339M
  }
138
2.11M
  for (tm = (insn_template *) tic54x_paroptab; tm->name; tm++)
139
2.08M
  {
140
2.08M
    if (tm->opcode == (memdata & tm->mask))
141
203k
    {
142
203k
      if (size) *size = get_insn_size (memdata, tm);
143
203k
      return tm;
144
203k
    }
145
2.08M
  }
146
147
36.6k
  if (size) *size = 1;
148
36.6k
  return &tic54x_unknown_opcode;
149
239k
}
150
151
static int
152
get_insn_size (unsigned short memdata, const insn_template *insn)
153
3.74M
{
154
3.74M
  int size;
155
156
3.74M
  if (insn->flags & FL_PAR)
157
203k
    {
158
      /* only non-parallel instructions support lk addressing */
159
203k
      size = insn->words;
160
203k
    }
161
3.54M
  else
162
3.54M
    {
163
3.54M
      size = insn->words + has_lkaddr (memdata, insn);
164
3.54M
    }
165
166
3.74M
  return size;
167
3.74M
}
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
3.98M
{
178
3.98M
  static int n;
179
  /* string storage for multiple operands */
180
3.98M
  char operand[4][64] = { {0},{0},{0},{0}, };
181
3.98M
  bfd_byte buf[2];
182
3.98M
  unsigned long opcode2 = 0;
183
3.98M
  unsigned long lkaddr = 0;
184
3.98M
  enum optype src = OP_None;
185
3.98M
  enum optype dst = OP_None;
186
3.98M
  int i, shift;
187
3.98M
  char *comma = "";
188
189
3.98M
  info->fprintf_func (info->stream, "%-7s", tm_name);
190
191
3.98M
  if (size > 1)
192
531k
    {
193
531k
      int status = (*info->read_memory_func) (memaddr + 1, buf, 2, info);
194
531k
      if (status != 0)
195
126
        return 0;
196
531k
      lkaddr = opcode2 = bfd_getl16 (buf);
197
531k
      if (size > 2)
198
15.1k
        {
199
15.1k
          status = (*info->read_memory_func) (memaddr + 2, buf, 2, info);
200
15.1k
          if (status != 0)
201
8
            return 0;
202
15.1k
          opcode2 = bfd_getl16 (buf);
203
15.1k
        }
204
531k
    }
205
206
12.4M
  for (i = 0; i < MAX_OPERANDS && OPTYPE (tm_operands[i]) != OP_None; i++)
207
8.49M
    {
208
8.49M
      char *next_comma = ",";
209
8.49M
      int optional = (tm_operands[i] & OPT) != 0;
210
211
8.49M
      switch (OPTYPE (tm_operands[i]))
212
8.49M
        {
213
450k
        case OP_Xmem:
214
450k
          sprint_dual_address (info, operand[i], XMEM (opcode));
215
450k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
216
450k
          break;
217
356k
        case OP_Ymem:
218
356k
          sprint_dual_address (info, operand[i], YMEM (opcode));
219
356k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
220
356k
          break;
221
2.56M
        case OP_Smem:
222
2.59M
        case OP_Sind:
223
2.71M
        case OP_Lmem:
224
2.71M
          info->fprintf_func (info->stream, "%s", comma);
225
2.71M
          if (INDIRECT (opcode))
226
496k
            {
227
496k
              if (MOD (opcode) >= 12)
228
185k
                {
229
185k
                  bfd_vma addr = lkaddr;
230
185k
                  int arf = ARF (opcode);
231
185k
                  int mod = MOD (opcode);
232
185k
                  if (mod == 15)
233
66.9k
                      info->fprintf_func (info->stream, "*(");
234
119k
                  else
235
119k
                      info->fprintf_func (info->stream, "*%sar%d(",
236
119k
                                          (mod == 13 || mod == 14 ? "+" : ""),
237
119k
                                          arf);
238
185k
                  (*(info->print_address_func)) ((bfd_vma) addr, info);
239
185k
                  info->fprintf_func (info->stream, ")%s",
240
185k
                                      mod == 14 ? "%" : "");
241
185k
                }
242
310k
              else
243
310k
                {
244
310k
                  sprint_indirect_address (info, operand[i], opcode);
245
310k
                  info->fprintf_func (info->stream, "%s", operand[i]);
246
310k
                }
247
496k
            }
248
2.22M
          else
249
2.22M
          {
250
            /* FIXME -- use labels (print_address_func) */
251
            /* in order to do this, we need to guess what DP is */
252
2.22M
            sprint_direct_address (info, operand[i], opcode);
253
2.22M
            info->fprintf_func (info->stream, "%s", operand[i]);
254
2.22M
          }
255
2.71M
          break;
256
59.4k
        case OP_dmad:
257
59.4k
          info->fprintf_func (info->stream, "%s", comma);
258
59.4k
          (*(info->print_address_func)) ((bfd_vma) opcode2, info);
259
59.4k
          break;
260
22.4k
        case OP_xpmad:
261
          /* upper 7 bits of address are in the opcode */
262
22.4k
          opcode2 += ((unsigned long) opcode & 0x7F) << 16;
263
          /* fall through */
264
104k
        case OP_pmad:
265
104k
          info->fprintf_func (info->stream, "%s", comma);
266
104k
          (*(info->print_address_func)) ((bfd_vma) opcode2, info);
267
104k
          break;
268
5.05k
        case OP_MMRX:
269
5.05k
          sprint_mmr (info, operand[i], MMRX (opcode));
270
5.05k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
271
5.05k
          break;
272
5.05k
        case OP_MMRY:
273
5.05k
          sprint_mmr (info, operand[i], MMRY (opcode));
274
5.05k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
275
5.05k
          break;
276
224k
        case OP_MMR:
277
224k
          sprint_mmr (info, operand[i], MMR (opcode));
278
224k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
279
224k
          break;
280
31.6k
        case OP_PA:
281
31.6k
          sprintf (operand[i], "pa%d", (unsigned) opcode2);
282
31.6k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
283
31.6k
          break;
284
453k
        case OP_SRC:
285
453k
          src = SRC (ext ? opcode2 : opcode) ? OP_B : OP_A;
286
453k
          sprintf (operand[i], (src == OP_B) ? "b" : "a");
287
453k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
288
453k
          break;
289
1.98M
        case OP_SRC1:
290
1.98M
          src = SRC1 (ext ? opcode2 : opcode) ? OP_B : OP_A;
291
1.98M
          sprintf (operand[i], (src == OP_B) ? "b" : "a");
292
1.98M
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
293
1.98M
          break;
294
32.8k
        case OP_RND:
295
32.8k
          dst = DST (opcode) ? OP_B : OP_A;
296
32.8k
          sprintf (operand[i], (dst == OP_B) ? "a" : "b");
297
32.8k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
298
32.8k
          break;
299
1.01M
        case OP_DST:
300
1.01M
          dst = DST (ext ? opcode2 : opcode) ? OP_B : OP_A;
301
1.01M
          if (!optional || dst != src)
302
874k
            {
303
874k
              sprintf (operand[i], (dst == OP_B) ? "b" : "a");
304
874k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
305
874k
            }
306
136k
          else
307
136k
            next_comma = comma;
308
1.01M
          break;
309
21.0k
        case OP_B:
310
21.0k
          sprintf (operand[i], "b");
311
21.0k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
312
21.0k
          break;
313
663
        case OP_A:
314
663
          sprintf (operand[i], "a");
315
663
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
316
663
          break;
317
756
        case OP_ARX:
318
756
          sprintf (operand[i], "ar%d", (int) ARX (opcode));
319
756
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
320
756
          break;
321
27.9k
        case OP_SHIFT:
322
27.9k
          shift = SHIFT (ext ? opcode2 : opcode);
323
27.9k
          if (!optional || shift != 0)
324
23.6k
            {
325
23.6k
              sprintf (operand[i], "%d", shift);
326
23.6k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
327
23.6k
            }
328
4.26k
          else
329
4.26k
            next_comma = comma;
330
27.9k
          break;
331
56.5k
        case OP_SHFT:
332
56.5k
          shift = SHFT (opcode);
333
56.5k
          if (!optional || shift != 0)
334
56.0k
            {
335
56.0k
              sprintf (operand[i], "%d", (unsigned) shift);
336
56.0k
              info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
337
56.0k
            }
338
480
          else
339
480
            next_comma = comma;
340
56.5k
          break;
341
158k
        case OP_lk:
342
158k
          sprintf (operand[i], "#%d", (int) (short) opcode2);
343
158k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
344
158k
          break;
345
31.4k
        case OP_T:
346
31.4k
          sprintf (operand[i], "t");
347
31.4k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
348
31.4k
          break;
349
84.4k
        case OP_TS:
350
84.4k
          sprintf (operand[i], "ts");
351
84.4k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
352
84.4k
          break;
353
5.13k
        case OP_k8:
354
5.13k
          sprintf (operand[i], "%d", (int) ((signed char) (opcode & 0xFF)));
355
5.13k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
356
5.13k
          break;
357
92.6k
        case OP_16:
358
92.6k
          sprintf (operand[i], "16");
359
92.6k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
360
92.6k
          break;
361
48.9k
        case OP_ASM:
362
48.9k
          sprintf (operand[i], "asm");
363
48.9k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
364
48.9k
          break;
365
6.48k
        case OP_BITC:
366
6.48k
          sprintf (operand[i], "%d", (int) (opcode & 0xF));
367
6.48k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
368
6.48k
          break;
369
200k
        case OP_CC:
370
          /* put all CC operands in the same operand */
371
200k
          sprint_condition (info, operand[i], opcode);
372
200k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
373
200k
          i = MAX_OPERANDS;
374
200k
          break;
375
34.5k
        case OP_CC2:
376
34.5k
          sprint_cc2 (info, operand[i], opcode);
377
34.5k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
378
34.5k
          break;
379
756
        case OP_CC3:
380
756
        {
381
756
          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
756
    sprintf (operand[i], "%s", code[CC3 (opcode)]);
386
756
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
387
756
          break;
388
22.4k
        }
389
59
        case OP_123:
390
59
          {
391
59
            int code = (opcode >> 8) & 0x3;
392
59
            sprintf (operand[i], "%d", (code == 0) ? 1 : (code == 2) ? 2 : 3);
393
59
            info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
394
59
            break;
395
22.4k
          }
396
672
        case OP_k5:
397
672
          sprintf (operand[i], "#%d", ((opcode & 0x1F) ^ 0x10) - 0x10);
398
672
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
399
672
          break;
400
56.6k
        case OP_k8u:
401
56.6k
          sprintf (operand[i], "#%d", (unsigned) (opcode & 0xFF));
402
56.6k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
403
56.6k
          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
5.66k
        case OP_lku:
409
5.66k
          sprintf (operand[i], "#%d", (unsigned) opcode2);
410
5.66k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
411
5.66k
          break;
412
1.41k
        case OP_N:
413
1.41k
          n = (opcode >> 9) & 0x1;
414
1.41k
          sprintf (operand[i], "st%d", n);
415
1.41k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
416
1.41k
          break;
417
1.41k
        case OP_SBIT:
418
1.41k
        {
419
1.41k
          const char *status0[] = {
420
1.41k
            "0", "1", "2", "3", "4", "5", "6", "7", "8",
421
1.41k
            "ovb", "ova", "c", "tc", "13", "14", "15"
422
1.41k
          };
423
1.41k
          const char *status1[] = {
424
1.41k
            "0", "1", "2", "3", "4",
425
1.41k
            "cmpt", "frct", "c16", "sxm", "ovm", "10",
426
1.41k
            "intm", "hm", "xf", "cpl", "braf"
427
1.41k
          };
428
1.41k
          sprintf (operand[i], "%s",
429
1.41k
                   n ? status1[SBIT (opcode)] : status0[SBIT (opcode)]);
430
1.41k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
431
1.41k
          break;
432
22.4k
        }
433
177k
        case OP_12:
434
177k
          sprintf (operand[i], "%d", (int) ((opcode >> 9) & 1) + 1);
435
177k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
436
177k
          break;
437
13.3k
        case OP_TRN:
438
13.3k
          sprintf (operand[i], "trn");
439
13.3k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
440
13.3k
          break;
441
22.4k
        case OP_DP:
442
22.4k
          sprintf (operand[i], "dp");
443
22.4k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
444
22.4k
          break;
445
14.5k
        case OP_k9:
446
          /* FIXME-- this is DP, print the original address? */
447
14.5k
          sprintf (operand[i], "#%d", (int) (opcode & 0x1FF));
448
14.5k
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
449
14.5k
          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
263
        case OP_031:
455
263
          sprintf (operand[i], "%d", (int) (opcode & 0x1F));
456
263
          info->fprintf_func (info->stream, "%s%s", comma, operand[i]);
457
263
          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
8.49M
        }
463
8.49M
      comma = next_comma;
464
8.49M
    }
465
3.98M
  return 1;
466
3.98M
}
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
203k
{
475
203k
  print_instruction (info, memaddr, opcode,
476
203k
                     ptm->name, ptm->operand_types, size, 0);
477
203k
  info->fprintf_func (info->stream, " || ");
478
203k
  return print_instruction (info, memaddr, opcode,
479
203k
                            ptm->parname, ptm->paroperand_types, size, 0);
480
203k
}
481
482
static int
483
sprint_dual_address (disassemble_info *info ATTRIBUTE_UNUSED,
484
         char buf[],
485
         unsigned short code)
486
806k
{
487
806k
  const char *formats[] = {
488
806k
    "*ar%d",
489
806k
    "*ar%d-",
490
806k
    "*ar%d+",
491
806k
    "*ar%d+0%%",
492
806k
  };
493
806k
  return sprintf (buf, formats[XMOD (code)], XARX (code));
494
806k
}
495
496
static int
497
sprint_indirect_address (disassemble_info *info ATTRIBUTE_UNUSED,
498
       char buf[],
499
       unsigned short opcode)
500
310k
{
501
310k
  const char *formats[] = {
502
310k
    "*ar%d",
503
310k
    "*ar%d-",
504
310k
    "*ar%d+",
505
310k
    "*+ar%d",
506
310k
    "*ar%d-0B",
507
310k
    "*ar%d-0",
508
310k
    "*ar%d+0",
509
310k
    "*ar%d+0B",
510
310k
    "*ar%d-%%",
511
310k
    "*ar%d-0%%",
512
310k
    "*ar%d+%%",
513
310k
    "*ar%d+0%%",
514
310k
  };
515
310k
  return sprintf (buf, formats[MOD (opcode)], ARF (opcode));
516
310k
}
517
518
static int
519
sprint_direct_address (disassemble_info *info ATTRIBUTE_UNUSED,
520
           char buf[],
521
           unsigned short opcode)
522
2.22M
{
523
  /* FIXME -- look up relocation if available */
524
2.22M
  return sprintf (buf, "DP+0x%02x", (int) (opcode & 0x7F));
525
2.22M
}
526
527
static int
528
sprint_mmr (disassemble_info *info ATTRIBUTE_UNUSED,
529
      char buf[],
530
      int mmr)
531
234k
{
532
234k
  const tic54x_symbol *reg = tic54x_mmregs;
533
19.1M
  while (reg->name != NULL)
534
19.0M
    {
535
19.0M
      if (mmr == reg->value)
536
111k
        {
537
111k
          sprintf (buf, "%s", (reg + 1)->name);
538
111k
          return 1;
539
111k
        }
540
18.8M
      ++reg;
541
18.8M
    }
542
123k
  sprintf (buf, "MMR(%d)", mmr); /* FIXME -- different targets.  */
543
123k
  return 0;
544
234k
}
545
546
static int
547
sprint_cc2 (disassemble_info *info ATTRIBUTE_UNUSED,
548
      char *buf,
549
      unsigned short opcode)
550
34.5k
{
551
34.5k
  const char *cc2[] = {
552
34.5k
    "??", "??", "ageq", "alt", "aneq", "aeq", "agt", "aleq",
553
34.5k
    "??", "??", "bgeq", "blt", "bneq", "beq", "bgt", "bleq",
554
34.5k
  };
555
34.5k
  return sprintf (buf, "%s", cc2[opcode & 0xF]);
556
34.5k
}
557
558
static int
559
sprint_condition (disassemble_info *info ATTRIBUTE_UNUSED,
560
      char *buf,
561
      unsigned short opcode)
562
200k
{
563
200k
  char *start = buf;
564
200k
  const char *cmp[] = {
565
200k
      "??", "??", "geq", "lt", "neq", "eq", "gt", "leq"
566
200k
  };
567
200k
  if (opcode & 0x40)
568
140k
    {
569
140k
      char acc = (opcode & 0x8) ? 'b' : 'a';
570
140k
      if (opcode & 0x7)
571
136k
          buf += sprintf (buf, "%c%s%s", acc, cmp[(opcode & 0x7)],
572
136k
                          (opcode & 0x20) ? ", " : "");
573
140k
      if (opcode & 0x20)
574
132k
          buf += sprintf (buf, "%c%s", acc, (opcode & 0x10) ? "ov" : "nov");
575
140k
    }
576
59.8k
  else if (opcode & 0x3F)
577
30.1k
    {
578
30.1k
      if (opcode & 0x30)
579
16.8k
        buf += sprintf (buf, "%s%s",
580
16.8k
                        ((opcode & 0x30) == 0x30) ? "tc" : "ntc",
581
16.8k
                        (opcode & 0x0F) ? ", " : "");
582
30.1k
      if (opcode & 0x0C)
583
18.9k
        buf += sprintf (buf, "%s%s",
584
18.9k
                        ((opcode & 0x0C) == 0x0C) ? "c" : "nc",
585
18.9k
                        (opcode & 0x03) ? ", " : "");
586
30.1k
      if (opcode & 0x03)
587
24.1k
        buf += sprintf (buf, "%s",
588
24.1k
                        ((opcode & 0x03) == 0x03) ? "bio" : "nbio");
589
30.1k
    }
590
29.7k
  else
591
29.7k
    buf += sprintf (buf, "unc");
592
593
200k
  return buf - start;
594
200k
}