* hppa-dis.c (extract_22): New function.
[deliverable/binutils-gdb.git] / opcodes / hppa-dis.c
CommitLineData
252b5132
RH
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
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 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. */
29static 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. */
37static 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
44typedef unsigned int CORE_ADDR;
45
46/* Get at various relevent fields of an instruction word. */
47
48#define MASK_5 0x1f
3b67cf2b 49#define MASK_10 0x3ff
252b5132
RH
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. */
58d0c905 62static const char *const control_reg[] = {
252b5132
RH
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
58d0c905 70static const char *const compare_cond_names[] = {
b333b6c6
JL
71 "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od",
72 ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev"
73};
58d0c905 74static const char *const compare_cond_64_names[] = {
b333b6c6
JL
75 "", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od",
76 ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev"
77};
58d0c905 78static const char *const cmpib_cond_64_names[] = {
b333b6c6 79 ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>"
252b5132 80};
58d0c905 81static const char *const add_cond_names[] = {
b333b6c6
JL
82 "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od",
83 ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev"
84};
58d0c905 85static const char *const add_cond_64_names[] = {
d1e9bd1f 86 "", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od",
b333b6c6
JL
87 ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev"
88};
58d0c905 89static const char *const wide_add_cond_names[] = {
b333b6c6
JL
90 "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=",
91 ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>"
252b5132
RH
92};
93static const char *const logical_cond_names[] = {
94 "", ",=", ",<", ",<=", 0, 0, 0, ",od",
95 ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
b333b6c6 96static const char *const logical_cond_64_names[] = {
d1e9bd1f 97 "", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od",
b333b6c6 98 ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"};
252b5132
RH
99static const char *const unit_cond_names[] = {
100 "", 0, ",sbz", ",shz", ",sdc", 0, ",sbc", ",shc",
101 ",tr", 0, ",nbz", ",nhz", ",ndc", 0, ",nbc", ",nhc"
102};
b333b6c6 103static const char *const unit_cond_64_names[] = {
d1e9bd1f 104 "", ",*swz", ",*sbz", ",*shz", ",*sdc", ",*swc", ",*sbc", ",*shc",
b333b6c6
JL
105 ",*tr", ",*nwz", ",*nbz", ",*nhz", ",*ndc", ",*nwc", ",*nbc", ",*nhc"
106};
58d0c905 107static const char *const shift_cond_names[] = {
252b5132
RH
108 "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
109};
58d0c905 110static const char *const shift_cond_64_names[] = {
d1e9bd1f 111 "", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev"
b333b6c6 112};
58d0c905 113static const char *const bb_cond_64_names[] = {
b333b6c6
JL
114 ",*<", ",*>="
115};
58d0c905
JL
116static const char *const index_compl_names[] = {"", ",m", ",s", ",sm"};
117static const char *const short_ldst_compl_names[] = {"", ",ma", "", ",mb"};
252b5132
RH
118static const char *const short_bytes_compl_names[] = {
119 "", ",b,m", ",e", ",e,m"
120};
121static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
58d0c905 122static const char *const float_comp_names[] =
252b5132
RH
123{
124 ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
125 ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
126 ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
127 ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
128};
58d0c905
JL
129static const char *const signed_unsigned_names[] = {",u", ",s"};
130static const char *const mix_half_names[] = {",l", ",r"};
131static const char *const saturation_names[] = {",us", ",ss", 0, ""};
132static const char *const read_write_names[] = {",r", ",w"};
133static const char *const add_compl_names[] = { 0, "", ",l", ",tsv" };
252b5132
RH
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
148static void
149fput_reg (reg, info)
150 unsigned reg;
151 disassemble_info *info;
152{
153 (*info->fprintf_func) (info->stream, reg ? reg_names[reg] : "r0");
154}
155
156static void
157fput_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
164static void
165fput_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
177static void
178fput_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
187static void
188fput_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 */
202static int
203extract_3 (word)
204 unsigned word;
205{
206 return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
207}
208
209static int
210extract_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 */
217static int
218extract_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 */
225static unsigned
226extract_5r_store (word)
227 unsigned word;
228{
229 return (word & MASK_5);
230}
231
232/* extract the immediate field from a {sr}sm instruction */
233static unsigned
234extract_5R_store (word)
235 unsigned word;
236{
237 return (word >> 16 & MASK_5);
238}
239
3b67cf2b
JL
240/* extract the 10 bit immediate field from a {sr}sm instruction */
241static unsigned
242extract_10U_store (word)
243 unsigned word;
244{
245 return (word >> 16 & MASK_10);
246}
247
252b5132
RH
248/* extract the immediate field from a bb instruction */
249static unsigned
250extract_5Q_store (word)
251 unsigned word;
252{
253 return (word >> 21 & MASK_5);
254}
255
256/* extract an 11 bit immediate field */
257static int
258extract_11 (word)
259 unsigned word;
260{
261 return low_sign_extend (word & MASK_11, 11);
262}
263
264/* extract a 14 bit immediate field */
265static int
266extract_14 (word)
267 unsigned word;
268{
269 return low_sign_extend (word & MASK_14, 14);
270}
271
272/* extract a 21 bit constant */
273
274static int
275extract_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
296static int
297extract_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
308static int
309extract_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
b3fe7ee2
JL
318static int
319extract_22 (word)
320 unsigned word;
321{
322 return sign_extend (GET_FIELD (word, 19, 28) |
323 GET_FIELD (word, 29, 29) << 10 |
324 GET_FIELD (word, 11, 15) << 11 |
325 GET_FIELD (word, 6, 10) << 16 |
326 (word & 0x1) << 21, 22) << 2;
327}
328
252b5132
RH
329/* Print one instruction. */
330int
331print_insn_hppa (memaddr, info)
332 bfd_vma memaddr;
333 disassemble_info *info;
334{
335 bfd_byte buffer[4];
336 unsigned int insn, i;
337
338 {
339 int status =
340 (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
341 if (status != 0)
342 {
343 (*info->memory_error_func) (status, memaddr, info);
344 return -1;
345 }
346 }
347
348 insn = bfd_getb32 (buffer);
349
350 for (i = 0; i < NUMOPCODES; ++i)
351 {
352 const struct pa_opcode *opcode = &pa_opcodes[i];
353 if ((insn & opcode->mask) == opcode->match)
354 {
355 register const char *s;
356
357 (*info->fprintf_func) (info->stream, "%s", opcode->name);
358
46e36b17 359 if (!strchr ("cfCY?-+nHNZFIuv", opcode->args[0]))
252b5132
RH
360 (*info->fprintf_func) (info->stream, " ");
361 for (s = opcode->args; *s != '\0'; ++s)
362 {
363 switch (*s)
364 {
365 case 'x':
366 fput_reg (GET_FIELD (insn, 11, 15), info);
367 break;
1eee34f5 368 case 'a':
252b5132
RH
369 case 'b':
370 fput_reg (GET_FIELD (insn, 6, 10), info);
371 break;
372 case '^':
373 fput_creg (GET_FIELD (insn, 6, 10), info);
374 break;
252b5132
RH
375 case 't':
376 fput_reg (GET_FIELD (insn, 27, 31), info);
377 break;
a349b151
JL
378
379 /* Handle floating point registers. */
380 case 'f':
381 switch (*++s)
382 {
383 case 't':
252b5132 384 fput_fp_reg (GET_FIELD (insn, 27, 31), info);
a349b151
JL
385 break;
386 case 'T':
387 if (GET_FIELD (insn, 25, 25))
388 fput_fp_reg_r (GET_FIELD (insn, 27, 31), info);
389 else
390 fput_fp_reg (GET_FIELD (insn, 27, 31), info);
391 break;
392 case 'a':
393 if (GET_FIELD (insn, 25, 25))
394 fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
395 else
396 fput_fp_reg (GET_FIELD (insn, 6, 10), info);
397 break;
debc018d
JL
398
399 /* 'fA' will not generate a space before the regsiter
400 name. Normally that is fine. Except that it
401 causes problems with xmpyu which has no FP format
402 completer. */
403 case 'X':
404 fputs_filtered (" ", info);
405
406 /* FALLTHRU */
407
a349b151
JL
408 case 'A':
409 if (GET_FIELD (insn, 24, 24))
410 fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
411 else
412 fput_fp_reg (GET_FIELD (insn, 6, 10), info);
413
414 break;
415 case 'b':
416 if (GET_FIELD (insn, 25, 25))
417 fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
418 else
419 fput_fp_reg (GET_FIELD (insn, 11, 15), info);
420 break;
421 case 'B':
422 if (GET_FIELD (insn, 19, 19))
423 fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
424 else
425 fput_fp_reg (GET_FIELD (insn, 11, 15), info);
426 break;
427 case 'C':
428 {
429 int reg = GET_FIELD (insn, 21, 22);
430 reg |= GET_FIELD (insn, 16, 18) << 2;
431 if (GET_FIELD (insn, 23, 23) != 0)
432 fput_fp_reg_r (reg, info);
433 else
434 fput_fp_reg (reg, info);
435 break;
436 }
437 case 'i':
438 {
439 int reg = GET_FIELD (insn, 6, 10);
252b5132 440
a349b151
JL
441 reg |= (GET_FIELD (insn, 26, 26) << 4);
442 fput_fp_reg (reg, info);
443 break;
444 }
445 case 'j':
446 {
447 int reg = GET_FIELD (insn, 11, 15);
252b5132 448
a349b151
JL
449 reg |= (GET_FIELD (insn, 26, 26) << 4);
450 fput_fp_reg (reg, info);
451 break;
452 }
453 case 'k':
454 {
455 int reg = GET_FIELD (insn, 27, 31);
252b5132 456
a349b151
JL
457 reg |= (GET_FIELD (insn, 26, 26) << 4);
458 fput_fp_reg (reg, info);
459 break;
460 }
461 case 'l':
462 {
463 int reg = GET_FIELD (insn, 21, 25);
252b5132 464
a349b151
JL
465 reg |= (GET_FIELD (insn, 26, 26) << 4);
466 fput_fp_reg (reg, info);
467 break;
468 }
469 case 'm':
470 {
471 int reg = GET_FIELD (insn, 16, 20);
472
473 reg |= (GET_FIELD (insn, 26, 26) << 4);
474 fput_fp_reg (reg, info);
475 break;
476 }
f322c2c2
JL
477 case 'e':
478 if (GET_FIELD (insn, 25, 25))
479 fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
480 else
481 fput_fp_reg (GET_FIELD (insn, 11, 15), info);
482 break;
483
a349b151 484 }
2f87f883 485 break;
252b5132 486
252b5132
RH
487 case '5':
488 fput_const (extract_5_load (insn), info);
489 break;
490 case 's':
491 (*info->fprintf_func) (info->stream,
492 "sr%d", GET_FIELD (insn, 16, 17));
493 break;
b333b6c6 494
252b5132
RH
495 case 'S':
496 (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn));
497 break;
3281117a
JL
498
499 /* Handle completers. */
252b5132 500 case 'c':
3281117a
JL
501 switch (*++s)
502 {
503 case 'x':
504 (*info->fprintf_func) (info->stream, "%s ",
505 index_compl_names[GET_COMPL (insn)]);
506 break;
507 case 'm':
508 (*info->fprintf_func) (info->stream, "%s ",
509 short_ldst_compl_names[GET_COMPL (insn)]);
510 break;
d758242c
JL
511 case 'q':
512 (*info->fprintf_func)
513 (info->stream, "%s ",
514 short_ldst_compl_names[(GET_FIELD (insn, 28, 28)
515 | GET_FIELD (insn, 29, 29))]);
516 break;
f322c2c2
JL
517 case 'J':
518 if (insn & 0x4)
519 (*info->fprintf_func) (info->stream, ",mb ");
520 else
521 (*info->fprintf_func) (info->stream, ",ma ");
522 break;
3281117a
JL
523 case 's':
524 (*info->fprintf_func) (info->stream, "%s ",
525 short_bytes_compl_names[GET_COMPL (insn)]);
526 break;
3b67cf2b
JL
527 case 'L':
528 (*info->fprintf_func) (info->stream, ",l");
529 break;
530 case 'w':
531 (*info->fprintf_func) (info->stream, "%s ",
532 read_write_names[GET_FIELD (insn, 25, 25)]);
533 break;
534 case 'W':
535 (*info->fprintf_func) (info->stream, ",w");
536 break;
537 case 'r':
538 if (GET_FIELD (insn, 23, 26) == 5)
539 (*info->fprintf_func) (info->stream, ",r");
540 break;
3281117a
JL
541 case 'Z':
542 if (GET_FIELD (insn, 26, 26))
543 (*info->fprintf_func) (info->stream, ",m ");
544 else
545 (*info->fprintf_func) (info->stream, " ");
546 break;
3b67cf2b
JL
547 case 'i':
548 if (GET_FIELD (insn, 25, 25))
549 (*info->fprintf_func) (info->stream, ",i");
550 break;
af10de82
JL
551 case 'z':
552 if (!GET_FIELD (insn, 21, 21))
553 (*info->fprintf_func) (info->stream, ",z");
554 break;
3b67cf2b
JL
555 case 'a':
556 (*info->fprintf_func)
557 (info->stream, "%s", add_compl_names[GET_FIELD
558 (insn, 20, 21)]);
559 break;
560 case 'Y':
561 (*info->fprintf_func)
562 (info->stream, ",dc%s", add_compl_names[GET_FIELD
563 (insn, 20, 21)]);
564 break;
565 case 'y':
566 (*info->fprintf_func)
567 (info->stream, ",c%s", add_compl_names[GET_FIELD
568 (insn, 20, 21)]);
569 break;
570 case 'v':
571 if (GET_FIELD (insn, 20, 20))
572 (*info->fprintf_func) (info->stream, ",tsv");
573 break;
574 case 't':
575 (*info->fprintf_func) (info->stream, ",tc");
576 if (GET_FIELD (insn, 20, 20))
577 (*info->fprintf_func) (info->stream, ",tsv");
578 break;
579 case 'B':
580 (*info->fprintf_func) (info->stream, ",db");
581 if (GET_FIELD (insn, 20, 20))
582 (*info->fprintf_func) (info->stream, ",tsv");
583 break;
584 case 'b':
585 (*info->fprintf_func) (info->stream, ",b");
586 if (GET_FIELD (insn, 20, 20))
587 (*info->fprintf_func) (info->stream, ",tsv");
588 break;
589 case 'T':
590 if (GET_FIELD (insn, 25, 25))
591 (*info->fprintf_func) (info->stream, ",tc");
592 break;
1eee34f5
JL
593 case 'S':
594 /* EXTRD/W has a following condition. */
595 if (*(s + 1) == '?')
596 (*info->fprintf_func)
597 (info->stream, "%s", signed_unsigned_names[GET_FIELD
598 (insn, 21, 21)]);
599 else
600 (*info->fprintf_func)
601 (info->stream, "%s ", signed_unsigned_names[GET_FIELD
602 (insn, 21, 21)]);
603 break;
604 case 'h':
605 (*info->fprintf_func)
606 (info->stream, "%s", mix_half_names[GET_FIELD
607 (insn, 17, 17)]);
608 break;
609 case 'H':
610 (*info->fprintf_func)
611 (info->stream, "%s", saturation_names[GET_FIELD
612 (insn, 24, 25)]);
613 break;
614 case '*':
615 (*info->fprintf_func)
616 (info->stream, ",%d%d%d%d ",
617 GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
618 GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
619 break;
3281117a 620 }
252b5132 621 break;
feb12992
JL
622
623 /* Handle conditions. */
252b5132 624 case '?':
feb12992
JL
625 {
626 s++;
627 switch (*s)
628 {
629 case 'f':
630 (*info->fprintf_func) (info->stream, "%s ",
631 float_comp_names[GET_FIELD
632 (insn, 27, 31)]);
633 break;
634
635 /* these four conditions are for the set of instructions
636 which distinguish true/false conditions by opcode
637 rather than by the 'f' bit (sigh): comb, comib,
638 addb, addib */
639 case 't':
a349b151 640 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)],
feb12992
JL
641 info);
642 break;
b333b6c6
JL
643 case 'T':
644 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
645 + 8], info);
646 break;
647 case 'r':
648 fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)],
649 info);
650 break;
651 case 'R':
652 fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)
653 + 8], info);
654 break;
655 case 'Q':
656 fputs_filtered (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
657 info);
658 break;
feb12992 659 case 'n':
a349b151 660 fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
feb12992
JL
661 + GET_FIELD (insn, 4, 4) * 8], info);
662 break;
663 case '@':
664 fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18)
665 + GET_FIELD (insn, 4, 4) * 8], info);
666 break;
667 case 's':
668 (*info->fprintf_func) (info->stream, "%s ",
669 compare_cond_names[GET_COND (insn)]);
670 break;
b333b6c6
JL
671 case 'S':
672 (*info->fprintf_func) (info->stream, "%s ",
673 compare_cond_64_names[GET_COND (insn)]);
674 break;
feb12992
JL
675 case 'a':
676 (*info->fprintf_func) (info->stream, "%s ",
677 add_cond_names[GET_COND (insn)]);
678 break;
b333b6c6
JL
679 case 'A':
680 (*info->fprintf_func) (info->stream, "%s ",
681 add_cond_64_names[GET_COND (insn)]);
682 break;
feb12992
JL
683 case 'd':
684 (*info->fprintf_func) (info->stream, "%s",
a349b151 685 add_cond_names[GET_FIELD (insn, 16, 18)]);
feb12992 686 break;
a349b151 687
b333b6c6
JL
688 case 'D':
689 (*info->fprintf_func) (info->stream, "%s",
a349b151
JL
690 add_cond_names[GET_FIELD (insn, 16, 18)
691 + 8]);
b333b6c6
JL
692 break;
693 case 'w':
a349b151 694 (*info->fprintf_func)
b333b6c6
JL
695 (info->stream, "%s",
696 wide_add_cond_names[GET_FIELD (insn, 16, 18)]);
697 break;
698
699 case 'W':
a349b151 700 (*info->fprintf_func)
b333b6c6
JL
701 (info->stream, "%s",
702 wide_add_cond_names[GET_FIELD (insn, 16, 18) + 8]);
703 break;
feb12992
JL
704
705 case 'l':
706 (*info->fprintf_func) (info->stream, "%s ",
707 logical_cond_names[GET_COND (insn)]);
708 break;
b333b6c6
JL
709 case 'L':
710 (*info->fprintf_func) (info->stream, "%s ",
711 logical_cond_64_names[GET_COND (insn)]);
712 break;
feb12992
JL
713 case 'u':
714 (*info->fprintf_func) (info->stream, "%s ",
715 unit_cond_names[GET_COND (insn)]);
716 break;
b333b6c6
JL
717 case 'U':
718 (*info->fprintf_func) (info->stream, "%s ",
719 unit_cond_64_names[GET_COND (insn)]);
720 break;
feb12992
JL
721 case 'y':
722 case 'x':
723 case 'b':
724 (*info->fprintf_func)
725 (info->stream, "%s",
726 shift_cond_names[GET_FIELD (insn, 16, 18)]);
727
728 /* If the next character in args is 'n', it will handle
729 putting out the space. */
730 if (s[1] != 'n')
731 (*info->fprintf_func) (info->stream, " ");
732 break;
b333b6c6 733 case 'X':
e46def7b 734 (*info->fprintf_func) (info->stream, "%s ",
b333b6c6
JL
735 shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
736 break;
737 case 'B':
738 (*info->fprintf_func)
739 (info->stream, "%s",
740 bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
feb12992 741
b333b6c6
JL
742 /* If the next character in args is 'n', it will handle
743 putting out the space. */
744 if (s[1] != 'n')
745 (*info->fprintf_func) (info->stream, " ");
746 break;
feb12992
JL
747 }
748 break;
749 }
252b5132 750
252b5132
RH
751 case 'V':
752 fput_const (extract_5_store (insn), info);
753 break;
754 case 'r':
755 fput_const (extract_5r_store (insn), info);
756 break;
757 case 'R':
758 fput_const (extract_5R_store (insn), info);
759 break;
3b67cf2b
JL
760 case 'U':
761 fput_const (extract_10U_store (insn), info);
762 break;
252b5132
RH
763 case 'Q':
764 fput_const (extract_5Q_store (insn), info);
765 break;
766 case 'i':
767 fput_const (extract_11 (insn), info);
768 break;
769 case 'j':
770 fput_const (extract_14 (insn), info);
771 break;
772 case 'k':
773 fput_const (extract_21 (insn), info);
774 break;
775 case 'n':
776 if (insn & 0x2)
777 (*info->fprintf_func) (info->stream, ",n ");
778 else
779 (*info->fprintf_func) (info->stream, " ");
780 break;
781 case 'N':
782 if ((insn & 0x20) && s[1])
783 (*info->fprintf_func) (info->stream, ",n ");
784 else if (insn & 0x20)
785 (*info->fprintf_func) (info->stream, ",n");
786 else if (s[1])
787 (*info->fprintf_func) (info->stream, " ");
788 break;
789 case 'w':
790 (*info->print_address_func) (memaddr + 8 + extract_12 (insn),
791 info);
792 break;
793 case 'W':
794 /* 17 bit PC-relative branch. */
795 (*info->print_address_func) ((memaddr + 8
796 + extract_17 (insn)),
797 info);
798 break;
799 case 'z':
800 /* 17 bit displacement. This is an offset from a register
801 so it gets disasssembled as just a number, not any sort
802 of address. */
803 fput_const (extract_17 (insn), info);
804 break;
d1e9bd1f
JL
805
806 case 'Z':
807 /* addil %r1 implicit output. */
2beaab59 808 (*info->fprintf_func) (info->stream, "%%r1");
d1e9bd1f
JL
809 break;
810
46424e05
JL
811 case '.':
812 (*info->fprintf_func) (info->stream, "%d",
813 GET_FIELD (insn, 24, 25));
814 break;
3b67cf2b
JL
815 case '*':
816 (*info->fprintf_func) (info->stream, "%d",
817 GET_FIELD (insn, 22, 25));
818 break;
b7d6d485 819 case '!':
2beaab59 820 (*info->fprintf_func) (info->stream, "%%sar");
b7d6d485 821 break;
252b5132
RH
822 case 'p':
823 (*info->fprintf_func) (info->stream, "%d",
824 31 - GET_FIELD (insn, 22, 26));
825 break;
46424e05
JL
826 case '~':
827 {
828 int num;
829 num = GET_FIELD (insn, 20, 20) << 5;
830 num |= GET_FIELD (insn, 22, 26);
831 (*info->fprintf_func) (info->stream, "%d", 63 - num);
832 break;
833 }
252b5132
RH
834 case 'P':
835 (*info->fprintf_func) (info->stream, "%d",
836 GET_FIELD (insn, 22, 26));
837 break;
af10de82
JL
838 case 'q':
839 {
840 int num;
841 num = GET_FIELD (insn, 20, 20) << 5;
842 num |= GET_FIELD (insn, 22, 26);
843 (*info->fprintf_func) (info->stream, "%d", num);
844 break;
845 }
252b5132
RH
846 case 'T':
847 (*info->fprintf_func) (info->stream, "%d",
848 32 - GET_FIELD (insn, 27, 31));
849 break;
af10de82
JL
850 case '%':
851 {
852 int num;
853 num = (GET_FIELD (insn, 23, 23) + 1) * 32;
854 num -= GET_FIELD (insn, 27, 31);
855 (*info->fprintf_func) (info->stream, "%d", num);
856 break;
857 }
858 case '|':
859 {
860 int num;
861 num = (GET_FIELD (insn, 19, 19) + 1) * 32;
862 num -= GET_FIELD (insn, 27, 31);
863 (*info->fprintf_func) (info->stream, "%d", num);
864 break;
865 }
46424e05
JL
866 case '$':
867 fput_const (GET_FIELD (insn, 20, 28), info);
868 break;
252b5132
RH
869 case 'A':
870 fput_const (GET_FIELD (insn, 6, 18), info);
871 break;
252b5132
RH
872 case 'D':
873 fput_const (GET_FIELD (insn, 6, 31), info);
874 break;
a349b151 875 case 'v':
252b5132
RH
876 (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
877 break;
878 case 'O':
879 fput_const ((GET_FIELD (insn, 6,20) << 5 |
880 GET_FIELD (insn, 27, 31)), info);
881 break;
882 case 'o':
883 fput_const (GET_FIELD (insn, 6, 20), info);
884 break;
252b5132
RH
885 case '2':
886 fput_const ((GET_FIELD (insn, 6, 22) << 5 |
887 GET_FIELD (insn, 27, 31)), info);
888 break;
889 case '1':
890 fput_const ((GET_FIELD (insn, 11, 20) << 5 |
891 GET_FIELD (insn, 27, 31)), info);
892 break;
893 case '0':
894 fput_const ((GET_FIELD (insn, 16, 20) << 5 |
895 GET_FIELD (insn, 27, 31)), info);
896 break;
897 case 'u':
898 (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
899 break;
900 case 'F':
901 /* if no destination completer and not before a completer
902 for fcmp, need a space here */
4f312591 903 if (s[1] == 'G' || s[1] == '?')
252b5132
RH
904 fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)],
905 info);
906 else
907 (*info->fprintf_func) (info->stream, "%s ",
908 float_format_names[GET_FIELD
909 (insn, 19, 20)]);
910 break;
911 case 'G':
912 (*info->fprintf_func) (info->stream, "%s ",
913 float_format_names[GET_FIELD (insn,
914 17, 18)]);
915 break;
916 case 'H':
917 if (GET_FIELD (insn, 26, 26) == 1)
918 (*info->fprintf_func) (info->stream, "%s ",
919 float_format_names[0]);
920 else
921 (*info->fprintf_func) (info->stream, "%s ",
922 float_format_names[1]);
923 break;
924 case 'I':
925 /* if no destination completer and not before a completer
926 for fcmp, need a space here */
4f312591 927 if (s[1] == '?')
252b5132
RH
928 fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)],
929 info);
930 else
931 (*info->fprintf_func) (info->stream, "%s ",
932 float_format_names[GET_FIELD
933 (insn, 20, 20)]);
934 break;
eb32eb44
JL
935
936 case 'J':
937 fput_const (extract_14 (insn), info);
938 break;
939
d758242c
JL
940 case '#':
941 {
942 int sign = GET_FIELD (insn, 31, 31);
943 int imm10 = GET_FIELD (insn, 18, 27);
944 int disp;
945
946 if (sign)
947 disp = (-1 << 10) | imm10;
948 else
949 disp = imm10;
950
951 disp <<= 3;
952 fput_const (disp, info);
953 break;
954 }
eb32eb44 955 case 'K':
d758242c
JL
956 case 'd':
957 {
958 int sign = GET_FIELD (insn, 31, 31);
959 int imm11 = GET_FIELD (insn, 18, 28);
960 int disp;
961
962 if (sign)
963 disp = (-1 << 11) | imm11;
964 else
965 disp = imm11;
966
967 disp <<= 2;
968 fput_const (disp, info);
969 break;
970 }
971
838c65f0
JL
972 /* ?!? FIXME */
973 case '_':
974 case '{':
975 fputs_filtered ("Disassembler botch.\n", info);
976 break;
977
978 case 'm':
979 {
980 int y = GET_FIELD (insn, 16, 18);
981
982 if (y != 1)
983 fput_const ((y ^ 1) - 1, info);
984 }
985 break;
986
987 case 'h':
988 {
989 int cbit;
990
991 cbit = GET_FIELD (insn, 16, 18);
992
993 if (cbit > 0)
994 (*info->fprintf_func) (info->stream, ",%d", cbit - 1);
995 break;
996 }
997
998 case '=':
999 {
1000 int cond = GET_FIELD (insn, 27, 31);
1001
1002 if (cond == 0)
1003 fputs_filtered (" ", info);
1004 else if (cond == 1)
1005 fputs_filtered ("acc ", info);
1006 else if (cond == 2)
1007 fputs_filtered ("rej ", info);
1008 else if (cond == 5)
1009 fputs_filtered ("acc8 ", info);
1010 else if (cond == 6)
1011 fputs_filtered ("rej8 ", info);
1012 else if (cond == 9)
1013 fputs_filtered ("acc6 ", info);
1014 else if (cond == 13)
1015 fputs_filtered ("acc4 ", info);
1016 else if (cond == 17)
1017 fputs_filtered ("acc2 ", info);
1018 break;
1019 }
1020
3610d131
JL
1021 case 'X':
1022 (*info->print_address_func) ((memaddr + 8
1023 + extract_22 (insn)),
1024 info);
1025 break;
69138680
JL
1026 case 'B':
1027 fputs_filtered (",pop", info);
1028 break;
2784abe5
JL
1029 case 'M':
1030 fputs_filtered (",push", info);
1031 break;
1032 case 'L':
1033 fputs_filtered (",%r2", info);
1034 break;
321e8dac
JL
1035 case 'g':
1036 fputs_filtered (",gate", info);
1037 break;
a5c4b2b4
JL
1038 case 'l':
1039 fputs_filtered (",l", info);
1040 break;
252b5132
RH
1041 default:
1042 (*info->fprintf_func) (info->stream, "%c", *s);
1043 break;
1044 }
1045 }
1046 return sizeof(insn);
1047 }
1048 }
1049 (*info->fprintf_func) (info->stream, "#%8x", insn);
1050 return sizeof(insn);
1051}
This page took 0.079333 seconds and 4 git commands to generate.