]>
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 ([email protected]). | |
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 | } | |
466 | } | |
2f87f883 | 467 | break; |
252b5132 | 468 | |
252b5132 RH |
469 | case '5': |
470 | fput_const (extract_5_load (insn), info); | |
471 | break; | |
472 | case 's': | |
473 | (*info->fprintf_func) (info->stream, | |
474 | "sr%d", GET_FIELD (insn, 16, 17)); | |
475 | break; | |
b333b6c6 | 476 | |
252b5132 RH |
477 | case 'S': |
478 | (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn)); | |
479 | break; | |
3281117a JL |
480 | |
481 | /* Handle completers. */ | |
252b5132 | 482 | case 'c': |
3281117a JL |
483 | switch (*++s) |
484 | { | |
485 | case 'x': | |
486 | (*info->fprintf_func) (info->stream, "%s ", | |
487 | index_compl_names[GET_COMPL (insn)]); | |
488 | break; | |
489 | case 'm': | |
490 | (*info->fprintf_func) (info->stream, "%s ", | |
491 | short_ldst_compl_names[GET_COMPL (insn)]); | |
492 | break; | |
493 | case 's': | |
494 | (*info->fprintf_func) (info->stream, "%s ", | |
495 | short_bytes_compl_names[GET_COMPL (insn)]); | |
496 | break; | |
3b67cf2b JL |
497 | case 'L': |
498 | (*info->fprintf_func) (info->stream, ",l"); | |
499 | break; | |
500 | case 'w': | |
501 | (*info->fprintf_func) (info->stream, "%s ", | |
502 | read_write_names[GET_FIELD (insn, 25, 25)]); | |
503 | break; | |
504 | case 'W': | |
505 | (*info->fprintf_func) (info->stream, ",w"); | |
506 | break; | |
507 | case 'r': | |
508 | if (GET_FIELD (insn, 23, 26) == 5) | |
509 | (*info->fprintf_func) (info->stream, ",r"); | |
510 | break; | |
3281117a JL |
511 | case 'Z': |
512 | if (GET_FIELD (insn, 26, 26)) | |
513 | (*info->fprintf_func) (info->stream, ",m "); | |
514 | else | |
515 | (*info->fprintf_func) (info->stream, " "); | |
516 | break; | |
3b67cf2b JL |
517 | case 'i': |
518 | if (GET_FIELD (insn, 25, 25)) | |
519 | (*info->fprintf_func) (info->stream, ",i"); | |
520 | break; | |
af10de82 JL |
521 | case 'z': |
522 | if (!GET_FIELD (insn, 21, 21)) | |
523 | (*info->fprintf_func) (info->stream, ",z"); | |
524 | break; | |
3b67cf2b JL |
525 | case 'a': |
526 | (*info->fprintf_func) | |
527 | (info->stream, "%s", add_compl_names[GET_FIELD | |
528 | (insn, 20, 21)]); | |
529 | break; | |
530 | case 'Y': | |
531 | (*info->fprintf_func) | |
532 | (info->stream, ",dc%s", add_compl_names[GET_FIELD | |
533 | (insn, 20, 21)]); | |
534 | break; | |
535 | case 'y': | |
536 | (*info->fprintf_func) | |
537 | (info->stream, ",c%s", add_compl_names[GET_FIELD | |
538 | (insn, 20, 21)]); | |
539 | break; | |
540 | case 'v': | |
541 | if (GET_FIELD (insn, 20, 20)) | |
542 | (*info->fprintf_func) (info->stream, ",tsv"); | |
543 | break; | |
544 | case 't': | |
545 | (*info->fprintf_func) (info->stream, ",tc"); | |
546 | if (GET_FIELD (insn, 20, 20)) | |
547 | (*info->fprintf_func) (info->stream, ",tsv"); | |
548 | break; | |
549 | case 'B': | |
550 | (*info->fprintf_func) (info->stream, ",db"); | |
551 | if (GET_FIELD (insn, 20, 20)) | |
552 | (*info->fprintf_func) (info->stream, ",tsv"); | |
553 | break; | |
554 | case 'b': | |
555 | (*info->fprintf_func) (info->stream, ",b"); | |
556 | if (GET_FIELD (insn, 20, 20)) | |
557 | (*info->fprintf_func) (info->stream, ",tsv"); | |
558 | break; | |
559 | case 'T': | |
560 | if (GET_FIELD (insn, 25, 25)) | |
561 | (*info->fprintf_func) (info->stream, ",tc"); | |
562 | break; | |
1eee34f5 JL |
563 | case 'S': |
564 | /* EXTRD/W has a following condition. */ | |
565 | if (*(s + 1) == '?') | |
566 | (*info->fprintf_func) | |
567 | (info->stream, "%s", signed_unsigned_names[GET_FIELD | |
568 | (insn, 21, 21)]); | |
569 | else | |
570 | (*info->fprintf_func) | |
571 | (info->stream, "%s ", signed_unsigned_names[GET_FIELD | |
572 | (insn, 21, 21)]); | |
573 | break; | |
574 | case 'h': | |
575 | (*info->fprintf_func) | |
576 | (info->stream, "%s", mix_half_names[GET_FIELD | |
577 | (insn, 17, 17)]); | |
578 | break; | |
579 | case 'H': | |
580 | (*info->fprintf_func) | |
581 | (info->stream, "%s", saturation_names[GET_FIELD | |
582 | (insn, 24, 25)]); | |
583 | break; | |
584 | case '*': | |
585 | (*info->fprintf_func) | |
586 | (info->stream, ",%d%d%d%d ", | |
587 | GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21), | |
588 | GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25)); | |
589 | break; | |
3281117a | 590 | } |
252b5132 | 591 | break; |
feb12992 JL |
592 | |
593 | /* Handle conditions. */ | |
252b5132 | 594 | case '?': |
feb12992 JL |
595 | { |
596 | s++; | |
597 | switch (*s) | |
598 | { | |
599 | case 'f': | |
600 | (*info->fprintf_func) (info->stream, "%s ", | |
601 | float_comp_names[GET_FIELD | |
602 | (insn, 27, 31)]); | |
603 | break; | |
604 | ||
605 | /* these four conditions are for the set of instructions | |
606 | which distinguish true/false conditions by opcode | |
607 | rather than by the 'f' bit (sigh): comb, comib, | |
608 | addb, addib */ | |
609 | case 't': | |
a349b151 | 610 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)], |
feb12992 JL |
611 | info); |
612 | break; | |
b333b6c6 JL |
613 | case 'T': |
614 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18) | |
615 | + 8], info); | |
616 | break; | |
617 | case 'r': | |
618 | fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)], | |
619 | info); | |
620 | break; | |
621 | case 'R': | |
622 | fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18) | |
623 | + 8], info); | |
624 | break; | |
625 | case 'Q': | |
626 | fputs_filtered (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)], | |
627 | info); | |
628 | break; | |
feb12992 | 629 | case 'n': |
a349b151 | 630 | fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18) |
feb12992 JL |
631 | + GET_FIELD (insn, 4, 4) * 8], info); |
632 | break; | |
633 | case '@': | |
634 | fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18) | |
635 | + GET_FIELD (insn, 4, 4) * 8], info); | |
636 | break; | |
637 | case 's': | |
638 | (*info->fprintf_func) (info->stream, "%s ", | |
639 | compare_cond_names[GET_COND (insn)]); | |
640 | break; | |
b333b6c6 JL |
641 | case 'S': |
642 | (*info->fprintf_func) (info->stream, "%s ", | |
643 | compare_cond_64_names[GET_COND (insn)]); | |
644 | break; | |
feb12992 JL |
645 | case 'a': |
646 | (*info->fprintf_func) (info->stream, "%s ", | |
647 | add_cond_names[GET_COND (insn)]); | |
648 | break; | |
b333b6c6 JL |
649 | case 'A': |
650 | (*info->fprintf_func) (info->stream, "%s ", | |
651 | add_cond_64_names[GET_COND (insn)]); | |
652 | break; | |
feb12992 JL |
653 | case 'd': |
654 | (*info->fprintf_func) (info->stream, "%s", | |
a349b151 | 655 | add_cond_names[GET_FIELD (insn, 16, 18)]); |
feb12992 | 656 | break; |
a349b151 | 657 | |
b333b6c6 JL |
658 | case 'D': |
659 | (*info->fprintf_func) (info->stream, "%s", | |
a349b151 JL |
660 | add_cond_names[GET_FIELD (insn, 16, 18) |
661 | + 8]); | |
b333b6c6 JL |
662 | break; |
663 | case 'w': | |
a349b151 | 664 | (*info->fprintf_func) |
b333b6c6 JL |
665 | (info->stream, "%s", |
666 | wide_add_cond_names[GET_FIELD (insn, 16, 18)]); | |
667 | break; | |
668 | ||
669 | case 'W': | |
a349b151 | 670 | (*info->fprintf_func) |
b333b6c6 JL |
671 | (info->stream, "%s", |
672 | wide_add_cond_names[GET_FIELD (insn, 16, 18) + 8]); | |
673 | break; | |
feb12992 JL |
674 | |
675 | case 'l': | |
676 | (*info->fprintf_func) (info->stream, "%s ", | |
677 | logical_cond_names[GET_COND (insn)]); | |
678 | break; | |
b333b6c6 JL |
679 | case 'L': |
680 | (*info->fprintf_func) (info->stream, "%s ", | |
681 | logical_cond_64_names[GET_COND (insn)]); | |
682 | break; | |
feb12992 JL |
683 | case 'u': |
684 | (*info->fprintf_func) (info->stream, "%s ", | |
685 | unit_cond_names[GET_COND (insn)]); | |
686 | break; | |
b333b6c6 JL |
687 | case 'U': |
688 | (*info->fprintf_func) (info->stream, "%s ", | |
689 | unit_cond_64_names[GET_COND (insn)]); | |
690 | break; | |
feb12992 JL |
691 | case 'y': |
692 | case 'x': | |
693 | case 'b': | |
694 | (*info->fprintf_func) | |
695 | (info->stream, "%s", | |
696 | shift_cond_names[GET_FIELD (insn, 16, 18)]); | |
697 | ||
698 | /* If the next character in args is 'n', it will handle | |
699 | putting out the space. */ | |
700 | if (s[1] != 'n') | |
701 | (*info->fprintf_func) (info->stream, " "); | |
702 | break; | |
b333b6c6 | 703 | case 'X': |
e46def7b | 704 | (*info->fprintf_func) (info->stream, "%s ", |
b333b6c6 JL |
705 | shift_cond_64_names[GET_FIELD (insn, 16, 18)]); |
706 | break; | |
707 | case 'B': | |
708 | (*info->fprintf_func) | |
709 | (info->stream, "%s", | |
710 | bb_cond_64_names[GET_FIELD (insn, 16, 16)]); | |
feb12992 | 711 | |
b333b6c6 JL |
712 | /* If the next character in args is 'n', it will handle |
713 | putting out the space. */ | |
714 | if (s[1] != 'n') | |
715 | (*info->fprintf_func) (info->stream, " "); | |
716 | break; | |
feb12992 JL |
717 | } |
718 | break; | |
719 | } | |
252b5132 | 720 | |
252b5132 RH |
721 | case 'V': |
722 | fput_const (extract_5_store (insn), info); | |
723 | break; | |
724 | case 'r': | |
725 | fput_const (extract_5r_store (insn), info); | |
726 | break; | |
727 | case 'R': | |
728 | fput_const (extract_5R_store (insn), info); | |
729 | break; | |
3b67cf2b JL |
730 | case 'U': |
731 | fput_const (extract_10U_store (insn), info); | |
732 | break; | |
252b5132 RH |
733 | case 'Q': |
734 | fput_const (extract_5Q_store (insn), info); | |
735 | break; | |
736 | case 'i': | |
737 | fput_const (extract_11 (insn), info); | |
738 | break; | |
739 | case 'j': | |
740 | fput_const (extract_14 (insn), info); | |
741 | break; | |
742 | case 'k': | |
743 | fput_const (extract_21 (insn), info); | |
744 | break; | |
745 | case 'n': | |
746 | if (insn & 0x2) | |
747 | (*info->fprintf_func) (info->stream, ",n "); | |
748 | else | |
749 | (*info->fprintf_func) (info->stream, " "); | |
750 | break; | |
751 | case 'N': | |
752 | if ((insn & 0x20) && s[1]) | |
753 | (*info->fprintf_func) (info->stream, ",n "); | |
754 | else if (insn & 0x20) | |
755 | (*info->fprintf_func) (info->stream, ",n"); | |
756 | else if (s[1]) | |
757 | (*info->fprintf_func) (info->stream, " "); | |
758 | break; | |
759 | case 'w': | |
760 | (*info->print_address_func) (memaddr + 8 + extract_12 (insn), | |
761 | info); | |
762 | break; | |
763 | case 'W': | |
764 | /* 17 bit PC-relative branch. */ | |
765 | (*info->print_address_func) ((memaddr + 8 | |
766 | + extract_17 (insn)), | |
767 | info); | |
768 | break; | |
769 | case 'z': | |
770 | /* 17 bit displacement. This is an offset from a register | |
771 | so it gets disasssembled as just a number, not any sort | |
772 | of address. */ | |
773 | fput_const (extract_17 (insn), info); | |
774 | break; | |
d1e9bd1f JL |
775 | |
776 | case 'Z': | |
777 | /* addil %r1 implicit output. */ | |
2beaab59 | 778 | (*info->fprintf_func) (info->stream, "%%r1"); |
d1e9bd1f JL |
779 | break; |
780 | ||
46424e05 JL |
781 | case '.': |
782 | (*info->fprintf_func) (info->stream, "%d", | |
783 | GET_FIELD (insn, 24, 25)); | |
784 | break; | |
3b67cf2b JL |
785 | case '*': |
786 | (*info->fprintf_func) (info->stream, "%d", | |
787 | GET_FIELD (insn, 22, 25)); | |
788 | break; | |
b7d6d485 | 789 | case '!': |
2beaab59 | 790 | (*info->fprintf_func) (info->stream, "%%sar"); |
b7d6d485 | 791 | break; |
252b5132 RH |
792 | case 'p': |
793 | (*info->fprintf_func) (info->stream, "%d", | |
794 | 31 - GET_FIELD (insn, 22, 26)); | |
795 | break; | |
46424e05 JL |
796 | case '~': |
797 | { | |
798 | int num; | |
799 | num = GET_FIELD (insn, 20, 20) << 5; | |
800 | num |= GET_FIELD (insn, 22, 26); | |
801 | (*info->fprintf_func) (info->stream, "%d", 63 - num); | |
802 | break; | |
803 | } | |
252b5132 RH |
804 | case 'P': |
805 | (*info->fprintf_func) (info->stream, "%d", | |
806 | GET_FIELD (insn, 22, 26)); | |
807 | break; | |
af10de82 JL |
808 | case 'q': |
809 | { | |
810 | int num; | |
811 | num = GET_FIELD (insn, 20, 20) << 5; | |
812 | num |= GET_FIELD (insn, 22, 26); | |
813 | (*info->fprintf_func) (info->stream, "%d", num); | |
814 | break; | |
815 | } | |
252b5132 RH |
816 | case 'T': |
817 | (*info->fprintf_func) (info->stream, "%d", | |
818 | 32 - GET_FIELD (insn, 27, 31)); | |
819 | break; | |
af10de82 JL |
820 | case '%': |
821 | { | |
822 | int num; | |
823 | num = (GET_FIELD (insn, 23, 23) + 1) * 32; | |
824 | num -= GET_FIELD (insn, 27, 31); | |
825 | (*info->fprintf_func) (info->stream, "%d", num); | |
826 | break; | |
827 | } | |
828 | case '|': | |
829 | { | |
830 | int num; | |
831 | num = (GET_FIELD (insn, 19, 19) + 1) * 32; | |
832 | num -= GET_FIELD (insn, 27, 31); | |
833 | (*info->fprintf_func) (info->stream, "%d", num); | |
834 | break; | |
835 | } | |
46424e05 JL |
836 | case '$': |
837 | fput_const (GET_FIELD (insn, 20, 28), info); | |
838 | break; | |
252b5132 RH |
839 | case 'A': |
840 | fput_const (GET_FIELD (insn, 6, 18), info); | |
841 | break; | |
252b5132 RH |
842 | case 'D': |
843 | fput_const (GET_FIELD (insn, 6, 31), info); | |
844 | break; | |
a349b151 | 845 | case 'v': |
252b5132 RH |
846 | (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25)); |
847 | break; | |
848 | case 'O': | |
849 | fput_const ((GET_FIELD (insn, 6,20) << 5 | | |
850 | GET_FIELD (insn, 27, 31)), info); | |
851 | break; | |
852 | case 'o': | |
853 | fput_const (GET_FIELD (insn, 6, 20), info); | |
854 | break; | |
252b5132 RH |
855 | case '2': |
856 | fput_const ((GET_FIELD (insn, 6, 22) << 5 | | |
857 | GET_FIELD (insn, 27, 31)), info); | |
858 | break; | |
859 | case '1': | |
860 | fput_const ((GET_FIELD (insn, 11, 20) << 5 | | |
861 | GET_FIELD (insn, 27, 31)), info); | |
862 | break; | |
863 | case '0': | |
864 | fput_const ((GET_FIELD (insn, 16, 20) << 5 | | |
865 | GET_FIELD (insn, 27, 31)), info); | |
866 | break; | |
867 | case 'u': | |
868 | (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25)); | |
869 | break; | |
870 | case 'F': | |
871 | /* if no destination completer and not before a completer | |
872 | for fcmp, need a space here */ | |
4f312591 | 873 | if (s[1] == 'G' || s[1] == '?') |
252b5132 RH |
874 | fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)], |
875 | info); | |
876 | else | |
877 | (*info->fprintf_func) (info->stream, "%s ", | |
878 | float_format_names[GET_FIELD | |
879 | (insn, 19, 20)]); | |
880 | break; | |
881 | case 'G': | |
882 | (*info->fprintf_func) (info->stream, "%s ", | |
883 | float_format_names[GET_FIELD (insn, | |
884 | 17, 18)]); | |
885 | break; | |
886 | case 'H': | |
887 | if (GET_FIELD (insn, 26, 26) == 1) | |
888 | (*info->fprintf_func) (info->stream, "%s ", | |
889 | float_format_names[0]); | |
890 | else | |
891 | (*info->fprintf_func) (info->stream, "%s ", | |
892 | float_format_names[1]); | |
893 | break; | |
894 | case 'I': | |
895 | /* if no destination completer and not before a completer | |
896 | for fcmp, need a space here */ | |
4f312591 | 897 | if (s[1] == '?') |
252b5132 RH |
898 | fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)], |
899 | info); | |
900 | else | |
901 | (*info->fprintf_func) (info->stream, "%s ", | |
902 | float_format_names[GET_FIELD | |
903 | (insn, 20, 20)]); | |
904 | break; | |
2784abe5 JL |
905 | case 'M': |
906 | fputs_filtered (",push", info); | |
907 | break; | |
908 | case 'L': | |
909 | fputs_filtered (",%r2", info); | |
910 | break; | |
321e8dac JL |
911 | case 'g': |
912 | fputs_filtered (",gate", info); | |
913 | break; | |
a5c4b2b4 JL |
914 | case 'l': |
915 | fputs_filtered (",l", info); | |
916 | break; | |
252b5132 RH |
917 | default: |
918 | (*info->fprintf_func) (info->stream, "%c", *s); | |
919 | break; | |
920 | } | |
921 | } | |
922 | return sizeof(insn); | |
923 | } | |
924 | } | |
925 | (*info->fprintf_func) (info->stream, "#%8x", insn); | |
926 | return sizeof(insn); | |
927 | } |