Commit | Line | Data |
---|---|---|
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 | ||
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 | |
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. */ | |
62 | static const char control_reg[][6] = { | |
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 compare_cond_names[][5] = { | |
b333b6c6 JL |
71 | "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od", |
72 | ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev" | |
73 | }; | |
74 | static const char compare_cond_64_names[][6] = { | |
75 | "", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od", | |
76 | ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev" | |
77 | }; | |
78 | static const char cmpib_cond_64_names[][6] = { | |
79 | ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>" | |
252b5132 RH |
80 | }; |
81 | static const char add_cond_names[][5] = { | |
b333b6c6 JL |
82 | "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od", |
83 | ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev" | |
84 | }; | |
85 | static const char add_cond_64_names[][6] = { | |
86 | ",*", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od", | |
87 | ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev" | |
88 | }; | |
89 | static const char wide_add_cond_names[][5] = { | |
90 | "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=", | |
91 | ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>" | |
252b5132 RH |
92 | }; |
93 | static const char *const logical_cond_names[] = { | |
94 | "", ",=", ",<", ",<=", 0, 0, 0, ",od", | |
95 | ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"}; | |
b333b6c6 JL |
96 | static const char *const logical_cond_64_names[] = { |
97 | ",*", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od", | |
98 | ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"}; | |
252b5132 RH |
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 | }; | |
b333b6c6 JL |
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 | }; | |
252b5132 RH |
107 | static const char shift_cond_names[][4] = { |
108 | "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev" | |
109 | }; | |
b333b6c6 JL |
110 | static const char shift_cond_64_names[][5] = { |
111 | ",*", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev" | |
112 | }; | |
113 | static const char bb_cond_64_names[][5] = { | |
114 | ",*<", ",*>=" | |
115 | }; | |
252b5132 RH |
116 | static const char index_compl_names[][4] = {"", ",m", ",s", ",sm"}; |
117 | static const char short_ldst_compl_names[][4] = {"", ",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 float_comp_names[][8] = | |
123 | { | |
124 | ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>", | |
125 | ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>", | |
126 | ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<", | |
127 | ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true" | |
128 | }; | |
1eee34f5 JL |
129 | static const char *const signed_unsigned_names[][3] = {",u", ",s"}; |
130 | static const char *const mix_half_names[][3] = {",l", ",r"}; | |
3b67cf2b JL |
131 | static const char *const saturation_names[][4] = {",us", ",ss", 0, ""}; |
132 | static const char *const read_write_names[][3] = {",r", ",w"}; | |
133 | static const char *const add_compl_names[] = { | |
134 | 0, "", ",l", ",tsv" | |
135 | }; | |
252b5132 RH |
136 | |
137 | /* For a bunch of different instructions form an index into a | |
138 | completer name table. */ | |
139 | #define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \ | |
140 | GET_FIELD (insn, 18, 18) << 1) | |
141 | ||
142 | #define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \ | |
143 | (GET_FIELD ((insn), 19, 19) ? 8 : 0)) | |
144 | ||
145 | /* Utility function to print registers. Put these first, so gcc's function | |
146 | inlining can do its stuff. */ | |
147 | ||
148 | #define fputs_filtered(STR,F) (*info->fprintf_func) (info->stream, "%s", STR) | |
149 | ||
150 | static void | |
151 | fput_reg (reg, info) | |
152 | unsigned reg; | |
153 | disassemble_info *info; | |
154 | { | |
155 | (*info->fprintf_func) (info->stream, reg ? reg_names[reg] : "r0"); | |
156 | } | |
157 | ||
158 | static void | |
159 | fput_fp_reg (reg, info) | |
160 | unsigned reg; | |
161 | disassemble_info *info; | |
162 | { | |
163 | (*info->fprintf_func) (info->stream, reg ? fp_reg_names[reg] : "fr0"); | |
164 | } | |
165 | ||
166 | static void | |
167 | fput_fp_reg_r (reg, info) | |
168 | unsigned reg; | |
169 | disassemble_info *info; | |
170 | { | |
171 | /* Special case floating point exception registers. */ | |
172 | if (reg < 4) | |
173 | (*info->fprintf_func) (info->stream, "fpe%d", reg * 2 + 1); | |
174 | else | |
175 | (*info->fprintf_func) (info->stream, "%sR", reg ? fp_reg_names[reg] | |
176 | : "fr0"); | |
177 | } | |
178 | ||
179 | static void | |
180 | fput_creg (reg, info) | |
181 | unsigned reg; | |
182 | disassemble_info *info; | |
183 | { | |
184 | (*info->fprintf_func) (info->stream, control_reg[reg]); | |
185 | } | |
186 | ||
187 | /* print constants with sign */ | |
188 | ||
189 | static void | |
190 | fput_const (num, info) | |
191 | unsigned num; | |
192 | disassemble_info *info; | |
193 | { | |
194 | if ((int)num < 0) | |
195 | (*info->fprintf_func) (info->stream, "-%x", -(int)num); | |
196 | else | |
197 | (*info->fprintf_func) (info->stream, "%x", num); | |
198 | } | |
199 | ||
200 | /* Routines to extract various sized constants out of hppa | |
201 | instructions. */ | |
202 | ||
203 | /* extract a 3-bit space register number from a be, ble, mtsp or mfsp */ | |
204 | static int | |
205 | extract_3 (word) | |
206 | unsigned word; | |
207 | { | |
208 | return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17); | |
209 | } | |
210 | ||
211 | static int | |
212 | extract_5_load (word) | |
213 | unsigned word; | |
214 | { | |
215 | return low_sign_extend (word >> 16 & MASK_5, 5); | |
216 | } | |
217 | ||
218 | /* extract the immediate field from a st{bhw}s instruction */ | |
219 | static int | |
220 | extract_5_store (word) | |
221 | unsigned word; | |
222 | { | |
223 | return low_sign_extend (word & MASK_5, 5); | |
224 | } | |
225 | ||
226 | /* extract the immediate field from a break instruction */ | |
227 | static unsigned | |
228 | extract_5r_store (word) | |
229 | unsigned word; | |
230 | { | |
231 | return (word & MASK_5); | |
232 | } | |
233 | ||
234 | /* extract the immediate field from a {sr}sm instruction */ | |
235 | static unsigned | |
236 | extract_5R_store (word) | |
237 | unsigned word; | |
238 | { | |
239 | return (word >> 16 & MASK_5); | |
240 | } | |
241 | ||
3b67cf2b JL |
242 | /* extract the 10 bit immediate field from a {sr}sm instruction */ |
243 | static unsigned | |
244 | extract_10U_store (word) | |
245 | unsigned word; | |
246 | { | |
247 | return (word >> 16 & MASK_10); | |
248 | } | |
249 | ||
252b5132 RH |
250 | /* extract the immediate field from a bb instruction */ |
251 | static unsigned | |
252 | extract_5Q_store (word) | |
253 | unsigned word; | |
254 | { | |
255 | return (word >> 21 & MASK_5); | |
256 | } | |
257 | ||
258 | /* extract an 11 bit immediate field */ | |
259 | static int | |
260 | extract_11 (word) | |
261 | unsigned word; | |
262 | { | |
263 | return low_sign_extend (word & MASK_11, 11); | |
264 | } | |
265 | ||
266 | /* extract a 14 bit immediate field */ | |
267 | static int | |
268 | extract_14 (word) | |
269 | unsigned word; | |
270 | { | |
271 | return low_sign_extend (word & MASK_14, 14); | |
272 | } | |
273 | ||
274 | /* extract a 21 bit constant */ | |
275 | ||
276 | static int | |
277 | extract_21 (word) | |
278 | unsigned word; | |
279 | { | |
280 | int val; | |
281 | ||
282 | word &= MASK_21; | |
283 | word <<= 11; | |
284 | val = GET_FIELD (word, 20, 20); | |
285 | val <<= 11; | |
286 | val |= GET_FIELD (word, 9, 19); | |
287 | val <<= 2; | |
288 | val |= GET_FIELD (word, 5, 6); | |
289 | val <<= 5; | |
290 | val |= GET_FIELD (word, 0, 4); | |
291 | val <<= 2; | |
292 | val |= GET_FIELD (word, 7, 8); | |
293 | return sign_extend (val, 21) << 11; | |
294 | } | |
295 | ||
296 | /* extract a 12 bit constant from branch instructions */ | |
297 | ||
298 | static int | |
299 | extract_12 (word) | |
300 | unsigned word; | |
301 | { | |
302 | return sign_extend (GET_FIELD (word, 19, 28) | | |
303 | GET_FIELD (word, 29, 29) << 10 | | |
304 | (word & 0x1) << 11, 12) << 2; | |
305 | } | |
306 | ||
307 | /* extract a 17 bit constant from branch instructions, returning the | |
308 | 19 bit signed value. */ | |
309 | ||
310 | static int | |
311 | extract_17 (word) | |
312 | unsigned word; | |
313 | { | |
314 | return sign_extend (GET_FIELD (word, 19, 28) | | |
315 | GET_FIELD (word, 29, 29) << 10 | | |
316 | GET_FIELD (word, 11, 15) << 11 | | |
317 | (word & 0x1) << 16, 17) << 2; | |
318 | } | |
319 | ||
320 | /* Print one instruction. */ | |
321 | int | |
322 | print_insn_hppa (memaddr, info) | |
323 | bfd_vma memaddr; | |
324 | disassemble_info *info; | |
325 | { | |
326 | bfd_byte buffer[4]; | |
327 | unsigned int insn, i; | |
328 | ||
329 | { | |
330 | int status = | |
331 | (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info); | |
332 | if (status != 0) | |
333 | { | |
334 | (*info->memory_error_func) (status, memaddr, info); | |
335 | return -1; | |
336 | } | |
337 | } | |
338 | ||
339 | insn = bfd_getb32 (buffer); | |
340 | ||
341 | for (i = 0; i < NUMOPCODES; ++i) | |
342 | { | |
343 | const struct pa_opcode *opcode = &pa_opcodes[i]; | |
344 | if ((insn & opcode->mask) == opcode->match) | |
345 | { | |
346 | register const char *s; | |
347 | ||
348 | (*info->fprintf_func) (info->stream, "%s", opcode->name); | |
349 | ||
feb12992 | 350 | if (!strchr ("cfCY?-+nHNZFIu", opcode->args[0])) |
252b5132 RH |
351 | (*info->fprintf_func) (info->stream, " "); |
352 | for (s = opcode->args; *s != '\0'; ++s) | |
353 | { | |
354 | switch (*s) | |
355 | { | |
356 | case 'x': | |
357 | fput_reg (GET_FIELD (insn, 11, 15), info); | |
358 | break; | |
359 | case 'X': | |
360 | if (GET_FIELD (insn, 25, 25)) | |
361 | fput_fp_reg_r (GET_FIELD (insn, 11, 15), info); | |
362 | else | |
363 | fput_fp_reg (GET_FIELD (insn, 11, 15), info); | |
364 | break; | |
1eee34f5 | 365 | case 'a': |
252b5132 RH |
366 | case 'b': |
367 | fput_reg (GET_FIELD (insn, 6, 10), info); | |
368 | break; | |
369 | case '^': | |
370 | fput_creg (GET_FIELD (insn, 6, 10), info); | |
371 | break; | |
372 | case 'E': | |
3ea80b33 | 373 | fput_fp_reg (GET_FIELD (insn, 6, 10), info); |
25ef477f | 374 | break; |
252b5132 RH |
375 | case 't': |
376 | fput_reg (GET_FIELD (insn, 27, 31), info); | |
377 | break; | |
378 | case 'v': | |
379 | if (GET_FIELD (insn, 25, 25)) | |
380 | fput_fp_reg_r (GET_FIELD (insn, 27, 31), info); | |
381 | else | |
382 | fput_fp_reg (GET_FIELD (insn, 27, 31), info); | |
383 | break; | |
384 | case 'y': | |
385 | fput_fp_reg (GET_FIELD (insn, 27, 31), info); | |
386 | break; | |
387 | case '4': | |
388 | { | |
389 | int reg = GET_FIELD (insn, 6, 10); | |
390 | ||
391 | reg |= (GET_FIELD (insn, 26, 26) << 4); | |
392 | fput_fp_reg (reg, info); | |
393 | break; | |
394 | } | |
395 | case '6': | |
396 | { | |
397 | int reg = GET_FIELD (insn, 11, 15); | |
398 | ||
399 | reg |= (GET_FIELD (insn, 26, 26) << 4); | |
400 | fput_fp_reg (reg, info); | |
401 | break; | |
402 | } | |
403 | case '7': | |
404 | { | |
405 | int reg = GET_FIELD (insn, 27, 31); | |
406 | ||
407 | reg |= (GET_FIELD (insn, 26, 26) << 4); | |
408 | fput_fp_reg (reg, info); | |
409 | break; | |
410 | } | |
411 | case '8': | |
412 | { | |
413 | int reg = GET_FIELD (insn, 16, 20); | |
414 | ||
415 | reg |= (GET_FIELD (insn, 26, 26) << 4); | |
416 | fput_fp_reg (reg, info); | |
417 | break; | |
418 | } | |
419 | case '9': | |
420 | { | |
421 | int reg = GET_FIELD (insn, 21, 25); | |
422 | ||
423 | reg |= (GET_FIELD (insn, 26, 26) << 4); | |
424 | fput_fp_reg (reg, info); | |
425 | break; | |
426 | } | |
427 | case '5': | |
428 | fput_const (extract_5_load (insn), info); | |
429 | break; | |
430 | case 's': | |
431 | (*info->fprintf_func) (info->stream, | |
432 | "sr%d", GET_FIELD (insn, 16, 17)); | |
433 | break; | |
b333b6c6 | 434 | |
252b5132 RH |
435 | case 'S': |
436 | (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn)); | |
437 | break; | |
3281117a JL |
438 | |
439 | /* Handle completers. */ | |
252b5132 | 440 | case 'c': |
3281117a JL |
441 | switch (*++s) |
442 | { | |
443 | case 'x': | |
444 | (*info->fprintf_func) (info->stream, "%s ", | |
445 | index_compl_names[GET_COMPL (insn)]); | |
446 | break; | |
447 | case 'm': | |
448 | (*info->fprintf_func) (info->stream, "%s ", | |
449 | short_ldst_compl_names[GET_COMPL (insn)]); | |
450 | break; | |
451 | case 's': | |
452 | (*info->fprintf_func) (info->stream, "%s ", | |
453 | short_bytes_compl_names[GET_COMPL (insn)]); | |
454 | break; | |
3b67cf2b JL |
455 | case 'L': |
456 | (*info->fprintf_func) (info->stream, ",l"); | |
457 | break; | |
458 | case 'w': | |
459 | (*info->fprintf_func) (info->stream, "%s ", | |
460 | read_write_names[GET_FIELD (insn, 25, 25)]); | |
461 | break; | |
462 | case 'W': | |
463 | (*info->fprintf_func) (info->stream, ",w"); | |
464 | break; | |
465 | case 'r': | |
466 | if (GET_FIELD (insn, 23, 26) == 5) | |
467 | (*info->fprintf_func) (info->stream, ",r"); | |
468 | break; | |
3281117a JL |
469 | case 'Z': |
470 | if (GET_FIELD (insn, 26, 26)) | |
471 | (*info->fprintf_func) (info->stream, ",m "); | |
472 | else | |
473 | (*info->fprintf_func) (info->stream, " "); | |
474 | break; | |
3b67cf2b JL |
475 | case 'i': |
476 | if (GET_FIELD (insn, 25, 25)) | |
477 | (*info->fprintf_func) (info->stream, ",i"); | |
478 | break; | |
479 | case 'a': | |
480 | (*info->fprintf_func) | |
481 | (info->stream, "%s", add_compl_names[GET_FIELD | |
482 | (insn, 20, 21)]); | |
483 | break; | |
484 | case 'Y': | |
485 | (*info->fprintf_func) | |
486 | (info->stream, ",dc%s", add_compl_names[GET_FIELD | |
487 | (insn, 20, 21)]); | |
488 | break; | |
489 | case 'y': | |
490 | (*info->fprintf_func) | |
491 | (info->stream, ",c%s", add_compl_names[GET_FIELD | |
492 | (insn, 20, 21)]); | |
493 | break; | |
494 | case 'v': | |
495 | if (GET_FIELD (insn, 20, 20)) | |
496 | (*info->fprintf_func) (info->stream, ",tsv"); | |
497 | break; | |
498 | case 't': | |
499 | (*info->fprintf_func) (info->stream, ",tc"); | |
500 | if (GET_FIELD (insn, 20, 20)) | |
501 | (*info->fprintf_func) (info->stream, ",tsv"); | |
502 | break; | |
503 | case 'B': | |
504 | (*info->fprintf_func) (info->stream, ",db"); | |
505 | if (GET_FIELD (insn, 20, 20)) | |
506 | (*info->fprintf_func) (info->stream, ",tsv"); | |
507 | break; | |
508 | case 'b': | |
509 | (*info->fprintf_func) (info->stream, ",b"); | |
510 | if (GET_FIELD (insn, 20, 20)) | |
511 | (*info->fprintf_func) (info->stream, ",tsv"); | |
512 | break; | |
513 | case 'T': | |
514 | if (GET_FIELD (insn, 25, 25)) | |
515 | (*info->fprintf_func) (info->stream, ",tc"); | |
516 | break; | |
1eee34f5 JL |
517 | case 'S': |
518 | /* EXTRD/W has a following condition. */ | |
519 | if (*(s + 1) == '?') | |
520 | (*info->fprintf_func) | |
521 | (info->stream, "%s", signed_unsigned_names[GET_FIELD | |
522 | (insn, 21, 21)]); | |
523 | else | |
524 | (*info->fprintf_func) | |
525 | (info->stream, "%s ", signed_unsigned_names[GET_FIELD | |
526 | (insn, 21, 21)]); | |
527 | break; | |
528 | case 'h': | |
529 | (*info->fprintf_func) | |
530 | (info->stream, "%s", mix_half_names[GET_FIELD | |
531 | (insn, 17, 17)]); | |
532 | break; | |
533 | case 'H': | |
534 | (*info->fprintf_func) | |
535 | (info->stream, "%s", saturation_names[GET_FIELD | |
536 | (insn, 24, 25)]); | |
537 | break; | |
538 | case '*': | |
539 | (*info->fprintf_func) | |
540 | (info->stream, ",%d%d%d%d ", | |
541 | GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21), | |
542 | GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25)); | |
543 | break; | |
3281117a | 544 | } |
252b5132 | 545 | break; |
feb12992 JL |
546 | |
547 | /* Handle conditions. */ | |
252b5132 | 548 | case '?': |
feb12992 JL |
549 | { |
550 | s++; | |
551 | switch (*s) | |
552 | { | |
553 | case 'f': | |
554 | (*info->fprintf_func) (info->stream, "%s ", | |
555 | float_comp_names[GET_FIELD | |
556 | (insn, 27, 31)]); | |
557 | break; | |
558 | ||
559 | /* these four conditions are for the set of instructions | |
560 | which distinguish true/false conditions by opcode | |
561 | rather than by the 'f' bit (sigh): comb, comib, | |
562 | addb, addib */ | |
563 | case 't': | |
564 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, | |
565 | 18)], | |
566 | info); | |
567 | break; | |
b333b6c6 JL |
568 | case 'T': |
569 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18) | |
570 | + 8], info); | |
571 | break; | |
572 | case 'r': | |
573 | fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)], | |
574 | info); | |
575 | break; | |
576 | case 'R': | |
577 | fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18) | |
578 | + 8], info); | |
579 | break; | |
580 | case 'Q': | |
581 | fputs_filtered (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)], | |
582 | info); | |
583 | break; | |
feb12992 JL |
584 | case 'n': |
585 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, | |
586 | 18) | |
587 | + GET_FIELD (insn, 4, 4) * 8], info); | |
588 | break; | |
589 | case '@': | |
590 | fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18) | |
591 | + GET_FIELD (insn, 4, 4) * 8], info); | |
592 | break; | |
593 | case 's': | |
594 | (*info->fprintf_func) (info->stream, "%s ", | |
595 | compare_cond_names[GET_COND (insn)]); | |
596 | break; | |
b333b6c6 JL |
597 | case 'S': |
598 | (*info->fprintf_func) (info->stream, "%s ", | |
599 | compare_cond_64_names[GET_COND (insn)]); | |
600 | break; | |
feb12992 JL |
601 | case 'a': |
602 | (*info->fprintf_func) (info->stream, "%s ", | |
603 | add_cond_names[GET_COND (insn)]); | |
604 | break; | |
b333b6c6 JL |
605 | case 'A': |
606 | (*info->fprintf_func) (info->stream, "%s ", | |
607 | add_cond_64_names[GET_COND (insn)]); | |
608 | break; | |
feb12992 JL |
609 | case 'd': |
610 | (*info->fprintf_func) (info->stream, "%s", | |
611 | add_cond_names[GET_FIELD (insn, | |
612 | 16, | |
613 | 18)]); | |
614 | break; | |
b333b6c6 JL |
615 | case 'D': |
616 | (*info->fprintf_func) (info->stream, "%s", | |
617 | add_cond_names[GET_FIELD (insn, | |
618 | 16, 18) | |
619 | + 8]); | |
620 | break; | |
621 | case 'w': | |
622 | (*info->fprintf_func) | |
623 | (info->stream, "%s", | |
624 | wide_add_cond_names[GET_FIELD (insn, 16, 18)]); | |
625 | break; | |
626 | ||
627 | case 'W': | |
628 | (*info->fprintf_func) | |
629 | (info->stream, "%s", | |
630 | wide_add_cond_names[GET_FIELD (insn, 16, 18) + 8]); | |
631 | break; | |
feb12992 JL |
632 | |
633 | case 'l': | |
634 | (*info->fprintf_func) (info->stream, "%s ", | |
635 | logical_cond_names[GET_COND (insn)]); | |
636 | break; | |
b333b6c6 JL |
637 | case 'L': |
638 | (*info->fprintf_func) (info->stream, "%s ", | |
639 | logical_cond_64_names[GET_COND (insn)]); | |
640 | break; | |
feb12992 JL |
641 | case 'u': |
642 | (*info->fprintf_func) (info->stream, "%s ", | |
643 | unit_cond_names[GET_COND (insn)]); | |
644 | break; | |
b333b6c6 JL |
645 | case 'U': |
646 | (*info->fprintf_func) (info->stream, "%s ", | |
647 | unit_cond_64_names[GET_COND (insn)]); | |
648 | break; | |
feb12992 JL |
649 | case 'y': |
650 | case 'x': | |
651 | case 'b': | |
652 | (*info->fprintf_func) | |
653 | (info->stream, "%s", | |
654 | shift_cond_names[GET_FIELD (insn, 16, 18)]); | |
655 | ||
656 | /* If the next character in args is 'n', it will handle | |
657 | putting out the space. */ | |
658 | if (s[1] != 'n') | |
659 | (*info->fprintf_func) (info->stream, " "); | |
660 | break; | |
b333b6c6 JL |
661 | case 'X': |
662 | (*info->fprintf_func) (info->stream, "%s", | |
663 | shift_cond_64_names[GET_FIELD (insn, 16, 18)]); | |
664 | break; | |
665 | case 'B': | |
666 | (*info->fprintf_func) | |
667 | (info->stream, "%s", | |
668 | bb_cond_64_names[GET_FIELD (insn, 16, 16)]); | |
feb12992 | 669 | |
b333b6c6 JL |
670 | /* If the next character in args is 'n', it will handle |
671 | putting out the space. */ | |
672 | if (s[1] != 'n') | |
673 | (*info->fprintf_func) (info->stream, " "); | |
674 | break; | |
feb12992 JL |
675 | } |
676 | break; | |
677 | } | |
252b5132 | 678 | |
252b5132 RH |
679 | case 'V': |
680 | fput_const (extract_5_store (insn), info); | |
681 | break; | |
682 | case 'r': | |
683 | fput_const (extract_5r_store (insn), info); | |
684 | break; | |
685 | case 'R': | |
686 | fput_const (extract_5R_store (insn), info); | |
687 | break; | |
3b67cf2b JL |
688 | case 'U': |
689 | fput_const (extract_10U_store (insn), info); | |
690 | break; | |
252b5132 RH |
691 | case 'Q': |
692 | fput_const (extract_5Q_store (insn), info); | |
693 | break; | |
694 | case 'i': | |
695 | fput_const (extract_11 (insn), info); | |
696 | break; | |
697 | case 'j': | |
698 | fput_const (extract_14 (insn), info); | |
699 | break; | |
700 | case 'k': | |
701 | fput_const (extract_21 (insn), info); | |
702 | break; | |
703 | case 'n': | |
704 | if (insn & 0x2) | |
705 | (*info->fprintf_func) (info->stream, ",n "); | |
706 | else | |
707 | (*info->fprintf_func) (info->stream, " "); | |
708 | break; | |
709 | case 'N': | |
710 | if ((insn & 0x20) && s[1]) | |
711 | (*info->fprintf_func) (info->stream, ",n "); | |
712 | else if (insn & 0x20) | |
713 | (*info->fprintf_func) (info->stream, ",n"); | |
714 | else if (s[1]) | |
715 | (*info->fprintf_func) (info->stream, " "); | |
716 | break; | |
717 | case 'w': | |
718 | (*info->print_address_func) (memaddr + 8 + extract_12 (insn), | |
719 | info); | |
720 | break; | |
721 | case 'W': | |
722 | /* 17 bit PC-relative branch. */ | |
723 | (*info->print_address_func) ((memaddr + 8 | |
724 | + extract_17 (insn)), | |
725 | info); | |
726 | break; | |
727 | case 'z': | |
728 | /* 17 bit displacement. This is an offset from a register | |
729 | so it gets disasssembled as just a number, not any sort | |
730 | of address. */ | |
731 | fput_const (extract_17 (insn), info); | |
732 | break; | |
46424e05 JL |
733 | case '.': |
734 | (*info->fprintf_func) (info->stream, "%d", | |
735 | GET_FIELD (insn, 24, 25)); | |
736 | break; | |
3b67cf2b JL |
737 | case '*': |
738 | (*info->fprintf_func) (info->stream, "%d", | |
739 | GET_FIELD (insn, 22, 25)); | |
740 | break; | |
b7d6d485 JL |
741 | case '!': |
742 | (*info->fprintf_func) (info->stream, "%sar"); | |
743 | break; | |
252b5132 RH |
744 | case 'p': |
745 | (*info->fprintf_func) (info->stream, "%d", | |
746 | 31 - GET_FIELD (insn, 22, 26)); | |
747 | break; | |
46424e05 JL |
748 | case '~': |
749 | { | |
750 | int num; | |
751 | num = GET_FIELD (insn, 20, 20) << 5; | |
752 | num |= GET_FIELD (insn, 22, 26); | |
753 | (*info->fprintf_func) (info->stream, "%d", 63 - num); | |
754 | break; | |
755 | } | |
252b5132 RH |
756 | case 'P': |
757 | (*info->fprintf_func) (info->stream, "%d", | |
758 | GET_FIELD (insn, 22, 26)); | |
759 | break; | |
760 | case 'T': | |
761 | (*info->fprintf_func) (info->stream, "%d", | |
762 | 32 - GET_FIELD (insn, 27, 31)); | |
763 | break; | |
46424e05 JL |
764 | case '$': |
765 | fput_const (GET_FIELD (insn, 20, 28), info); | |
766 | break; | |
252b5132 RH |
767 | case 'A': |
768 | fput_const (GET_FIELD (insn, 6, 18), info); | |
769 | break; | |
252b5132 RH |
770 | case 'D': |
771 | fput_const (GET_FIELD (insn, 6, 31), info); | |
772 | break; | |
773 | case 'f': | |
774 | (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25)); | |
775 | break; | |
776 | case 'O': | |
777 | fput_const ((GET_FIELD (insn, 6,20) << 5 | | |
778 | GET_FIELD (insn, 27, 31)), info); | |
779 | break; | |
780 | case 'o': | |
781 | fput_const (GET_FIELD (insn, 6, 20), info); | |
782 | break; | |
783 | case '3': | |
784 | { | |
785 | int reg = GET_FIELD (insn, 21, 22); | |
786 | reg |= GET_FIELD (insn, 16, 18) << 2; | |
787 | if (GET_FIELD (insn, 23, 23) != 0) | |
788 | fput_fp_reg_r (reg, info); | |
789 | else | |
790 | fput_fp_reg (reg, info); | |
791 | break; | |
792 | } | |
793 | ||
794 | case '2': | |
795 | fput_const ((GET_FIELD (insn, 6, 22) << 5 | | |
796 | GET_FIELD (insn, 27, 31)), info); | |
797 | break; | |
798 | case '1': | |
799 | fput_const ((GET_FIELD (insn, 11, 20) << 5 | | |
800 | GET_FIELD (insn, 27, 31)), info); | |
801 | break; | |
802 | case '0': | |
803 | fput_const ((GET_FIELD (insn, 16, 20) << 5 | | |
804 | GET_FIELD (insn, 27, 31)), info); | |
805 | break; | |
806 | case 'u': | |
807 | (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25)); | |
808 | break; | |
809 | case 'F': | |
810 | /* if no destination completer and not before a completer | |
811 | for fcmp, need a space here */ | |
4f312591 | 812 | if (s[1] == 'G' || s[1] == '?') |
252b5132 RH |
813 | fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)], |
814 | info); | |
815 | else | |
816 | (*info->fprintf_func) (info->stream, "%s ", | |
817 | float_format_names[GET_FIELD | |
818 | (insn, 19, 20)]); | |
819 | break; | |
820 | case 'G': | |
821 | (*info->fprintf_func) (info->stream, "%s ", | |
822 | float_format_names[GET_FIELD (insn, | |
823 | 17, 18)]); | |
824 | break; | |
825 | case 'H': | |
826 | if (GET_FIELD (insn, 26, 26) == 1) | |
827 | (*info->fprintf_func) (info->stream, "%s ", | |
828 | float_format_names[0]); | |
829 | else | |
830 | (*info->fprintf_func) (info->stream, "%s ", | |
831 | float_format_names[1]); | |
832 | break; | |
833 | case 'I': | |
834 | /* if no destination completer and not before a completer | |
835 | for fcmp, need a space here */ | |
4f312591 | 836 | if (s[1] == '?') |
252b5132 RH |
837 | fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)], |
838 | info); | |
839 | else | |
840 | (*info->fprintf_func) (info->stream, "%s ", | |
841 | float_format_names[GET_FIELD | |
842 | (insn, 20, 20)]); | |
843 | break; | |
844 | case 'J': | |
845 | if (GET_FIELD (insn, 24, 24)) | |
846 | fput_fp_reg_r (GET_FIELD (insn, 6, 10), info); | |
847 | else | |
848 | fput_fp_reg (GET_FIELD (insn, 6, 10), info); | |
849 | ||
850 | break; | |
851 | case 'K': | |
852 | if (GET_FIELD (insn, 19, 19)) | |
853 | fput_fp_reg_r (GET_FIELD (insn, 11, 15), info); | |
854 | else | |
855 | fput_fp_reg (GET_FIELD (insn, 11, 15), info); | |
856 | break; | |
252b5132 RH |
857 | default: |
858 | (*info->fprintf_func) (info->stream, "%c", *s); | |
859 | break; | |
860 | } | |
861 | } | |
862 | return sizeof(insn); | |
863 | } | |
864 | } | |
865 | (*info->fprintf_func) (info->stream, "#%8x", insn); | |
866 | return sizeof(insn); | |
867 | } |