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