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