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