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