OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [opcodes/] [hppa-dis.c] - Blame information for rev 165

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Disassembler for the PA-RISC. Somewhat derived from sparc-pinsn.c.
2
   Copyright 1989, 1990, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2003,
3
   2005, 2007  Free Software Foundation, Inc.
4
 
5
   Contributed by the Center for Software Science at the
6
   University of Utah (pa-gdb-bugs@cs.utah.edu).
7
 
8
   This file is part of the GNU opcodes library.
9
 
10
   This library is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3, or (at your option)
13
   any later version.
14
 
15
   It is distributed in the hope that it will be useful, but WITHOUT
16
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18
   License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program; if not, write to the Free Software
22
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23
   MA 02110-1301, USA.  */
24
 
25
#include "sysdep.h"
26
#include "dis-asm.h"
27
#include "libhppa.h"
28
#include "opcode/hppa.h"
29
 
30
/* Integer register names, indexed by the numbers which appear in the
31
   opcodes.  */
32
static const char *const reg_names[] =
33
{
34
  "flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
35
  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
36
  "r20", "r21", "r22", "r23", "r24", "r25", "r26", "dp", "ret0", "ret1",
37
  "sp", "r31"
38
};
39
 
40
/* Floating point register names, indexed by the numbers which appear in the
41
   opcodes.  */
42
static const char *const fp_reg_names[] =
43
{
44
  "fpsr", "fpe2", "fpe4", "fpe6",
45
  "fr4", "fr5", "fr6", "fr7", "fr8",
46
  "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
47
  "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",
48
  "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"
49
};
50
 
51
typedef unsigned int CORE_ADDR;
52
 
53
/* Get at various relevent fields of an instruction word.  */
54
 
55
#define MASK_5  0x1f
56
#define MASK_10 0x3ff
57
#define MASK_11 0x7ff
58
#define MASK_14 0x3fff
59
#define MASK_16 0xffff
60
#define MASK_21 0x1fffff
61
 
62
/* These macros get bit fields using HP's numbering (MSB = 0).  */
63
 
64
#define GET_FIELD(X, FROM, TO) \
65
  ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
66
 
67
#define GET_BIT(X, WHICH) \
68
  GET_FIELD (X, WHICH, WHICH)
69
 
70
/* Some of these have been converted to 2-d arrays because they
71
   consume less storage this way.  If the maintenance becomes a
72
   problem, convert them back to const 1-d pointer arrays.  */
73
static const char *const control_reg[] =
74
{
75
  "rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
76
  "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
77
  "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
78
  "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
79
  "tr4", "tr5", "tr6", "tr7"
80
};
81
 
82
static const char *const compare_cond_names[] =
83
{
84
  "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od",
85
  ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev"
86
};
87
static const char *const compare_cond_64_names[] =
88
{
89
  "", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od",
90
  ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev"
91
};
92
static const char *const cmpib_cond_64_names[] =
93
{
94
  ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>"
95
};
96
static const char *const add_cond_names[] =
97
{
98
  "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od",
99
  ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev"
100
};
101
static const char *const add_cond_64_names[] =
102
{
103
  "", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od",
104
  ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev"
105
};
106
static const char *const wide_add_cond_names[] =
107
{
108
  "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=",
109
  ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>"
110
};
111
static const char *const logical_cond_names[] =
112
{
113
  "", ",=", ",<", ",<=", 0, 0, 0, ",od",
114
  ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
115
static const char *const logical_cond_64_names[] =
116
{
117
  "", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od",
118
  ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"};
119
static const char *const unit_cond_names[] =
120
{
121
  "", ",swz", ",sbz", ",shz", ",sdc", ",swc", ",sbc", ",shc",
122
  ",tr", ",nwz", ",nbz", ",nhz", ",ndc", ",nwc", ",nbc", ",nhc"
123
};
124
static const char *const unit_cond_64_names[] =
125
{
126
  "", ",*swz", ",*sbz", ",*shz", ",*sdc", ",*swc", ",*sbc", ",*shc",
127
  ",*tr", ",*nwz", ",*nbz", ",*nhz", ",*ndc", ",*nwc", ",*nbc", ",*nhc"
128
};
129
static const char *const shift_cond_names[] =
130
{
131
  "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
132
};
133
static const char *const shift_cond_64_names[] =
134
{
135
  "", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev"
136
};
137
static const char *const bb_cond_64_names[] =
138
{
139
  ",*<", ",*>="
140
};
141
static const char *const index_compl_names[] = {"", ",m", ",s", ",sm"};
142
static const char *const short_ldst_compl_names[] = {"", ",ma", "", ",mb"};
143
static const char *const short_bytes_compl_names[] =
144
{
145
  "", ",b,m", ",e", ",e,m"
146
};
147
static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
148
static const char *const fcnv_fixed_names[] = {",w", ",dw", "", ",qw"};
149
static const char *const fcnv_ufixed_names[] = {",uw", ",udw", "", ",uqw"};
150
static const char *const float_comp_names[] =
151
{
152
  ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
153
  ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
154
  ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
155
  ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
156
};
157
static const char *const signed_unsigned_names[] = {",u", ",s"};
158
static const char *const mix_half_names[] = {",l", ",r"};
159
static const char *const saturation_names[] = {",us", ",ss", 0, ""};
160
static const char *const read_write_names[] = {",r", ",w"};
161
static const char *const add_compl_names[] = { 0, "", ",l", ",tsv" };
162
 
163
/* For a bunch of different instructions form an index into a
164
   completer name table.  */
165
#define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \
166
                         GET_FIELD (insn, 18, 18) << 1)
167
 
168
#define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \
169
                        (GET_FIELD ((insn), 19, 19) ? 8 : 0))
170
 
171
/* Utility function to print registers.  Put these first, so gcc's function
172
   inlining can do its stuff.  */
173
 
174
#define fputs_filtered(STR,F)   (*info->fprintf_func) (info->stream, "%s", STR)
175
 
176
static void
177
fput_reg (unsigned reg, disassemble_info *info)
178
{
179
  (*info->fprintf_func) (info->stream, reg ? reg_names[reg] : "r0");
180
}
181
 
182
static void
183
fput_fp_reg (unsigned reg, disassemble_info *info)
184
{
185
  (*info->fprintf_func) (info->stream, reg ? fp_reg_names[reg] : "fr0");
186
}
187
 
188
static void
189
fput_fp_reg_r (unsigned reg, disassemble_info *info)
190
{
191
  /* Special case floating point exception registers.  */
192
  if (reg < 4)
193
    (*info->fprintf_func) (info->stream, "fpe%d", reg * 2 + 1);
194
  else
195
    (*info->fprintf_func) (info->stream, "%sR",
196
                           reg ? fp_reg_names[reg] : "fr0");
197
}
198
 
199
static void
200
fput_creg (unsigned reg, disassemble_info *info)
201
{
202
  (*info->fprintf_func) (info->stream, control_reg[reg]);
203
}
204
 
205
/* Print constants with sign.  */
206
 
207
static void
208
fput_const (unsigned num, disassemble_info *info)
209
{
210
  if ((int) num < 0)
211
    (*info->fprintf_func) (info->stream, "-%x", - (int) num);
212
  else
213
    (*info->fprintf_func) (info->stream, "%x", num);
214
}
215
 
216
/* Routines to extract various sized constants out of hppa
217
   instructions.  */
218
 
219
/* Extract a 3-bit space register number from a be, ble, mtsp or mfsp.  */
220
static int
221
extract_3 (unsigned word)
222
{
223
  return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
224
}
225
 
226
static int
227
extract_5_load (unsigned word)
228
{
229
  return low_sign_extend (word >> 16 & MASK_5, 5);
230
}
231
 
232
/* Extract the immediate field from a st{bhw}s instruction.  */
233
 
234
static int
235
extract_5_store (unsigned word)
236
{
237
  return low_sign_extend (word & MASK_5, 5);
238
}
239
 
240
/* Extract the immediate field from a break instruction.  */
241
 
242
static unsigned
243
extract_5r_store (unsigned word)
244
{
245
  return (word & MASK_5);
246
}
247
 
248
/* Extract the immediate field from a {sr}sm instruction.  */
249
 
250
static unsigned
251
extract_5R_store (unsigned word)
252
{
253
  return (word >> 16 & MASK_5);
254
}
255
 
256
/* Extract the 10 bit immediate field from a {sr}sm instruction.  */
257
 
258
static unsigned
259
extract_10U_store (unsigned word)
260
{
261
  return (word >> 16 & MASK_10);
262
}
263
 
264
/* Extract the immediate field from a bb instruction.  */
265
 
266
static unsigned
267
extract_5Q_store (unsigned word)
268
{
269
  return (word >> 21 & MASK_5);
270
}
271
 
272
/* Extract an 11 bit immediate field.  */
273
 
274
static int
275
extract_11 (unsigned word)
276
{
277
  return low_sign_extend (word & MASK_11, 11);
278
}
279
 
280
/* Extract a 14 bit immediate field.  */
281
 
282
static int
283
extract_14 (unsigned word)
284
{
285
  return low_sign_extend (word & MASK_14, 14);
286
}
287
 
288
/* Extract a 16 bit immediate field (PA2.0 wide only).  */
289
 
290
static int
291
extract_16 (unsigned word)
292
{
293
  int m15, m0, m1;
294
 
295
  m0 = GET_BIT (word, 16);
296
  m1 = GET_BIT (word, 17);
297
  m15 = GET_BIT (word, 31);
298
  word = (word >> 1) & 0x1fff;
299
  word = word | (m15 << 15) | ((m15 ^ m0) << 14) | ((m15 ^ m1) << 13);
300
  return sign_extend (word, 16);
301
}
302
 
303
/* Extract a 21 bit constant.  */
304
 
305
static int
306
extract_21 (unsigned word)
307
{
308
  int val;
309
 
310
  word &= MASK_21;
311
  word <<= 11;
312
  val = GET_FIELD (word, 20, 20);
313
  val <<= 11;
314
  val |= GET_FIELD (word, 9, 19);
315
  val <<= 2;
316
  val |= GET_FIELD (word, 5, 6);
317
  val <<= 5;
318
  val |= GET_FIELD (word, 0, 4);
319
  val <<= 2;
320
  val |= GET_FIELD (word, 7, 8);
321
  return sign_extend (val, 21) << 11;
322
}
323
 
324
/* Extract a 12 bit constant from branch instructions.  */
325
 
326
static int
327
extract_12 (unsigned word)
328
{
329
  return sign_extend (GET_FIELD (word, 19, 28)
330
                      | GET_FIELD (word, 29, 29) << 10
331
                      | (word & 0x1) << 11, 12) << 2;
332
}
333
 
334
/* Extract a 17 bit constant from branch instructions, returning the
335
   19 bit signed value.  */
336
 
337
static int
338
extract_17 (unsigned word)
339
{
340
  return sign_extend (GET_FIELD (word, 19, 28)
341
                      | GET_FIELD (word, 29, 29) << 10
342
                      | GET_FIELD (word, 11, 15) << 11
343
                      | (word & 0x1) << 16, 17) << 2;
344
}
345
 
346
static int
347
extract_22 (unsigned word)
348
{
349
  return sign_extend (GET_FIELD (word, 19, 28)
350
                      | GET_FIELD (word, 29, 29) << 10
351
                      | GET_FIELD (word, 11, 15) << 11
352
                      | GET_FIELD (word, 6, 10) << 16
353
                      | (word & 0x1) << 21, 22) << 2;
354
}
355
 
356
/* Print one instruction.  */
357
 
358
int
359
print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
360
{
361
  bfd_byte buffer[4];
362
  unsigned int insn, i;
363
 
364
  {
365
    int status =
366
      (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
367
    if (status != 0)
368
      {
369
        (*info->memory_error_func) (status, memaddr, info);
370
        return -1;
371
      }
372
  }
373
 
374
  insn = bfd_getb32 (buffer);
375
 
376
  for (i = 0; i < NUMOPCODES; ++i)
377
    {
378
      const struct pa_opcode *opcode = &pa_opcodes[i];
379
 
380
      if ((insn & opcode->mask) == opcode->match)
381
        {
382
          const char *s;
383
#ifndef BFD64
384
          if (opcode->arch == pa20w)
385
            continue;
386
#endif
387
          (*info->fprintf_func) (info->stream, "%s", opcode->name);
388
 
389
          if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
390
            (*info->fprintf_func) (info->stream, " ");
391
          for (s = opcode->args; *s != '\0'; ++s)
392
            {
393
              switch (*s)
394
                {
395
                case 'x':
396
                  fput_reg (GET_FIELD (insn, 11, 15), info);
397
                  break;
398
                case 'a':
399
                case 'b':
400
                  fput_reg (GET_FIELD (insn, 6, 10), info);
401
                  break;
402
                case '^':
403
                  fput_creg (GET_FIELD (insn, 6, 10), info);
404
                  break;
405
                case 't':
406
                  fput_reg (GET_FIELD (insn, 27, 31), info);
407
                  break;
408
 
409
                  /* Handle floating point registers.  */
410
                case 'f':
411
                  switch (*++s)
412
                    {
413
                    case 't':
414
                      fput_fp_reg (GET_FIELD (insn, 27, 31), info);
415
                      break;
416
                    case 'T':
417
                      if (GET_FIELD (insn, 25, 25))
418
                        fput_fp_reg_r (GET_FIELD (insn, 27, 31), info);
419
                      else
420
                        fput_fp_reg (GET_FIELD (insn, 27, 31), info);
421
                      break;
422
                    case 'a':
423
                      if (GET_FIELD (insn, 25, 25))
424
                        fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
425
                      else
426
                        fput_fp_reg (GET_FIELD (insn, 6, 10), info);
427
                      break;
428
 
429
                      /* 'fA' will not generate a space before the regsiter
430
                         name.  Normally that is fine.  Except that it
431
                         causes problems with xmpyu which has no FP format
432
                         completer.  */
433
                    case 'X':
434
                      fputs_filtered (" ", info);
435
                      /* FALLTHRU */
436
 
437
                    case 'A':
438
                      if (GET_FIELD (insn, 24, 24))
439
                        fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
440
                      else
441
                        fput_fp_reg (GET_FIELD (insn, 6, 10), info);
442
                      break;
443
                    case 'b':
444
                      if (GET_FIELD (insn, 25, 25))
445
                        fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
446
                      else
447
                        fput_fp_reg (GET_FIELD (insn, 11, 15), info);
448
                      break;
449
                    case 'B':
450
                      if (GET_FIELD (insn, 19, 19))
451
                        fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
452
                      else
453
                        fput_fp_reg (GET_FIELD (insn, 11, 15), info);
454
                      break;
455
                    case 'C':
456
                      {
457
                        int reg = GET_FIELD (insn, 21, 22);
458
                        reg |= GET_FIELD (insn, 16, 18) << 2;
459
                        if (GET_FIELD (insn, 23, 23) != 0)
460
                          fput_fp_reg_r (reg, info);
461
                        else
462
                          fput_fp_reg (reg, info);
463
                        break;
464
                      }
465
                    case 'i':
466
                      {
467
                        int reg = GET_FIELD (insn, 6, 10);
468
 
469
                        reg |= (GET_FIELD (insn, 26, 26) << 4);
470
                        fput_fp_reg (reg, info);
471
                        break;
472
                      }
473
                    case 'j':
474
                      {
475
                        int reg = GET_FIELD (insn, 11, 15);
476
 
477
                        reg |= (GET_FIELD (insn, 26, 26) << 4);
478
                        fput_fp_reg (reg, info);
479
                        break;
480
                      }
481
                    case 'k':
482
                      {
483
                        int reg = GET_FIELD (insn, 27, 31);
484
 
485
                        reg |= (GET_FIELD (insn, 26, 26) << 4);
486
                        fput_fp_reg (reg, info);
487
                        break;
488
                      }
489
                    case 'l':
490
                      {
491
                        int reg = GET_FIELD (insn, 21, 25);
492
 
493
                        reg |= (GET_FIELD (insn, 26, 26) << 4);
494
                        fput_fp_reg (reg, info);
495
                        break;
496
                      }
497
                    case 'm':
498
                      {
499
                        int reg = GET_FIELD (insn, 16, 20);
500
 
501
                        reg |= (GET_FIELD (insn, 26, 26) << 4);
502
                        fput_fp_reg (reg, info);
503
                        break;
504
                      }
505
 
506
                      /* 'fe' will not generate a space before the register
507
                         name.  Normally that is fine.  Except that it
508
                         causes problems with fstw fe,y(b) which has no FP
509
                         format completer.  */
510
                    case 'E':
511
                      fputs_filtered (" ", info);
512
                      /* FALLTHRU */
513
 
514
                    case 'e':
515
                      if (GET_FIELD (insn, 30, 30))
516
                        fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
517
                      else
518
                        fput_fp_reg (GET_FIELD (insn, 11, 15), info);
519
                      break;
520
                    case 'x':
521
                      fput_fp_reg (GET_FIELD (insn, 11, 15), info);
522
                      break;
523
                    }
524
                  break;
525
 
526
                case '5':
527
                  fput_const (extract_5_load (insn), info);
528
                  break;
529
                case 's':
530
                  {
531
                    int space = GET_FIELD (insn, 16, 17);
532
                    /* Zero means implicit addressing, not use of sr0.  */
533
                    if (space != 0)
534
                      (*info->fprintf_func) (info->stream, "sr%d", space);
535
                  }
536
                  break;
537
 
538
                case 'S':
539
                  (*info->fprintf_func) (info->stream, "sr%d",
540
                                         extract_3 (insn));
541
                  break;
542
 
543
                  /* Handle completers.  */
544
                case 'c':
545
                  switch (*++s)
546
                    {
547
                    case 'x':
548
                      (*info->fprintf_func)
549
                        (info->stream, "%s",
550
                         index_compl_names[GET_COMPL (insn)]);
551
                      break;
552
                    case 'X':
553
                      (*info->fprintf_func)
554
                        (info->stream, "%s ",
555
                         index_compl_names[GET_COMPL (insn)]);
556
                      break;
557
                    case 'm':
558
                      (*info->fprintf_func)
559
                        (info->stream, "%s",
560
                         short_ldst_compl_names[GET_COMPL (insn)]);
561
                      break;
562
                    case 'M':
563
                      (*info->fprintf_func)
564
                        (info->stream, "%s ",
565
                         short_ldst_compl_names[GET_COMPL (insn)]);
566
                      break;
567
                    case 'A':
568
                      (*info->fprintf_func)
569
                        (info->stream, "%s ",
570
                         short_bytes_compl_names[GET_COMPL (insn)]);
571
                      break;
572
                    case 's':
573
                      (*info->fprintf_func)
574
                        (info->stream, "%s",
575
                         short_bytes_compl_names[GET_COMPL (insn)]);
576
                      break;
577
                    case 'c':
578
                    case 'C':
579
                      switch (GET_FIELD (insn, 20, 21))
580
                        {
581
                        case 1:
582
                          (*info->fprintf_func) (info->stream, ",bc ");
583
                          break;
584
                        case 2:
585
                          (*info->fprintf_func) (info->stream, ",sl ");
586
                          break;
587
                        default:
588
                          (*info->fprintf_func) (info->stream, " ");
589
                        }
590
                      break;
591
                    case 'd':
592
                      switch (GET_FIELD (insn, 20, 21))
593
                        {
594
                        case 1:
595
                          (*info->fprintf_func) (info->stream, ",co ");
596
                          break;
597
                        default:
598
                          (*info->fprintf_func) (info->stream, " ");
599
                        }
600
                      break;
601
                    case 'o':
602
                      (*info->fprintf_func) (info->stream, ",o");
603
                      break;
604
                    case 'g':
605
                      (*info->fprintf_func) (info->stream, ",gate");
606
                      break;
607
                    case 'p':
608
                      (*info->fprintf_func) (info->stream, ",l,push");
609
                      break;
610
                    case 'P':
611
                      (*info->fprintf_func) (info->stream, ",pop");
612
                      break;
613
                    case 'l':
614
                    case 'L':
615
                      (*info->fprintf_func) (info->stream, ",l");
616
                      break;
617
                    case 'w':
618
                      (*info->fprintf_func)
619
                        (info->stream, "%s ",
620
                         read_write_names[GET_FIELD (insn, 25, 25)]);
621
                      break;
622
                    case 'W':
623
                      (*info->fprintf_func) (info->stream, ",w ");
624
                      break;
625
                    case 'r':
626
                      if (GET_FIELD (insn, 23, 26) == 5)
627
                        (*info->fprintf_func) (info->stream, ",r");
628
                      break;
629
                    case 'Z':
630
                      if (GET_FIELD (insn, 26, 26))
631
                        (*info->fprintf_func) (info->stream, ",m ");
632
                      else
633
                        (*info->fprintf_func) (info->stream, " ");
634
                      break;
635
                    case 'i':
636
                      if (GET_FIELD (insn, 25, 25))
637
                        (*info->fprintf_func) (info->stream, ",i");
638
                      break;
639
                    case 'z':
640
                      if (!GET_FIELD (insn, 21, 21))
641
                        (*info->fprintf_func) (info->stream, ",z");
642
                      break;
643
                    case 'a':
644
                      (*info->fprintf_func)
645
                        (info->stream, "%s",
646
                         add_compl_names[GET_FIELD (insn, 20, 21)]);
647
                      break;
648
                    case 'Y':
649
                      (*info->fprintf_func)
650
                        (info->stream, ",dc%s",
651
                         add_compl_names[GET_FIELD (insn, 20, 21)]);
652
                      break;
653
                    case 'y':
654
                      (*info->fprintf_func)
655
                        (info->stream, ",c%s",
656
                         add_compl_names[GET_FIELD (insn, 20, 21)]);
657
                      break;
658
                    case 'v':
659
                      if (GET_FIELD (insn, 20, 20))
660
                        (*info->fprintf_func) (info->stream, ",tsv");
661
                      break;
662
                    case 't':
663
                      (*info->fprintf_func) (info->stream, ",tc");
664
                      if (GET_FIELD (insn, 20, 20))
665
                        (*info->fprintf_func) (info->stream, ",tsv");
666
                      break;
667
                    case 'B':
668
                      (*info->fprintf_func) (info->stream, ",db");
669
                      if (GET_FIELD (insn, 20, 20))
670
                        (*info->fprintf_func) (info->stream, ",tsv");
671
                      break;
672
                    case 'b':
673
                      (*info->fprintf_func) (info->stream, ",b");
674
                      if (GET_FIELD (insn, 20, 20))
675
                        (*info->fprintf_func) (info->stream, ",tsv");
676
                      break;
677
                    case 'T':
678
                      if (GET_FIELD (insn, 25, 25))
679
                        (*info->fprintf_func) (info->stream, ",tc");
680
                      break;
681
                    case 'S':
682
                      /* EXTRD/W has a following condition.  */
683
                      if (*(s + 1) == '?')
684
                        (*info->fprintf_func)
685
                          (info->stream, "%s",
686
                           signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
687
                      else
688
                        (*info->fprintf_func)
689
                          (info->stream, "%s ",
690
                           signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
691
                      break;
692
                    case 'h':
693
                      (*info->fprintf_func)
694
                        (info->stream, "%s",
695
                         mix_half_names[GET_FIELD (insn, 17, 17)]);
696
                      break;
697
                    case 'H':
698
                      (*info->fprintf_func)
699
                        (info->stream, "%s ",
700
                         saturation_names[GET_FIELD (insn, 24, 25)]);
701
                      break;
702
                    case '*':
703
                      (*info->fprintf_func)
704
                        (info->stream, ",%d%d%d%d ",
705
                         GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
706
                         GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
707
                      break;
708
 
709
                    case 'q':
710
                      {
711
                        int m, a;
712
 
713
                        m = GET_FIELD (insn, 28, 28);
714
                        a = GET_FIELD (insn, 29, 29);
715
 
716
                        if (m && !a)
717
                          fputs_filtered (",ma ", info);
718
                        else if (m && a)
719
                          fputs_filtered (",mb ", info);
720
                        else
721
                          fputs_filtered (" ", info);
722
                        break;
723
                      }
724
 
725
                    case 'J':
726
                      {
727
                        int opc = GET_FIELD (insn, 0, 5);
728
 
729
                        if (opc == 0x16 || opc == 0x1e)
730
                          {
731
                            if (GET_FIELD (insn, 29, 29) == 0)
732
                              fputs_filtered (",ma ", info);
733
                            else
734
                              fputs_filtered (",mb ", info);
735
                          }
736
                        else
737
                          fputs_filtered (" ", info);
738
                        break;
739
                      }
740
 
741
                    case 'e':
742
                      {
743
                        int opc = GET_FIELD (insn, 0, 5);
744
 
745
                        if (opc == 0x13 || opc == 0x1b)
746
                          {
747
                            if (GET_FIELD (insn, 18, 18) == 1)
748
                              fputs_filtered (",mb ", info);
749
                            else
750
                              fputs_filtered (",ma ", info);
751
                          }
752
                        else if (opc == 0x17 || opc == 0x1f)
753
                          {
754
                            if (GET_FIELD (insn, 31, 31) == 1)
755
                              fputs_filtered (",ma ", info);
756
                            else
757
                              fputs_filtered (",mb ", info);
758
                          }
759
                        else
760
                          fputs_filtered (" ", info);
761
 
762
                        break;
763
                      }
764
                    }
765
                  break;
766
 
767
                  /* Handle conditions.  */
768
                case '?':
769
                  {
770
                    s++;
771
                    switch (*s)
772
                      {
773
                      case 'f':
774
                        (*info->fprintf_func)
775
                          (info->stream, "%s ",
776
                           float_comp_names[GET_FIELD (insn, 27, 31)]);
777
                        break;
778
 
779
                        /* These four conditions are for the set of instructions
780
                           which distinguish true/false conditions by opcode
781
                           rather than by the 'f' bit (sigh): comb, comib,
782
                           addb, addib.  */
783
                      case 't':
784
                        fputs_filtered
785
                          (compare_cond_names[GET_FIELD (insn, 16, 18)], info);
786
                        break;
787
                      case 'n':
788
                        fputs_filtered
789
                          (compare_cond_names[GET_FIELD (insn, 16, 18)
790
                                              + GET_FIELD (insn, 4, 4) * 8],
791
                           info);
792
                        break;
793
                      case 'N':
794
                        fputs_filtered
795
                          (compare_cond_64_names[GET_FIELD (insn, 16, 18)
796
                                                 + GET_FIELD (insn, 2, 2) * 8],
797
                           info);
798
                        break;
799
                      case 'Q':
800
                        fputs_filtered
801
                          (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
802
                           info);
803
                        break;
804
                      case '@':
805
                        fputs_filtered
806
                          (add_cond_names[GET_FIELD (insn, 16, 18)
807
                                          + GET_FIELD (insn, 4, 4) * 8],
808
                           info);
809
                        break;
810
                      case 's':
811
                        (*info->fprintf_func)
812
                          (info->stream, "%s ",
813
                           compare_cond_names[GET_COND (insn)]);
814
                        break;
815
                      case 'S':
816
                        (*info->fprintf_func)
817
                          (info->stream, "%s ",
818
                           compare_cond_64_names[GET_COND (insn)]);
819
                        break;
820
                      case 'a':
821
                        (*info->fprintf_func)
822
                          (info->stream, "%s ",
823
                           add_cond_names[GET_COND (insn)]);
824
                        break;
825
                      case 'A':
826
                        (*info->fprintf_func)
827
                          (info->stream, "%s ",
828
                           add_cond_64_names[GET_COND (insn)]);
829
                        break;
830
                      case 'd':
831
                        (*info->fprintf_func)
832
                          (info->stream, "%s",
833
                           add_cond_names[GET_FIELD (insn, 16, 18)]);
834
                        break;
835
 
836
                      case 'W':
837
                        (*info->fprintf_func)
838
                          (info->stream, "%s",
839
                           wide_add_cond_names[GET_FIELD (insn, 16, 18) +
840
                                               GET_FIELD (insn, 4, 4) * 8]);
841
                        break;
842
 
843
                      case 'l':
844
                        (*info->fprintf_func)
845
                          (info->stream, "%s ",
846
                           logical_cond_names[GET_COND (insn)]);
847
                        break;
848
                      case 'L':
849
                        (*info->fprintf_func)
850
                          (info->stream, "%s ",
851
                           logical_cond_64_names[GET_COND (insn)]);
852
                        break;
853
                      case 'u':
854
                        (*info->fprintf_func)
855
                          (info->stream, "%s ",
856
                           unit_cond_names[GET_COND (insn)]);
857
                        break;
858
                      case 'U':
859
                        (*info->fprintf_func)
860
                          (info->stream, "%s ",
861
                           unit_cond_64_names[GET_COND (insn)]);
862
                        break;
863
                      case 'y':
864
                      case 'x':
865
                      case 'b':
866
                        (*info->fprintf_func)
867
                          (info->stream, "%s",
868
                           shift_cond_names[GET_FIELD (insn, 16, 18)]);
869
 
870
                        /* If the next character in args is 'n', it will handle
871
                           putting out the space.  */
872
                        if (s[1] != 'n')
873
                          (*info->fprintf_func) (info->stream, " ");
874
                        break;
875
                      case 'X':
876
                        (*info->fprintf_func)
877
                          (info->stream, "%s ",
878
                           shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
879
                        break;
880
                      case 'B':
881
                        (*info->fprintf_func)
882
                          (info->stream, "%s",
883
                           bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
884
 
885
                        /* If the next character in args is 'n', it will handle
886
                           putting out the space.  */
887
                        if (s[1] != 'n')
888
                          (*info->fprintf_func) (info->stream, " ");
889
                        break;
890
                      }
891
                    break;
892
                  }
893
 
894
                case 'V':
895
                  fput_const (extract_5_store (insn), info);
896
                  break;
897
                case 'r':
898
                  fput_const (extract_5r_store (insn), info);
899
                  break;
900
                case 'R':
901
                  fput_const (extract_5R_store (insn), info);
902
                  break;
903
                case 'U':
904
                  fput_const (extract_10U_store (insn), info);
905
                  break;
906
                case 'B':
907
                case 'Q':
908
                  fput_const (extract_5Q_store (insn), info);
909
                  break;
910
                case 'i':
911
                  fput_const (extract_11 (insn), info);
912
                  break;
913
                case 'j':
914
                  fput_const (extract_14 (insn), info);
915
                  break;
916
                case 'k':
917
                  fputs_filtered ("L%", info);
918
                  fput_const (extract_21 (insn), info);
919
                  break;
920
                case '<':
921
                case 'l':
922
                  /* 16-bit long disp., PA2.0 wide only.  */
923
                  fput_const (extract_16 (insn), info);
924
                  break;
925
                case 'n':
926
                  if (insn & 0x2)
927
                    (*info->fprintf_func) (info->stream, ",n ");
928
                  else
929
                    (*info->fprintf_func) (info->stream, " ");
930
                  break;
931
                case 'N':
932
                  if ((insn & 0x20) && s[1])
933
                    (*info->fprintf_func) (info->stream, ",n ");
934
                  else if (insn & 0x20)
935
                    (*info->fprintf_func) (info->stream, ",n");
936
                  else if (s[1])
937
                    (*info->fprintf_func) (info->stream, " ");
938
                  break;
939
                case 'w':
940
                  (*info->print_address_func)
941
                    (memaddr + 8 + extract_12 (insn), info);
942
                  break;
943
                case 'W':
944
                  /* 17 bit PC-relative branch.  */
945
                  (*info->print_address_func)
946
                    ((memaddr + 8 + extract_17 (insn)), info);
947
                  break;
948
                case 'z':
949
                  /* 17 bit displacement.  This is an offset from a register
950
                     so it gets disasssembled as just a number, not any sort
951
                     of address.  */
952
                  fput_const (extract_17 (insn), info);
953
                  break;
954
 
955
                case 'Z':
956
                  /* addil %r1 implicit output.  */
957
                  fputs_filtered ("r1", info);
958
                  break;
959
 
960
                case 'Y':
961
                  /* be,l %sr0,%r31 implicit output.  */
962
                  fputs_filtered ("sr0,r31", info);
963
                  break;
964
 
965
                case '@':
966
                  (*info->fprintf_func) (info->stream, "0");
967
                  break;
968
 
969
                case '.':
970
                  (*info->fprintf_func) (info->stream, "%d",
971
                                         GET_FIELD (insn, 24, 25));
972
                  break;
973
                case '*':
974
                  (*info->fprintf_func) (info->stream, "%d",
975
                                         GET_FIELD (insn, 22, 25));
976
                  break;
977
                case '!':
978
                  fputs_filtered ("sar", info);
979
                  break;
980
                case 'p':
981
                  (*info->fprintf_func) (info->stream, "%d",
982
                                         31 - GET_FIELD (insn, 22, 26));
983
                  break;
984
                case '~':
985
                  {
986
                    int num;
987
                    num = GET_FIELD (insn, 20, 20) << 5;
988
                    num |= GET_FIELD (insn, 22, 26);
989
                    (*info->fprintf_func) (info->stream, "%d", 63 - num);
990
                    break;
991
                  }
992
                case 'P':
993
                  (*info->fprintf_func) (info->stream, "%d",
994
                                         GET_FIELD (insn, 22, 26));
995
                  break;
996
                case 'q':
997
                  {
998
                    int num;
999
                    num = GET_FIELD (insn, 20, 20) << 5;
1000
                    num |= GET_FIELD (insn, 22, 26);
1001
                    (*info->fprintf_func) (info->stream, "%d", num);
1002
                    break;
1003
                  }
1004
                case 'T':
1005
                  (*info->fprintf_func) (info->stream, "%d",
1006
                                         32 - GET_FIELD (insn, 27, 31));
1007
                  break;
1008
                case '%':
1009
                  {
1010
                    int num;
1011
                    num = (GET_FIELD (insn, 23, 23) + 1) * 32;
1012
                    num -= GET_FIELD (insn, 27, 31);
1013
                    (*info->fprintf_func) (info->stream, "%d", num);
1014
                    break;
1015
                  }
1016
                case '|':
1017
                  {
1018
                    int num;
1019
                    num = (GET_FIELD (insn, 19, 19) + 1) * 32;
1020
                    num -= GET_FIELD (insn, 27, 31);
1021
                    (*info->fprintf_func) (info->stream, "%d", num);
1022
                    break;
1023
                  }
1024
                case '$':
1025
                  fput_const (GET_FIELD (insn, 20, 28), info);
1026
                  break;
1027
                case 'A':
1028
                  fput_const (GET_FIELD (insn, 6, 18), info);
1029
                  break;
1030
                case 'D':
1031
                  fput_const (GET_FIELD (insn, 6, 31), info);
1032
                  break;
1033
                case 'v':
1034
                  (*info->fprintf_func) (info->stream, ",%d",
1035
                                         GET_FIELD (insn, 23, 25));
1036
                  break;
1037
                case 'O':
1038
                  fput_const ((GET_FIELD (insn, 6,20) << 5 |
1039
                               GET_FIELD (insn, 27, 31)), info);
1040
                  break;
1041
                case 'o':
1042
                  fput_const (GET_FIELD (insn, 6, 20), info);
1043
                  break;
1044
                case '2':
1045
                  fput_const ((GET_FIELD (insn, 6, 22) << 5 |
1046
                               GET_FIELD (insn, 27, 31)), info);
1047
                  break;
1048
                case '1':
1049
                  fput_const ((GET_FIELD (insn, 11, 20) << 5 |
1050
                               GET_FIELD (insn, 27, 31)), info);
1051
                  break;
1052
                case '0':
1053
                  fput_const ((GET_FIELD (insn, 16, 20) << 5 |
1054
                               GET_FIELD (insn, 27, 31)), info);
1055
                  break;
1056
                case 'u':
1057
                  (*info->fprintf_func) (info->stream, ",%d",
1058
                                         GET_FIELD (insn, 23, 25));
1059
                  break;
1060
                case 'F':
1061
                  /* If no destination completer and not before a completer
1062
                     for fcmp, need a space here.  */
1063
                  if (s[1] == 'G' || s[1] == '?')
1064
                    fputs_filtered
1065
                      (float_format_names[GET_FIELD (insn, 19, 20)], info);
1066
                  else
1067
                    (*info->fprintf_func)
1068
                      (info->stream, "%s ",
1069
                       float_format_names[GET_FIELD (insn, 19, 20)]);
1070
                  break;
1071
                case 'G':
1072
                  (*info->fprintf_func)
1073
                    (info->stream, "%s ",
1074
                     float_format_names[GET_FIELD (insn, 17, 18)]);
1075
                  break;
1076
                case 'H':
1077
                  if (GET_FIELD (insn, 26, 26) == 1)
1078
                    (*info->fprintf_func) (info->stream, "%s ",
1079
                                           float_format_names[0]);
1080
                  else
1081
                    (*info->fprintf_func) (info->stream, "%s ",
1082
                                           float_format_names[1]);
1083
                  break;
1084
                case 'I':
1085
                  /* If no destination completer and not before a completer
1086
                     for fcmp, need a space here.  */
1087
                  if (s[1] == '?')
1088
                    fputs_filtered
1089
                      (float_format_names[GET_FIELD (insn, 20, 20)], info);
1090
                  else
1091
                    (*info->fprintf_func)
1092
                      (info->stream, "%s ",
1093
                       float_format_names[GET_FIELD (insn, 20, 20)]);
1094
                  break;
1095
 
1096
                case 'J':
1097
                  fput_const (extract_14 (insn), info);
1098
                  break;
1099
 
1100
                case '#':
1101
                  {
1102
                    int sign = GET_FIELD (insn, 31, 31);
1103
                    int imm10 = GET_FIELD (insn, 18, 27);
1104
                    int disp;
1105
 
1106
                    if (sign)
1107
                      disp = (-1 << 10) | imm10;
1108
                    else
1109
                      disp = imm10;
1110
 
1111
                    disp <<= 3;
1112
                    fput_const (disp, info);
1113
                    break;
1114
                  }
1115
                case 'K':
1116
                case 'd':
1117
                  {
1118
                    int sign = GET_FIELD (insn, 31, 31);
1119
                    int imm11 = GET_FIELD (insn, 18, 28);
1120
                    int disp;
1121
 
1122
                    if (sign)
1123
                      disp = (-1 << 11) | imm11;
1124
                    else
1125
                      disp = imm11;
1126
 
1127
                    disp <<= 2;
1128
                    fput_const (disp, info);
1129
                    break;
1130
                  }
1131
 
1132
                case '>':
1133
                case 'y':
1134
                  {
1135
                    /* 16-bit long disp., PA2.0 wide only.  */
1136
                    int disp = extract_16 (insn);
1137
                    disp &= ~3;
1138
                    fput_const (disp, info);
1139
                    break;
1140
                  }
1141
 
1142
                case '&':
1143
                  {
1144
                    /* 16-bit long disp., PA2.0 wide only.  */
1145
                    int disp = extract_16 (insn);
1146
                    disp &= ~7;
1147
                    fput_const (disp, info);
1148
                    break;
1149
                  }
1150
 
1151
                case '_':
1152
                  break; /* Dealt with by '{' */
1153
 
1154
                case '{':
1155
                  {
1156
                    int sub = GET_FIELD (insn, 14, 16);
1157
                    int df = GET_FIELD (insn, 17, 18);
1158
                    int sf = GET_FIELD (insn, 19, 20);
1159
                    const char * const * source = float_format_names;
1160
                    const char * const * dest = float_format_names;
1161
                    char *t = "";
1162
 
1163
                    if (sub == 4)
1164
                      {
1165
                        fputs_filtered (",UND ", info);
1166
                        break;
1167
                      }
1168
                    if ((sub & 3) == 3)
1169
                      t = ",t";
1170
                    if ((sub & 3) == 1)
1171
                      source = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
1172
                    if (sub & 2)
1173
                      dest = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
1174
 
1175
                    (*info->fprintf_func) (info->stream, "%s%s%s ",
1176
                                           t, source[sf], dest[df]);
1177
                    break;
1178
                  }
1179
 
1180
                case 'm':
1181
                  {
1182
                    int y = GET_FIELD (insn, 16, 18);
1183
 
1184
                    if (y != 1)
1185
                      fput_const ((y ^ 1) - 1, info);
1186
                  }
1187
                  break;
1188
 
1189
                case 'h':
1190
                  {
1191
                    int cbit;
1192
 
1193
                    cbit = GET_FIELD (insn, 16, 18);
1194
 
1195
                    if (cbit > 0)
1196
                      (*info->fprintf_func) (info->stream, ",%d", cbit - 1);
1197
                    break;
1198
                  }
1199
 
1200
                case '=':
1201
                  {
1202
                    int cond = GET_FIELD (insn, 27, 31);
1203
 
1204
                    switch (cond)
1205
                      {
1206
                      case  0: fputs_filtered (" ", info); break;
1207
                      case  1: fputs_filtered ("acc ", info); break;
1208
                      case  2: fputs_filtered ("rej ", info); break;
1209
                      case  5: fputs_filtered ("acc8 ", info); break;
1210
                      case  6: fputs_filtered ("rej8 ", info); break;
1211
                      case  9: fputs_filtered ("acc6 ", info); break;
1212
                      case 13: fputs_filtered ("acc4 ", info); break;
1213
                      case 17: fputs_filtered ("acc2 ", info); break;
1214
                      default: break;
1215
                      }
1216
                    break;
1217
                  }
1218
 
1219
                case 'X':
1220
                  (*info->print_address_func)
1221
                    (memaddr + 8 + extract_22 (insn), info);
1222
                  break;
1223
                case 'L':
1224
                  fputs_filtered (",rp", info);
1225
                  break;
1226
                default:
1227
                  (*info->fprintf_func) (info->stream, "%c", *s);
1228
                  break;
1229
                }
1230
            }
1231
          return sizeof (insn);
1232
        }
1233
    }
1234
  (*info->fprintf_func) (info->stream, "#%8x", insn);
1235
  return sizeof (insn);
1236
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.