Coverage Report

Created: 2026-10-02 09:53

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