Coverage Report

Created: 2023-08-28 06:30

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