Coverage Report

Created: 2026-03-10 08:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/visium-dis.c
Line
Count
Source
1
/* Single instruction disassembler for the Visium.
2
3
   Copyright (C) 2002-2026 Free Software Foundation, Inc.
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 program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include "disassemble.h"
24
#include "opcode/visium.h"
25
26
#include <string.h>
27
#include <stdlib.h>
28
#include <stdio.h>
29
#include <ctype.h>
30
#include <setjmp.h>
31
32
/* Maximum length of an instruction.  */
33
#define MAXLEN 4
34
35
struct private
36
{
37
  /* Points to first byte not fetched.  */
38
  bfd_byte *max_fetched;
39
  bfd_byte the_buffer[MAXLEN];
40
  bfd_vma insn_start;
41
  jmp_buf bailout;
42
};
43
44
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
45
   to ADDR (exclusive) are valid.  Returns 1 for success, longjmps
46
   on error.  */
47
#define FETCH_DATA(info, addr) \
48
477k
  ((addr) <= ((struct private *)(info->private_data))->max_fetched \
49
477k
   ? 1 : fetch_data ((info), (addr)))
50
51
static int fetch_data (struct disassemble_info *info, bfd_byte * addr);
52
53
static int
54
fetch_data (struct disassemble_info *info, bfd_byte *addr)
55
477k
{
56
477k
  int status;
57
477k
  struct private *priv = (struct private *) info->private_data;
58
477k
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
59
60
477k
  status = (*info->read_memory_func) (start,
61
477k
              priv->max_fetched,
62
477k
              addr - priv->max_fetched, info);
63
477k
  if (status != 0)
64
289
    {
65
289
      (*info->memory_error_func) (status, start, info);
66
289
      longjmp (priv->bailout, 1);
67
289
    }
68
477k
  else
69
477k
    priv->max_fetched = addr;
70
477k
  return 1;
71
477k
}
72
73
static char *size_names[] = { "?", "b", "w", "?", "l", "?", "?", "?" };
74
75
static char *cc_names[] =
76
{
77
  "fa", "eq", "cs", "os", "ns", "ne", "cc", "oc",
78
  "nc", "ge", "gt", "hi", "le", "ls", "lt", "tr"
79
};
80
81
/* Disassemble non-storage relative instructions.  */
82
83
static int
84
disassem_class0 (disassemble_info *info, unsigned int ins)
85
113k
{
86
113k
  int opcode = (ins >> 21) & 0x000f;
87
88
113k
  if (ins & CLASS0_UNUSED_MASK)
89
63.7k
    goto illegal_opcode;
90
91
50.0k
  switch (opcode)
92
50.0k
    {
93
42.5k
    case 0:
94
      /* BRR instruction.  */
95
42.5k
      {
96
42.5k
  unsigned cbf = (ins >> 27) & 0x000f;
97
42.5k
  int displacement = ((ins & 0xffff) ^ 0x8000) - 0x8000;
98
99
42.5k
  if (ins == 0)
100
26.3k
    (*info->fprintf_func) (info->stream, "nop");
101
16.1k
  else
102
16.1k
    (*info->fprintf_func) (info->stream, "brr     %s,%+d",
103
16.1k
         cc_names[cbf], displacement);
104
42.5k
      }
105
42.5k
      break;
106
812
    case 1:
107
      /* Illegal opcode.  */
108
812
      goto illegal_opcode;
109
0
      break;
110
611
    case 2:
111
      /* Illegal opcode.  */
112
611
      goto illegal_opcode;
113
0
      break;
114
921
    case 3:
115
      /* Illegal opcode.  */
116
921
      goto illegal_opcode;
117
0
      break;
118
736
    case 4:
119
      /* Illegal opcode.  */
120
736
      goto illegal_opcode;
121
0
      break;
122
475
    case 5:
123
      /* Illegal opcode.  */
124
475
      goto illegal_opcode;
125
0
      break;
126
1.32k
    case 6:
127
      /* Illegal opcode.  */
128
1.32k
      goto illegal_opcode;
129
0
      break;
130
254
    case 7:
131
      /* Illegal opcode.  */
132
254
      goto illegal_opcode;
133
0
      break;
134
1.95k
    case 8:
135
      /* Illegal opcode.  */
136
1.95k
      goto illegal_opcode;
137
0
      break;
138
97
    case 9:
139
      /* Illegal opcode.  */
140
97
      goto illegal_opcode;
141
0
      break;
142
40
    case 10:
143
      /* Illegal opcode.  */
144
40
      goto illegal_opcode;
145
0
      break;
146
61
    case 11:
147
      /* Illegal opcode.  */
148
61
      goto illegal_opcode;
149
0
      break;
150
101
    case 12:
151
      /* Illegal opcode.  */
152
101
      goto illegal_opcode;
153
0
      break;
154
16
    case 13:
155
      /* Illegal opcode.  */
156
16
      goto illegal_opcode;
157
0
      break;
158
67
    case 14:
159
      /* Illegal opcode.  */
160
67
      goto illegal_opcode;
161
0
      break;
162
91
    case 15:
163
      /* Illegal opcode.  */
164
91
      goto illegal_opcode;
165
0
      break;
166
50.0k
    }
167
42.5k
  return 0;
168
169
71.3k
 illegal_opcode:
170
71.3k
  return -1;
171
50.0k
}
172
173
/* Disassemble non-storage register class instructions.   */
174
175
static int
176
disassem_class1 (disassemble_info *info, unsigned int ins)
177
51.0k
{
178
51.0k
  int opcode = (ins >> 21) & 0xf;
179
51.0k
  int source_a = (ins >> 16) & 0x1f;
180
51.0k
  int source_b = (ins >> 4) & 0x1f;
181
51.0k
  int indx = (ins >> 10) & 0x1f;
182
183
51.0k
  int size = ins & 0x7;
184
185
51.0k
  if (ins & CLASS1_UNUSED_MASK)
186
28.0k
    goto illegal_opcode;
187
188
22.9k
  switch (opcode)
189
22.9k
    {
190
3.66k
    case 0:
191
      /* Stop.  */
192
3.66k
      (*info->fprintf_func) (info->stream, "stop    %d,r%d", indx, source_a);
193
3.66k
      break;
194
987
    case 1:
195
      /* BMI - Block Move Indirect.  */
196
987
      if (ins != BMI)
197
926
  goto illegal_opcode;
198
199
61
      (*info->fprintf_func) (info->stream, "bmi     r1,r2,r3");
200
61
      break;
201
765
    case 2:
202
      /* Illegal opcode.  */
203
765
      goto illegal_opcode;
204
0
      break;
205
1.53k
    case 3:
206
      /* BMD - Block Move Direct.  */
207
1.53k
      if (ins != BMD)
208
1.49k
  goto illegal_opcode;
209
210
35
      (*info->fprintf_func) (info->stream, "bmd     r1,r2,r3");
211
35
      break;
212
893
    case 4:
213
      /* DSI - Disable Interrupts.  */
214
893
      if (ins != DSI)
215
880
  goto illegal_opcode;
216
217
13
      (*info->fprintf_func) (info->stream, "dsi");
218
13
      break;
219
220
723
    case 5:
221
      /* ENI - Enable Interrupts.  */
222
723
      if (ins != ENI)
223
646
  goto illegal_opcode;
224
225
77
      (*info->fprintf_func) (info->stream, "eni");
226
77
      break;
227
228
1.02k
    case 6:
229
      /* Illegal opcode (was EUT).  */
230
1.02k
      goto illegal_opcode;
231
0
      break;
232
928
    case 7:
233
      /* RFI - Return from Interrupt.  */
234
928
      if (ins != RFI)
235
910
  goto illegal_opcode;
236
237
18
      (*info->fprintf_func) (info->stream, "rfi");
238
18
      break;
239
3.16k
    case 8:
240
      /* Illegal opcode.  */
241
3.16k
      goto illegal_opcode;
242
0
      break;
243
1.12k
    case 9:
244
      /* Illegal opcode.  */
245
1.12k
      goto illegal_opcode;
246
0
      break;
247
743
    case 10:
248
      /* Illegal opcode.  */
249
743
      goto illegal_opcode;
250
0
      break;
251
1.76k
    case 11:
252
      /* Illegal opcode.  */
253
1.76k
      goto illegal_opcode;
254
0
      break;
255
1.18k
    case 12:
256
      /* Illegal opcode.  */
257
1.18k
      goto illegal_opcode;
258
0
      break;
259
568
    case 13:
260
568
      goto illegal_opcode;
261
0
      break;
262
766
    case 14:
263
766
      goto illegal_opcode;
264
0
      break;
265
3.17k
    case 15:
266
3.17k
      if (ins & EAM_SELECT_MASK)
267
2.10k
  {
268
    /* Extension arithmetic module write */
269
2.10k
    int fp_ins = (ins >> 27) & 0xf;
270
271
2.10k
    if (size != 4)
272
422
      goto illegal_opcode;
273
274
1.68k
    if (ins & FP_SELECT_MASK)
275
668
      {
276
        /* Which floating point instructions don't need a fsrcB
277
           register.  */
278
668
        const int no_fsrcb[16] = { 1, 0, 0, 0, 0, 1, 1, 1,
279
668
    1, 1, 0, 0, 1, 0, 0, 0
280
668
        };
281
668
        if (no_fsrcb[fp_ins] && source_b)
282
60
    goto illegal_opcode;
283
284
        /* Check that none of the floating register register numbers
285
           is higher than 15. (If this is fload, then srcA is a
286
           general register.  */
287
608
        if (ins & ((1 << 14) | (1 << 8)) || (fp_ins && ins & (1 << 20)))
288
137
    goto illegal_opcode;
289
290
471
        switch (fp_ins)
291
471
    {
292
18
    case 0:
293
18
      (*info->fprintf_func) (info->stream, "fload   f%d,r%d",
294
18
           indx, source_a);
295
18
      break;
296
48
    case 1:
297
48
      (*info->fprintf_func) (info->stream, "fadd    f%d,f%d,f%d",
298
48
           indx, source_a, source_b);
299
48
      break;
300
95
    case 2:
301
95
      (*info->fprintf_func) (info->stream, "fsub    f%d,f%d,f%d",
302
95
           indx, source_a, source_b);
303
95
      break;
304
0
    case 3:
305
0
      (*info->fprintf_func) (info->stream, "fmult   f%d,f%d,f%d",
306
0
           indx, source_a, source_b);
307
0
      break;
308
40
    case 4:
309
40
      (*info->fprintf_func) (info->stream, "fdiv    f%d,f%d,f%d",
310
40
           indx, source_a, source_b);
311
40
      break;
312
102
    case 5:
313
102
      (*info->fprintf_func) (info->stream, "fsqrt   f%d,f%d",
314
102
           indx, source_a);
315
102
      break;
316
69
    case 6:
317
69
      (*info->fprintf_func) (info->stream, "fneg    f%d,f%d",
318
69
           indx, source_a);
319
69
      break;
320
9
    case 7:
321
9
      (*info->fprintf_func) (info->stream, "fabs    f%d,f%d",
322
9
           indx, source_a);
323
9
      break;
324
10
    case 8:
325
10
      (*info->fprintf_func) (info->stream, "ftoi    f%d,f%d",
326
10
           indx, source_a);
327
10
      break;
328
15
    case 9:
329
15
      (*info->fprintf_func) (info->stream, "itof    f%d,f%d",
330
15
           indx, source_a);
331
15
      break;
332
20
    case 12:
333
20
      (*info->fprintf_func) (info->stream, "fmove   f%d,f%d",
334
20
           indx, source_a);
335
20
      break;
336
45
    default:
337
45
      (*info->fprintf_func) (info->stream,
338
45
           "fpinst  %d,f%d,f%d,f%d", fp_ins,
339
45
           indx, source_a, source_b);
340
45
      break;
341
471
    }
342
471
      }
343
1.01k
    else
344
1.01k
      {
345
        /* Which EAM operations do not need a srcB register.  */
346
1.01k
        const int no_srcb[32] =
347
1.01k
        { 0, 0, 1, 1, 0, 1, 1, 1,
348
1.01k
    0, 1, 1, 1, 0, 0, 0, 0,
349
1.01k
    0, 0, 0, 0, 0, 0, 0, 0,
350
1.01k
    0, 0, 0, 0, 0, 0, 0, 0
351
1.01k
        };
352
353
1.01k
        if (no_srcb[indx] && source_b)
354
44
    goto illegal_opcode;
355
356
972
        if (fp_ins)
357
55
    goto illegal_opcode;
358
359
917
        switch (indx)
360
917
    {
361
11
    case 0:
362
11
      (*info->fprintf_func) (info->stream, "mults   r%d,r%d",
363
11
           source_a, source_b);
364
11
      break;
365
103
    case 1:
366
103
      (*info->fprintf_func) (info->stream, "multu   r%d,r%d",
367
103
           source_a, source_b);
368
103
      break;
369
42
    case 2:
370
42
      (*info->fprintf_func) (info->stream, "divs    r%d",
371
42
           source_a);
372
42
      break;
373
0
    case 3:
374
0
      (*info->fprintf_func) (info->stream, "divu    r%d",
375
0
           source_a);
376
0
      break;
377
65
    case 4:
378
65
      (*info->fprintf_func) (info->stream, "writemd r%d,r%d",
379
65
           source_a, source_b);
380
65
      break;
381
10
    case 5:
382
10
      (*info->fprintf_func) (info->stream, "writemdc r%d",
383
10
           source_a);
384
10
      break;
385
0
    case 6:
386
0
      (*info->fprintf_func) (info->stream, "divds   r%d",
387
0
           source_a);
388
0
      break;
389
15
    case 7:
390
15
      (*info->fprintf_func) (info->stream, "divdu   r%d",
391
15
           source_a);
392
15
      break;
393
0
    case 9:
394
0
      (*info->fprintf_func) (info->stream, "asrd    r%d",
395
0
           source_a);
396
0
      break;
397
35
    case 10:
398
35
      (*info->fprintf_func) (info->stream, "lsrd    r%d",
399
35
           source_a);
400
35
      break;
401
40
    case 11:
402
40
      (*info->fprintf_func) (info->stream, "asld    r%d",
403
40
           source_a);
404
40
      break;
405
596
    default:
406
596
      (*info->fprintf_func) (info->stream,
407
596
           "eamwrite %d,r%d,r%d", indx,
408
596
           source_a, source_b);
409
596
      break;
410
917
    }
411
917
      }
412
1.68k
  }
413
1.07k
      else
414
1.07k
  {
415
    /* WRITE - write to memory.  */
416
1.07k
    (*info->fprintf_func) (info->stream, "write.%s %d(r%d),r%d",
417
1.07k
         size_names[size], indx, source_a, source_b);
418
1.07k
  }
419
2.45k
      break;
420
22.9k
    }
421
422
6.32k
  return 0;
423
424
44.6k
 illegal_opcode:
425
44.6k
  return -1;
426
22.9k
}
427
428
/* Disassemble storage immediate class instructions.   */
429
430
static int
431
disassem_class2 (disassemble_info *info, unsigned int ins)
432
52.8k
{
433
52.8k
  int opcode = (ins >> 21) & 0xf;
434
52.8k
  int source_a = (ins >> 16) & 0x1f;
435
52.8k
  unsigned immediate = ins & 0x0000ffff;
436
437
52.8k
  if (ins & CC_MASK)
438
42.3k
    goto illegal_opcode;
439
440
10.5k
  switch (opcode)
441
10.5k
    {
442
851
    case 0:
443
      /* ADDI instruction.  */
444
851
      (*info->fprintf_func) (info->stream, "addi    r%d,%d", source_a,
445
851
           immediate);
446
851
      break;
447
843
    case 1:
448
      /* Illegal opcode.  */
449
843
      goto illegal_opcode;
450
0
      break;
451
307
    case 2:
452
      /* SUBI instruction.  */
453
307
      (*info->fprintf_func) (info->stream, "subi    r%d,%d", source_a,
454
307
           immediate);
455
307
      break;
456
292
    case 3:
457
      /* Illegal opcode.  */
458
292
      goto illegal_opcode;
459
0
      break;
460
694
    case 4:
461
      /* MOVIL instruction.  */
462
694
      (*info->fprintf_func) (info->stream, "movil   r%d,0x%04X", source_a,
463
694
           immediate);
464
694
      break;
465
533
    case 5:
466
      /* MOVIU instruction.  */
467
533
      (*info->fprintf_func) (info->stream, "moviu   r%d,0x%04X", source_a,
468
533
           immediate);
469
533
      break;
470
148
    case 6:
471
      /* MOVIQ instruction.  */
472
148
      (*info->fprintf_func) (info->stream, "moviq   r%d,%u", source_a,
473
148
           immediate);
474
148
      break;
475
534
    case 7:
476
      /* Illegal opcode.  */
477
534
      goto illegal_opcode;
478
0
      break;
479
1.82k
    case 8:
480
      /* WRTL instruction.  */
481
1.82k
      if (source_a != 0)
482
1.30k
  goto illegal_opcode;
483
484
523
      (*info->fprintf_func) (info->stream, "wrtl    0x%04X", immediate);
485
523
      break;
486
252
    case 9:
487
      /* WRTU instruction.  */
488
252
      if (source_a != 0)
489
217
  goto illegal_opcode;
490
491
35
      (*info->fprintf_func) (info->stream, "wrtu    0x%04X", immediate);
492
35
      break;
493
484
    case 10:
494
      /* Illegal opcode.  */
495
484
      goto illegal_opcode;
496
0
      break;
497
107
    case 11:
498
      /* Illegal opcode.  */
499
107
      goto illegal_opcode;
500
0
      break;
501
2.66k
    case 12:
502
      /* Illegal opcode.  */
503
2.66k
      goto illegal_opcode;
504
0
      break;
505
446
    case 13:
506
      /* Illegal opcode.  */
507
446
      goto illegal_opcode;
508
0
      break;
509
129
    case 14:
510
      /* Illegal opcode.  */
511
129
      goto illegal_opcode;
512
0
      break;
513
402
    case 15:
514
      /* Illegal opcode.  */
515
402
      goto illegal_opcode;
516
0
      break;
517
10.5k
    }
518
519
3.09k
  return 0;
520
521
49.7k
 illegal_opcode:
522
49.7k
  return -1;
523
10.5k
}
524
525
/* Disassemble storage register class instructions.  */
526
527
static int
528
disassem_class3 (disassemble_info *info, unsigned int ins)
529
77.3k
{
530
77.3k
  int opcode = (ins >> 21) & 0xf;
531
77.3k
  int source_b = (ins >> 4) & 0x1f;
532
77.3k
  int source_a = (ins >> 16) & 0x1f;
533
77.3k
  int size = ins & 0x7;
534
77.3k
  int dest = (ins >> 10) & 0x1f;
535
536
  /* Those instructions that don't have a srcB register.  */
537
77.3k
  const int no_srcb[16] =
538
77.3k
  { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 };
539
540
  /* These are instructions which can take an immediate srcB value.  */
541
77.3k
  const int srcb_immed[16] =
542
77.3k
  { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 };
543
544
  /* User opcodes should not provide a non-zero srcB register
545
     when none is required. Only a BRA or floating point
546
     instruction should have a non-zero condition code field.
547
     Only a WRITE or EAMWRITE (opcode 15) should select an EAM
548
     or floating point operation.  Note that FP_SELECT_MASK is
549
     the same bit (bit 3) as the interrupt bit which
550
     distinguishes SYS1 from BRA and SYS2 from RFLAG.  */
551
77.3k
  if ((no_srcb[opcode] && source_b)
552
64.5k
      || (!srcb_immed[opcode] && ins & CLASS3_SOURCEB_IMMED)
553
47.9k
      || (opcode != 12 && opcode != 15 && ins & CC_MASK)
554
29.9k
      || (opcode != 15 && ins & (EAM_SELECT_MASK | FP_SELECT_MASK)))
555
48.5k
    goto illegal_opcode;
556
557
558
28.7k
  switch (opcode)
559
28.7k
    {
560
299
    case 0:
561
      /* ADD instruction.  */
562
299
      (*info->fprintf_func) (info->stream, "add.%s   r%d,r%d,r%d",
563
299
           size_names[size], dest, source_a, source_b);
564
299
      break;
565
132
    case 1:
566
      /* ADC instruction.  */
567
132
      (*info->fprintf_func) (info->stream, "adc.%s   r%d,r%d,r%d",
568
132
           size_names[size], dest, source_a, source_b);
569
132
      break;
570
61
    case 2:
571
      /* SUB instruction.  */
572
61
      if (dest == 0)
573
30
  (*info->fprintf_func) (info->stream, "cmp.%s   r%d,r%d",
574
30
             size_names[size], source_a, source_b);
575
31
      else
576
31
  (*info->fprintf_func) (info->stream, "sub.%s   r%d,r%d,r%d",
577
31
             size_names[size], dest, source_a, source_b);
578
61
      break;
579
289
    case 3:
580
      /* SUBC instruction.  */
581
289
      if (dest == 0)
582
172
  (*info->fprintf_func) (info->stream, "cmpc.%s  r%d,r%d",
583
172
             size_names[size], source_a, source_b);
584
117
      else
585
117
  (*info->fprintf_func) (info->stream, "subc.%s  r%d,r%d,r%d",
586
117
             size_names[size], dest, source_a, source_b);
587
289
      break;
588
115
    case 4:
589
      /* EXTW instruction.  */
590
115
      if (size == 1)
591
23
  goto illegal_opcode;
592
593
92
      (*info->fprintf_func) (info->stream, "extw.%s  r%d,r%d",
594
92
           size_names[size], dest, source_a);
595
92
      break;
596
183
    case 5:
597
      /* ASR instruction.  */
598
183
      if (ins & CLASS3_SOURCEB_IMMED)
599
68
  (*info->fprintf_func) (info->stream, "asr.%s   r%d,r%d,%d",
600
68
             size_names[size], dest, source_a, source_b);
601
115
      else
602
115
  (*info->fprintf_func) (info->stream, "asr.%s   r%d,r%d,r%d",
603
115
             size_names[size], dest, source_a, source_b);
604
183
      break;
605
334
    case 6:
606
      /* LSR instruction.  */
607
334
      if (ins & CLASS3_SOURCEB_IMMED)
608
278
  (*info->fprintf_func) (info->stream, "lsr.%s   r%d,r%d,%d",
609
278
             size_names[size], dest, source_a, source_b);
610
56
      else
611
56
  (*info->fprintf_func) (info->stream, "lsr.%s   r%d,r%d,r%d",
612
56
             size_names[size], dest, source_a, source_b);
613
334
      break;
614
100
    case 7:
615
      /* ASL instruction.  */
616
100
      if (ins & CLASS3_SOURCEB_IMMED)
617
55
  (*info->fprintf_func) (info->stream, "asl.%s   r%d,r%d,%d",
618
55
             size_names[size], dest, source_a, source_b);
619
45
      else
620
45
  (*info->fprintf_func) (info->stream, "asl.%s   r%d,r%d,r%d",
621
45
             size_names[size], dest, source_a, source_b);
622
100
      break;
623
275
    case 8:
624
      /* XOR instruction.  */
625
275
      (*info->fprintf_func) (info->stream, "xor.%s   r%d,r%d,r%d",
626
275
           size_names[size], dest, source_a, source_b);
627
275
      break;
628
133
    case 9:
629
      /* OR instruction.  */
630
133
      if (source_b == 0)
631
76
  (*info->fprintf_func) (info->stream, "move.%s  r%d,r%d",
632
76
             size_names[size], dest, source_a);
633
57
      else
634
57
  (*info->fprintf_func) (info->stream, "or.%s    r%d,r%d,r%d",
635
57
             size_names[size], dest, source_a, source_b);
636
133
      break;
637
58
    case 10:
638
      /* AND instruction.  */
639
58
      (*info->fprintf_func) (info->stream, "and.%s   r%d,r%d,r%d",
640
58
           size_names[size], dest, source_a, source_b);
641
58
      break;
642
71
    case 11:
643
      /* NOT instruction.  */
644
71
      (*info->fprintf_func) (info->stream, "not.%s   r%d,r%d",
645
71
           size_names[size], dest, source_a);
646
71
      break;
647
301
    case 12:
648
      /* BRA instruction.  */
649
301
      {
650
301
  unsigned cbf = (ins >> 27) & 0x000f;
651
652
301
  if (size != 4)
653
298
    goto illegal_opcode;
654
655
3
  (*info->fprintf_func) (info->stream, "bra     %s,r%d,r%d",
656
3
             cc_names[cbf], source_a, dest);
657
3
      }
658
0
      break;
659
170
    case 13:
660
      /* RFLAG instruction.  */
661
170
      if (source_a || size != 4)
662
83
  goto illegal_opcode;
663
664
87
      (*info->fprintf_func) (info->stream, "rflag   r%d", dest);
665
87
      break;
666
51
    case 14:
667
      /* EXTB instruction.  */
668
51
      (*info->fprintf_func) (info->stream, "extb.%s  r%d,r%d",
669
51
           size_names[size], dest, source_a);
670
51
      break;
671
26.1k
    case 15:
672
26.1k
      if (!(ins & CLASS3_SOURCEB_IMMED))
673
2.70k
  goto illegal_opcode;
674
675
23.4k
      if (ins & EAM_SELECT_MASK)
676
22.4k
  {
677
    /* Extension arithmetic module read.  */
678
22.4k
    int fp_ins = (ins >> 27) & 0xf;
679
680
22.4k
    if (size != 4)
681
21.8k
      goto illegal_opcode;
682
683
656
    if (ins & FP_SELECT_MASK)
684
227
      {
685
        /* Check fsrcA <= 15 and fsrcB <= 15.  */
686
227
        if (ins & ((1 << 20) | (1 << 8)))
687
183
    goto illegal_opcode;
688
689
44
        switch (fp_ins)
690
44
    {
691
0
    case 0:
692
0
      if (source_b)
693
0
        goto illegal_opcode;
694
695
0
      (*info->fprintf_func) (info->stream, "fstore  r%d,f%d",
696
0
           dest, source_a);
697
0
      break;
698
0
    case 10:
699
0
      (*info->fprintf_func) (info->stream, "fcmp    r%d,f%d,f%d",
700
0
           dest, source_a, source_b);
701
0
      break;
702
3
    case 11:
703
3
      (*info->fprintf_func) (info->stream, "fcmpe   r%d,f%d,f%d",
704
3
           dest, source_a, source_b);
705
3
      break;
706
41
    default:
707
41
      (*info->fprintf_func) (info->stream,
708
41
           "fpuread %d,r%d,f%d,f%d", fp_ins,
709
41
           dest, source_a, source_b);
710
41
      break;
711
44
    }
712
44
      }
713
429
    else
714
429
      {
715
429
        if (fp_ins || source_a)
716
429
    goto illegal_opcode;
717
718
0
        switch (source_b)
719
0
    {
720
0
    case 0:
721
0
      (*info->fprintf_func) (info->stream, "readmda r%d", dest);
722
0
      break;
723
0
    case 1:
724
0
      (*info->fprintf_func) (info->stream, "readmdb r%d", dest);
725
0
      break;
726
0
    case 2:
727
0
      (*info->fprintf_func) (info->stream, "readmdc r%d", dest);
728
0
      break;
729
0
    default:
730
0
      (*info->fprintf_func) (info->stream, "eamread r%d,%d",
731
0
           dest, source_b);
732
0
      break;
733
0
    }
734
0
      }
735
656
  }
736
1.01k
      else
737
1.01k
  {
738
1.01k
    if (ins & FP_SELECT_MASK)
739
438
      goto illegal_opcode;
740
741
    /* READ instruction.  */
742
579
    (*info->fprintf_func) (info->stream, "read.%s  r%d,%d(r%d)",
743
579
         size_names[size], dest, source_b, source_a);
744
579
  }
745
623
      break;
746
28.7k
    }
747
748
2.79k
  return 0;
749
750
74.5k
 illegal_opcode:
751
74.5k
  return -1;
752
753
28.7k
}
754
755
/* Print the visium instruction at address addr in debugged memory,
756
   on info->stream. Return length of the instruction, in bytes.  */
757
758
int
759
print_insn_visium (bfd_vma addr, disassemble_info *info)
760
477k
{
761
477k
  unsigned ins;
762
477k
  unsigned p1, p2;
763
477k
  int ans;
764
477k
  int i;
765
766
  /* Stuff copied from m68k-dis.c.  */
767
477k
  struct private priv;
768
477k
  bfd_byte *buffer = priv.the_buffer;
769
477k
  info->private_data = &priv;
770
477k
  priv.max_fetched = priv.the_buffer;
771
477k
  priv.insn_start = addr;
772
477k
  if (setjmp (priv.bailout) != 0)
773
289
    {
774
      /* Error return.  */
775
289
      return -1;
776
289
    }
777
778
  /* We do return this info.  */
779
477k
  info->insn_info_valid = 1;
780
781
  /* Assume non branch insn.  */
782
477k
  info->insn_type = dis_nonbranch;
783
784
  /* Assume no delay.  */
785
477k
  info->branch_delay_insns = 0;
786
787
  /* Assume no target known.  */
788
477k
  info->target = 0;
789
790
  /* Get 32-bit instruction word.  */
791
477k
  FETCH_DATA (info, buffer + 4);
792
477k
  ins = (unsigned) buffer[0] << 24;
793
477k
  ins |= buffer[1] << 16;
794
477k
  ins |= buffer[2] << 8;
795
477k
  ins |= buffer[3];
796
797
477k
  ans = 0;
798
799
477k
  p1 = buffer[0] ^ buffer[1] ^ buffer[2] ^ buffer[3];
800
477k
  p2 = 0;
801
4.29M
  for (i = 0; i < 8; i++)
802
3.81M
    {
803
3.81M
      p2 += p1 & 1;
804
3.81M
      p1 >>= 1;
805
3.81M
    }
806
807
  /* Decode the instruction.  */
808
477k
  if (p2 & 1)
809
182k
    ans = -1;
810
294k
  else
811
294k
    {
812
294k
      switch ((ins >> 25) & 0x3)
813
294k
  {
814
113k
  case 0:
815
113k
    ans = disassem_class0 (info, ins);
816
113k
    break;
817
51.0k
  case 1:
818
51.0k
    ans = disassem_class1 (info, ins);
819
51.0k
    break;
820
52.8k
  case 2:
821
52.8k
    ans = disassem_class2 (info, ins);
822
52.8k
    break;
823
77.3k
  case 3:
824
77.3k
    ans = disassem_class3 (info, ins);
825
77.3k
    break;
826
294k
  }
827
294k
    }
828
829
477k
  if (ans != 0)
830
422k
    (*info->fprintf_func) (info->stream, "err");
831
832
  /* Return number of bytes consumed (always 4 for the Visium).  */
833
477k
  return 4;
834
477k
}