* hppa-dis.c (print_insn_hppa): Handle 'J', 'K', and 'cc'.
[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 case 'e':
467 if (GET_FIELD (insn, 25, 25))
468 fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
469 else
470 fput_fp_reg (GET_FIELD (insn, 11, 15), info);
471 break;
472
473 }
474 break;
475
476 case '5':
477 fput_const (extract_5_load (insn), info);
478 break;
479 case 's':
480 (*info->fprintf_func) (info->stream,
481 "sr%d", GET_FIELD (insn, 16, 17));
482 break;
483
484 case 'S':
485 (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn));
486 break;
487
488 /* Handle completers. */
489 case 'c':
490 switch (*++s)
491 {
492 case 'x':
493 (*info->fprintf_func) (info->stream, "%s ",
494 index_compl_names[GET_COMPL (insn)]);
495 break;
496 case 'm':
497 (*info->fprintf_func) (info->stream, "%s ",
498 short_ldst_compl_names[GET_COMPL (insn)]);
499 break;
500 case 'q':
501 (*info->fprintf_func)
502 (info->stream, "%s ",
503 short_ldst_compl_names[(GET_FIELD (insn, 28, 28)
504 | GET_FIELD (insn, 29, 29))]);
505 break;
506 case 'J':
507 if (insn & 0x4)
508 (*info->fprintf_func) (info->stream, ",mb ");
509 else
510 (*info->fprintf_func) (info->stream, ",ma ");
511 break;
512 case 's':
513 (*info->fprintf_func) (info->stream, "%s ",
514 short_bytes_compl_names[GET_COMPL (insn)]);
515 break;
516 case 'L':
517 (*info->fprintf_func) (info->stream, ",l");
518 break;
519 case 'w':
520 (*info->fprintf_func) (info->stream, "%s ",
521 read_write_names[GET_FIELD (insn, 25, 25)]);
522 break;
523 case 'W':
524 (*info->fprintf_func) (info->stream, ",w");
525 break;
526 case 'r':
527 if (GET_FIELD (insn, 23, 26) == 5)
528 (*info->fprintf_func) (info->stream, ",r");
529 break;
530 case 'Z':
531 if (GET_FIELD (insn, 26, 26))
532 (*info->fprintf_func) (info->stream, ",m ");
533 else
534 (*info->fprintf_func) (info->stream, " ");
535 break;
536 case 'i':
537 if (GET_FIELD (insn, 25, 25))
538 (*info->fprintf_func) (info->stream, ",i");
539 break;
540 case 'z':
541 if (!GET_FIELD (insn, 21, 21))
542 (*info->fprintf_func) (info->stream, ",z");
543 break;
544 case 'a':
545 (*info->fprintf_func)
546 (info->stream, "%s", add_compl_names[GET_FIELD
547 (insn, 20, 21)]);
548 break;
549 case 'Y':
550 (*info->fprintf_func)
551 (info->stream, ",dc%s", add_compl_names[GET_FIELD
552 (insn, 20, 21)]);
553 break;
554 case 'y':
555 (*info->fprintf_func)
556 (info->stream, ",c%s", add_compl_names[GET_FIELD
557 (insn, 20, 21)]);
558 break;
559 case 'v':
560 if (GET_FIELD (insn, 20, 20))
561 (*info->fprintf_func) (info->stream, ",tsv");
562 break;
563 case 't':
564 (*info->fprintf_func) (info->stream, ",tc");
565 if (GET_FIELD (insn, 20, 20))
566 (*info->fprintf_func) (info->stream, ",tsv");
567 break;
568 case 'B':
569 (*info->fprintf_func) (info->stream, ",db");
570 if (GET_FIELD (insn, 20, 20))
571 (*info->fprintf_func) (info->stream, ",tsv");
572 break;
573 case 'b':
574 (*info->fprintf_func) (info->stream, ",b");
575 if (GET_FIELD (insn, 20, 20))
576 (*info->fprintf_func) (info->stream, ",tsv");
577 break;
578 case 'T':
579 if (GET_FIELD (insn, 25, 25))
580 (*info->fprintf_func) (info->stream, ",tc");
581 break;
582 case 'S':
583 /* EXTRD/W has a following condition. */
584 if (*(s + 1) == '?')
585 (*info->fprintf_func)
586 (info->stream, "%s", signed_unsigned_names[GET_FIELD
587 (insn, 21, 21)]);
588 else
589 (*info->fprintf_func)
590 (info->stream, "%s ", signed_unsigned_names[GET_FIELD
591 (insn, 21, 21)]);
592 break;
593 case 'h':
594 (*info->fprintf_func)
595 (info->stream, "%s", mix_half_names[GET_FIELD
596 (insn, 17, 17)]);
597 break;
598 case 'H':
599 (*info->fprintf_func)
600 (info->stream, "%s", saturation_names[GET_FIELD
601 (insn, 24, 25)]);
602 break;
603 case '*':
604 (*info->fprintf_func)
605 (info->stream, ",%d%d%d%d ",
606 GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
607 GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
608 break;
609 }
610 break;
611
612 /* Handle conditions. */
613 case '?':
614 {
615 s++;
616 switch (*s)
617 {
618 case 'f':
619 (*info->fprintf_func) (info->stream, "%s ",
620 float_comp_names[GET_FIELD
621 (insn, 27, 31)]);
622 break;
623
624 /* these four conditions are for the set of instructions
625 which distinguish true/false conditions by opcode
626 rather than by the 'f' bit (sigh): comb, comib,
627 addb, addib */
628 case 't':
629 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)],
630 info);
631 break;
632 case 'T':
633 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
634 + 8], info);
635 break;
636 case 'r':
637 fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)],
638 info);
639 break;
640 case 'R':
641 fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)
642 + 8], info);
643 break;
644 case 'Q':
645 fputs_filtered (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
646 info);
647 break;
648 case 'n':
649 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
650 + GET_FIELD (insn, 4, 4) * 8], info);
651 break;
652 case '@':
653 fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18)
654 + GET_FIELD (insn, 4, 4) * 8], info);
655 break;
656 case 's':
657 (*info->fprintf_func) (info->stream, "%s ",
658 compare_cond_names[GET_COND (insn)]);
659 break;
660 case 'S':
661 (*info->fprintf_func) (info->stream, "%s ",
662 compare_cond_64_names[GET_COND (insn)]);
663 break;
664 case 'a':
665 (*info->fprintf_func) (info->stream, "%s ",
666 add_cond_names[GET_COND (insn)]);
667 break;
668 case 'A':
669 (*info->fprintf_func) (info->stream, "%s ",
670 add_cond_64_names[GET_COND (insn)]);
671 break;
672 case 'd':
673 (*info->fprintf_func) (info->stream, "%s",
674 add_cond_names[GET_FIELD (insn, 16, 18)]);
675 break;
676
677 case 'D':
678 (*info->fprintf_func) (info->stream, "%s",
679 add_cond_names[GET_FIELD (insn, 16, 18)
680 + 8]);
681 break;
682 case 'w':
683 (*info->fprintf_func)
684 (info->stream, "%s",
685 wide_add_cond_names[GET_FIELD (insn, 16, 18)]);
686 break;
687
688 case 'W':
689 (*info->fprintf_func)
690 (info->stream, "%s",
691 wide_add_cond_names[GET_FIELD (insn, 16, 18) + 8]);
692 break;
693
694 case 'l':
695 (*info->fprintf_func) (info->stream, "%s ",
696 logical_cond_names[GET_COND (insn)]);
697 break;
698 case 'L':
699 (*info->fprintf_func) (info->stream, "%s ",
700 logical_cond_64_names[GET_COND (insn)]);
701 break;
702 case 'u':
703 (*info->fprintf_func) (info->stream, "%s ",
704 unit_cond_names[GET_COND (insn)]);
705 break;
706 case 'U':
707 (*info->fprintf_func) (info->stream, "%s ",
708 unit_cond_64_names[GET_COND (insn)]);
709 break;
710 case 'y':
711 case 'x':
712 case 'b':
713 (*info->fprintf_func)
714 (info->stream, "%s",
715 shift_cond_names[GET_FIELD (insn, 16, 18)]);
716
717 /* If the next character in args is 'n', it will handle
718 putting out the space. */
719 if (s[1] != 'n')
720 (*info->fprintf_func) (info->stream, " ");
721 break;
722 case 'X':
723 (*info->fprintf_func) (info->stream, "%s ",
724 shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
725 break;
726 case 'B':
727 (*info->fprintf_func)
728 (info->stream, "%s",
729 bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
730
731 /* If the next character in args is 'n', it will handle
732 putting out the space. */
733 if (s[1] != 'n')
734 (*info->fprintf_func) (info->stream, " ");
735 break;
736 }
737 break;
738 }
739
740 case 'V':
741 fput_const (extract_5_store (insn), info);
742 break;
743 case 'r':
744 fput_const (extract_5r_store (insn), info);
745 break;
746 case 'R':
747 fput_const (extract_5R_store (insn), info);
748 break;
749 case 'U':
750 fput_const (extract_10U_store (insn), info);
751 break;
752 case 'Q':
753 fput_const (extract_5Q_store (insn), info);
754 break;
755 case 'i':
756 fput_const (extract_11 (insn), info);
757 break;
758 case 'j':
759 fput_const (extract_14 (insn), info);
760 break;
761 case 'k':
762 fput_const (extract_21 (insn), info);
763 break;
764 case 'n':
765 if (insn & 0x2)
766 (*info->fprintf_func) (info->stream, ",n ");
767 else
768 (*info->fprintf_func) (info->stream, " ");
769 break;
770 case 'N':
771 if ((insn & 0x20) && s[1])
772 (*info->fprintf_func) (info->stream, ",n ");
773 else if (insn & 0x20)
774 (*info->fprintf_func) (info->stream, ",n");
775 else if (s[1])
776 (*info->fprintf_func) (info->stream, " ");
777 break;
778 case 'w':
779 (*info->print_address_func) (memaddr + 8 + extract_12 (insn),
780 info);
781 break;
782 case 'W':
783 /* 17 bit PC-relative branch. */
784 (*info->print_address_func) ((memaddr + 8
785 + extract_17 (insn)),
786 info);
787 break;
788 case 'z':
789 /* 17 bit displacement. This is an offset from a register
790 so it gets disasssembled as just a number, not any sort
791 of address. */
792 fput_const (extract_17 (insn), info);
793 break;
794
795 case 'Z':
796 /* addil %r1 implicit output. */
797 (*info->fprintf_func) (info->stream, "%%r1");
798 break;
799
800 case '.':
801 (*info->fprintf_func) (info->stream, "%d",
802 GET_FIELD (insn, 24, 25));
803 break;
804 case '*':
805 (*info->fprintf_func) (info->stream, "%d",
806 GET_FIELD (insn, 22, 25));
807 break;
808 case '!':
809 (*info->fprintf_func) (info->stream, "%%sar");
810 break;
811 case 'p':
812 (*info->fprintf_func) (info->stream, "%d",
813 31 - GET_FIELD (insn, 22, 26));
814 break;
815 case '~':
816 {
817 int num;
818 num = GET_FIELD (insn, 20, 20) << 5;
819 num |= GET_FIELD (insn, 22, 26);
820 (*info->fprintf_func) (info->stream, "%d", 63 - num);
821 break;
822 }
823 case 'P':
824 (*info->fprintf_func) (info->stream, "%d",
825 GET_FIELD (insn, 22, 26));
826 break;
827 case 'q':
828 {
829 int num;
830 num = GET_FIELD (insn, 20, 20) << 5;
831 num |= GET_FIELD (insn, 22, 26);
832 (*info->fprintf_func) (info->stream, "%d", num);
833 break;
834 }
835 case 'T':
836 (*info->fprintf_func) (info->stream, "%d",
837 32 - GET_FIELD (insn, 27, 31));
838 break;
839 case '%':
840 {
841 int num;
842 num = (GET_FIELD (insn, 23, 23) + 1) * 32;
843 num -= GET_FIELD (insn, 27, 31);
844 (*info->fprintf_func) (info->stream, "%d", num);
845 break;
846 }
847 case '|':
848 {
849 int num;
850 num = (GET_FIELD (insn, 19, 19) + 1) * 32;
851 num -= GET_FIELD (insn, 27, 31);
852 (*info->fprintf_func) (info->stream, "%d", num);
853 break;
854 }
855 case '$':
856 fput_const (GET_FIELD (insn, 20, 28), info);
857 break;
858 case 'A':
859 fput_const (GET_FIELD (insn, 6, 18), info);
860 break;
861 case 'D':
862 fput_const (GET_FIELD (insn, 6, 31), info);
863 break;
864 case 'v':
865 (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
866 break;
867 case 'O':
868 fput_const ((GET_FIELD (insn, 6,20) << 5 |
869 GET_FIELD (insn, 27, 31)), info);
870 break;
871 case 'o':
872 fput_const (GET_FIELD (insn, 6, 20), info);
873 break;
874 case '2':
875 fput_const ((GET_FIELD (insn, 6, 22) << 5 |
876 GET_FIELD (insn, 27, 31)), info);
877 break;
878 case '1':
879 fput_const ((GET_FIELD (insn, 11, 20) << 5 |
880 GET_FIELD (insn, 27, 31)), info);
881 break;
882 case '0':
883 fput_const ((GET_FIELD (insn, 16, 20) << 5 |
884 GET_FIELD (insn, 27, 31)), info);
885 break;
886 case 'u':
887 (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
888 break;
889 case 'F':
890 /* if no destination completer and not before a completer
891 for fcmp, need a space here */
892 if (s[1] == 'G' || s[1] == '?')
893 fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)],
894 info);
895 else
896 (*info->fprintf_func) (info->stream, "%s ",
897 float_format_names[GET_FIELD
898 (insn, 19, 20)]);
899 break;
900 case 'G':
901 (*info->fprintf_func) (info->stream, "%s ",
902 float_format_names[GET_FIELD (insn,
903 17, 18)]);
904 break;
905 case 'H':
906 if (GET_FIELD (insn, 26, 26) == 1)
907 (*info->fprintf_func) (info->stream, "%s ",
908 float_format_names[0]);
909 else
910 (*info->fprintf_func) (info->stream, "%s ",
911 float_format_names[1]);
912 break;
913 case 'I':
914 /* if no destination completer and not before a completer
915 for fcmp, need a space here */
916 if (s[1] == '?')
917 fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)],
918 info);
919 else
920 (*info->fprintf_func) (info->stream, "%s ",
921 float_format_names[GET_FIELD
922 (insn, 20, 20)]);
923 break;
924
925 case 'J':
926 fput_const (extract_14 (insn), info);
927 break;
928
929
930 case '#':
931 {
932 int sign = GET_FIELD (insn, 31, 31);
933 int imm10 = GET_FIELD (insn, 18, 27);
934 int disp;
935
936 if (sign)
937 disp = (-1 << 10) | imm10;
938 else
939 disp = imm10;
940
941 disp <<= 3;
942 fput_const (disp, info);
943 break;
944 }
945 case 'K':
946 case 'd':
947 {
948 int sign = GET_FIELD (insn, 31, 31);
949 int imm11 = GET_FIELD (insn, 18, 28);
950 int disp;
951
952 if (sign)
953 disp = (-1 << 11) | imm11;
954 else
955 disp = imm11;
956
957 disp <<= 2;
958 fput_const (disp, info);
959 break;
960 }
961
962 /* ?!? FIXME */
963 case '_':
964 case '{':
965 fputs_filtered ("Disassembler botch.\n", info);
966 break;
967
968 case 'm':
969 {
970 int y = GET_FIELD (insn, 16, 18);
971
972 if (y != 1)
973 fput_const ((y ^ 1) - 1, info);
974 }
975 break;
976
977 case 'h':
978 {
979 int cbit;
980
981 cbit = GET_FIELD (insn, 16, 18);
982
983 if (cbit > 0)
984 (*info->fprintf_func) (info->stream, ",%d", cbit - 1);
985 break;
986 }
987
988 case '=':
989 {
990 int cond = GET_FIELD (insn, 27, 31);
991
992 if (cond == 0)
993 fputs_filtered (" ", info);
994 else if (cond == 1)
995 fputs_filtered ("acc ", info);
996 else if (cond == 2)
997 fputs_filtered ("rej ", info);
998 else if (cond == 5)
999 fputs_filtered ("acc8 ", info);
1000 else if (cond == 6)
1001 fputs_filtered ("rej8 ", info);
1002 else if (cond == 9)
1003 fputs_filtered ("acc6 ", info);
1004 else if (cond == 13)
1005 fputs_filtered ("acc4 ", info);
1006 else if (cond == 17)
1007 fputs_filtered ("acc2 ", info);
1008 break;
1009 }
1010
1011 case 'X':
1012 (*info->print_address_func) ((memaddr + 8
1013 + extract_22 (insn)),
1014 info);
1015 break;
1016 case 'B':
1017 fputs_filtered (",pop", info);
1018 break;
1019 case 'M':
1020 fputs_filtered (",push", info);
1021 break;
1022 case 'L':
1023 fputs_filtered (",%r2", info);
1024 break;
1025 case 'g':
1026 fputs_filtered (",gate", info);
1027 break;
1028 case 'l':
1029 fputs_filtered (",l", info);
1030 break;
1031 default:
1032 (*info->fprintf_func) (info->stream, "%c", *s);
1033 break;
1034 }
1035 }
1036 return sizeof(insn);
1037 }
1038 }
1039 (*info->fprintf_func) (info->stream, "#%8x", insn);
1040 return sizeof(insn);
1041 }
This page took 0.070394 seconds and 4 git commands to generate.