1 /* Disassembler for the PA-RISC. Somewhat derived from sparc-pinsn.c.
2 Copyright 1989, 1990, 1992 Free Software Foundation, Inc.
4 Contributed by the Center for Software Science at the
5 University of Utah (pa-gdb-bugs@cs.utah.edu).
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "opcode/hppa.h"
27 char *control_reg
[] = {"rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
28 "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
29 "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
30 "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
31 "tr4", "tr5", "tr6", "tr7"
34 char *compare_cond_names
[] = {"", ",=", ",<", ",<=", ",<<", ",<<=", ",sv",
35 ",od", ",tr", ",<>", ",>=", ",>", ",>>=",
38 char *add_cond_names
[] = {"", ",=", ",<", ",<=", ",nuv", ",znv", ",sv",
39 ",od", ",tr", ",<>", ",>=", ",>", ",uv",
42 char *logical_cond_names
[] = {"", ",=", ",<", ",<=", 0, 0, 0, ",od",
43 ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
44 char *unit_cond_names
[] = {"", 0, ",sbz", ",shz", ",sdc", 0, ",sbc", ",shc",
45 ",tr", 0, ",nbz", ",nhz", ",ndc", 0, ",nbc", ",nhc"
47 char *shift_cond_names
[] = {"", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"};
49 char *index_compl_names
[] = {"", ",m", ",s", ",sm"};
50 char *short_ldst_compl_names
[] = {"", ",ma", "", ",mb"};
51 char *short_bytes_compl_names
[] = {"", ",b,m", ",e", ",e,m"};
52 char *float_format_names
[] = {",sgl", ",dbl", ",quad"};
53 char *float_comp_names
[] =
54 {",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
55 ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
56 ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
57 ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
60 /* For a bunch of different instructions form an index into a
61 completer name table. */
62 #define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \
63 GET_FIELD (insn, 18, 18) << 1)
65 #define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \
66 (GET_FIELD ((insn), 19, 19) ? 8 : 0))
68 void fput_reg (), fput_const ();
70 /* Print one instruction from MEMADDR on STREAM. */
72 print_insn (memaddr
, stream
)
76 unsigned int insn
, i
, op
;
78 read_memory (memaddr
, &insn
, sizeof (insn
));
80 for (i
= 0; i
< NUMOPCODES
; ++i
)
82 const struct pa_opcode
*opcode
= &pa_opcodes
[i
];
83 if ((insn
& opcode
->mask
) == opcode
->match
)
85 register const char *s
;
87 fputs_filtered (opcode
->name
, stream
);
89 if (!index ("cCY<?!@-+&U>~nZFM", opcode
->args
[0]))
90 fputs_filtered (" ", stream
);
91 for (s
= opcode
->args
; *s
!= '\0'; ++s
)
96 fput_reg (GET_FIELD (insn
, 11, 15), stream
);
99 if (GET_FIELD (insn
, 25, 25))
100 fput_reg_r (GET_FIELD (insn
, 11, 15), stream
);
102 fput_reg (GET_FIELD (insn
, 11, 15), stream
);
105 fput_reg (GET_FIELD (insn
, 6, 10), stream
);
108 fput_creg (GET_FIELD (insn
, 6, 10), stream
);
111 if (GET_FIELD (insn
, 25, 25))
112 fput_reg_r (GET_FIELD (insn
, 6, 10), stream
);
114 fput_reg (GET_FIELD (insn
, 6, 10), stream
);
117 fput_reg (GET_FIELD (insn
, 27, 31), stream
);
120 if (GET_FIELD (insn
, 25, 25))
121 fput_reg_r (GET_FIELD (insn
, 27, 31), stream
);
123 fput_reg (GET_FIELD (insn
, 27, 31), stream
);
126 fput_creg (GET_FIELD (insn
, 6, 10), stream
);
129 fput_reg (GET_FIELD (insn
, 11, 15), stream
);
132 fput_reg (GET_FIELD (insn
, 27, 31), stream
);
135 fput_reg (GET_FIELD (insn
, 16, 20), stream
);
138 fput_reg (GET_FIELD (insn
, 21, 25), stream
);
141 fput_const (extract_5_load (insn
), stream
);
145 fprintf_filtered (stream
, "sr%d", extract_3 (insn
));
148 fprintf_filtered (stream
, "%s ",
149 index_compl_names
[GET_COMPL (insn
)]);
152 fprintf_filtered (stream
, "%s ",
153 short_ldst_compl_names
[GET_COMPL (insn
)]);
156 fprintf_filtered (stream
, "%s ",
157 short_bytes_compl_names
[GET_COMPL (insn
)]);
159 /* these four conditions are for the set of instructions
160 which distinguish true/false conditions by opcode rather
161 than by the 'f' bit (sigh): comb, comib, addb, addib */
163 fputs_filtered (compare_cond_names
[GET_FIELD (insn
, 16, 18)],
167 fputs_filtered (compare_cond_names
[GET_FIELD (insn
, 16, 18) + 8],
171 fputs_filtered (add_cond_names
[GET_FIELD (insn
, 16, 18)],
175 fputs_filtered (add_cond_names
[GET_FIELD (insn
, 16, 18) + 8],
179 fprintf_filtered (stream
, "%s ",
180 compare_cond_names
[GET_COND (insn
)]);
183 fprintf_filtered (stream
, "%s ",
184 add_cond_names
[GET_FIELD (insn
, 16, 18)]);
188 fprintf_filtered (stream
, "%s ",
189 logical_cond_names
[GET_COND (insn
)]);
192 fprintf_filtered (stream
, "%s ",
193 unit_cond_names
[GET_COND (insn
)]);
197 fprintf_filtered (stream
, "%s ",
198 shift_cond_names
[GET_FIELD (insn
, 16, 18)]);
201 fput_const (extract_5_store (insn
), stream
);
204 fput_const (extract_11 (insn
), stream
);
207 fput_const (extract_14 (insn
), stream
);
210 fput_const (extract_21 (insn
), stream
);
214 fprintf_filtered (stream
, ",n ");
216 fprintf_filtered (stream
, " ");
219 print_address (memaddr
+ 8 + extract_12 (insn
), stream
);
222 /* don't interpret an address if it's an external branch
224 op
= GET_FIELD (insn
, 0, 5);
225 if (op
!= 0x38 /* be */ && op
!= 0x39 /* ble */)
226 print_address (memaddr
+ 8 + extract_17 (insn
), stream
);
228 fput_const (extract_17 (insn
), stream
);
233 if (space
= GET_FIELD (insn
, 16, 17))
234 fprintf_filtered (stream
, "sr%d,", space
);
235 fput_reg (GET_FIELD (insn
, 6, 10), stream
);
239 fprintf_filtered (stream
, "%d",
240 31 - GET_FIELD (insn
, 22, 26));
243 fprintf_filtered (stream
, "%d",
244 GET_FIELD (insn
, 22, 26));
247 fprintf_filtered (stream
, "%d",
248 32 - GET_FIELD (insn
, 27, 31));
251 fput_const (GET_FIELD (insn
, 6, 18), stream
);
254 if (GET_FIELD (insn
, 26, 26))
255 fprintf_filtered (stream
, ",m ");
257 fprintf_filtered (stream
, " ");
260 fput_const (GET_FIELD (insn
, 6, 31), stream
);
263 fprintf_filtered (stream
, ",%d", GET_FIELD (insn
, 23, 25));
266 fput_const ((GET_FIELD (insn
, 6,20) << 5 |
267 GET_FIELD (insn
, 27, 31)), stream
);
270 fput_const (GET_FIELD (insn
, 6, 20), stream
);
273 fput_const ((GET_FIELD (insn
, 6, 22) << 5 |
274 GET_FIELD (insn
, 27, 31)), stream
);
277 fput_const ((GET_FIELD (insn
, 11, 20) << 5 |
278 GET_FIELD (insn
, 27, 31)), stream
);
281 fput_const ((GET_FIELD (insn
, 16, 20) << 5 |
282 GET_FIELD (insn
, 27, 31)), stream
);
285 fprintf_filtered (stream
, "%d", GET_FIELD (insn
, 23, 25));
288 /* if no destination completer, need a space here */
289 if (GET_FIELD (insn
, 21, 22) == 1)
290 fputs_filtered (float_format_names
[GET_FIELD (insn
, 19, 20)],
293 fprintf_filtered (stream
, "%s ",
294 float_format_names
[GET_FIELD
298 fprintf_filtered (stream
, "%s ",
299 float_format_names
[GET_FIELD (insn
,
303 fputs_filtered (float_format_names
[GET_FIELD
304 (insn
, 26, 26)], stream
);
307 fputs_filtered (float_comp_names
[GET_FIELD (insn
, 27, 31)],
311 fprintf_filtered (stream
, "fp%d", GET_FIELD (insn
, 6, 10));
314 fprintf_filtered (stream
, "fp%d", GET_FIELD (insn
, 11, 15));
317 if (GET_FIELD (insn
, 23, 25) == 0)
318 fprintf_filtered (stream
, "fp%d",
319 GET_FIELD (insn
, 27, 31));
321 fprintf_filtered (stream
, "cp%d",
322 GET_FIELD (insn
, 27, 31));
325 fprintf_filtered (stream
, "%c", *s
);
332 fprintf_filtered (stream
, "%#8x", insn
);
336 /* Utility function to print registers */
339 fput_reg (reg
, stream
)
344 fputs_filtered (reg_names
[reg
], stream
);
346 fputs_filtered ("r0", stream
);
350 fput_reg_r (reg
, stream
)
355 fputs_filtered (reg_names
[reg
], stream
);
357 fputs_filtered ("r0", stream
);
358 fputs_filtered ("R", stream
);
362 fput_creg (reg
, stream
)
366 fputs_filtered (control_reg
[reg
], stream
);
369 /* print constants with sign */
372 fput_const (num
, stream
)
377 fprintf_filtered (stream
, "-%x", -(int)num
);
379 fprintf_filtered (stream
, "%x", num
);
This page took 0.038706 seconds and 4 git commands to generate.