* hppa-dis.c: Finish constifying various completers, register
[external/binutils.git] / opcodes / hppa-dis.c
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_10 0x3ff
50 #define MASK_11 0x7ff
51 #define MASK_14 0x3fff
52 #define MASK_21 0x1fffff
53
54 /* This macro gets bit fields using HP's numbering (MSB = 0) */
55
56 #define GET_FIELD(X, FROM, TO) \
57   ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
58
59 /* Some of these have been converted to 2-d arrays because they
60    consume less storage this way.  If the maintenance becomes a
61    problem, convert them back to const 1-d pointer arrays.  */
62 static const char *const control_reg[] = {
63   "rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
64   "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
65   "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
66   "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
67   "tr4", "tr5", "tr6", "tr7"
68 };
69
70 static const char *const compare_cond_names[] = {
71   "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od",
72   ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev"
73 };
74 static const char *const compare_cond_64_names[] = {
75   "", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od",
76   ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev"
77 };
78 static const char *const cmpib_cond_64_names[] = {
79   ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>"
80 };
81 static const char *const add_cond_names[] = {
82   "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od",
83   ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev"
84 };
85 static const char *const add_cond_64_names[] = {
86   "", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od",
87   ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev"
88 };
89 static const char *const wide_add_cond_names[] = {
90   "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=",
91   ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>"
92 };
93 static const char *const logical_cond_names[] = {
94   "", ",=", ",<", ",<=", 0, 0, 0, ",od",
95   ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
96 static const char *const logical_cond_64_names[] = {
97   "", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od",
98   ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"};
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 };
103 static const char *const unit_cond_64_names[] = {
104   "", ",*swz", ",*sbz", ",*shz", ",*sdc", ",*swc", ",*sbc", ",*shc",
105   ",*tr", ",*nwz", ",*nbz", ",*nhz", ",*ndc", ",*nwc", ",*nbc", ",*nhc"
106 };
107 static const char *const shift_cond_names[] = {
108   "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
109 };
110 static const char *const shift_cond_64_names[] = {
111   "", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev"
112 };
113 static const char *const bb_cond_64_names[] = {
114   ",*<", ",*>="
115 };
116 static const char *const index_compl_names[] = {"", ",m", ",s", ",sm"};
117 static const char *const short_ldst_compl_names[] = {"", ",ma", "", ",mb"};
118 static const char *const short_bytes_compl_names[] = {
119   "", ",b,m", ",e", ",e,m"
120 };
121 static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
122 static const char *const float_comp_names[] =
123 {
124   ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
125   ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
126   ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
127   ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
128 };
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" };
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
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
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
348           if (!strchr ("cfCY?-+nHNZFIu", opcode->args[0]))
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;
357                 case 'a':
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;
364                 case 't':
365                   fput_reg (GET_FIELD (insn, 27, 31), info);
366                   break;
367
368                 /* Handle floating point registers.  */
369                 case 'f':
370                   switch (*++s)
371                     {
372                     case 't':
373                       fput_fp_reg (GET_FIELD (insn, 27, 31), info);
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;
387                     case 'A':
388                       if (GET_FIELD (insn, 24, 24))
389                         fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
390                       else
391                         fput_fp_reg (GET_FIELD (insn, 6, 10), info);
392                       
393                       break;
394                     case 'b':
395                       if (GET_FIELD (insn, 25, 25))
396                         fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
397                       else
398                         fput_fp_reg (GET_FIELD (insn, 11, 15), info);
399                       break;
400                     case 'B':
401                       if (GET_FIELD (insn, 19, 19))
402                         fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
403                       else
404                         fput_fp_reg (GET_FIELD (insn, 11, 15), info);
405                       break;
406                     case 'C':
407                       {
408                         int reg = GET_FIELD (insn, 21, 22);
409                         reg |= GET_FIELD (insn, 16, 18) << 2;
410                         if (GET_FIELD (insn, 23, 23) != 0)
411                           fput_fp_reg_r (reg, info);
412                         else
413                           fput_fp_reg (reg, info);
414                         break;
415                       }
416                     case 'i':
417                       {
418                         int reg = GET_FIELD (insn, 6, 10);
419
420                         reg |= (GET_FIELD (insn, 26, 26) << 4);
421                         fput_fp_reg (reg, info);
422                         break;
423                       }
424                     case 'j':
425                       {
426                         int reg = GET_FIELD (insn, 11, 15);
427
428                         reg |= (GET_FIELD (insn, 26, 26) << 4);
429                         fput_fp_reg (reg, info);
430                         break;
431                       }
432                     case 'k':
433                       {
434                         int reg = GET_FIELD (insn, 27, 31);
435
436                         reg |= (GET_FIELD (insn, 26, 26) << 4);
437                         fput_fp_reg (reg, info);
438                         break;
439                       }
440                     case 'l':
441                       {
442                         int reg = GET_FIELD (insn, 21, 25);
443
444                         reg |= (GET_FIELD (insn, 26, 26) << 4);
445                         fput_fp_reg (reg, info);
446                         break;
447                       }
448                     case 'm':
449                       {
450                         int reg = GET_FIELD (insn, 16, 20);
451
452                         reg |= (GET_FIELD (insn, 26, 26) << 4);
453                         fput_fp_reg (reg, info);
454                         break;
455                       }
456                     }
457
458                 case '5':
459                   fput_const (extract_5_load (insn), info);
460                   break;
461                 case 's':
462                   (*info->fprintf_func) (info->stream,
463                                          "sr%d", GET_FIELD (insn, 16, 17));
464                   break;
465
466                 case 'S':
467                   (*info->fprintf_func) (info->stream, "sr%d", extract_3 (insn));
468                   break;
469
470                 /* Handle completers.  */
471                 case 'c':
472                   switch (*++s)
473                     {
474                     case 'x':
475                       (*info->fprintf_func) (info->stream, "%s ",
476                                              index_compl_names[GET_COMPL (insn)]);
477                       break;
478                     case 'm':
479                       (*info->fprintf_func) (info->stream, "%s ",
480                                              short_ldst_compl_names[GET_COMPL (insn)]);
481                       break;
482                     case 's':
483                       (*info->fprintf_func) (info->stream, "%s ",
484                                              short_bytes_compl_names[GET_COMPL (insn)]);
485                       break;
486                     case 'L':
487                       (*info->fprintf_func) (info->stream, ",l");
488                       break;
489                     case 'w':
490                       (*info->fprintf_func) (info->stream, "%s ",
491                                              read_write_names[GET_FIELD (insn, 25, 25)]);
492                       break;
493                     case 'W':
494                       (*info->fprintf_func) (info->stream, ",w");
495                       break;
496                     case 'r':
497                       if (GET_FIELD (insn, 23, 26) == 5)
498                         (*info->fprintf_func) (info->stream, ",r");
499                       break;
500                     case 'Z':
501                       if (GET_FIELD (insn, 26, 26))
502                         (*info->fprintf_func) (info->stream, ",m ");
503                       else
504                         (*info->fprintf_func) (info->stream, " ");
505                       break;
506                     case 'i':
507                       if (GET_FIELD (insn, 25, 25))
508                         (*info->fprintf_func) (info->stream, ",i");
509                       break;
510                     case 'z':
511                       if (!GET_FIELD (insn, 21, 21))
512                         (*info->fprintf_func) (info->stream, ",z");
513                       break;
514                     case 'a':
515                       (*info->fprintf_func)
516                         (info->stream, "%s", add_compl_names[GET_FIELD
517                                                             (insn, 20, 21)]);
518                       break;
519                     case 'Y':
520                       (*info->fprintf_func)
521                         (info->stream, ",dc%s", add_compl_names[GET_FIELD
522                                                                (insn, 20, 21)]);
523                       break;
524                     case 'y':
525                       (*info->fprintf_func)
526                         (info->stream, ",c%s", add_compl_names[GET_FIELD
527                                                               (insn, 20, 21)]);
528                       break;
529                     case 'v':
530                       if (GET_FIELD (insn, 20, 20))
531                         (*info->fprintf_func) (info->stream, ",tsv");
532                       break;
533                     case 't':
534                       (*info->fprintf_func) (info->stream, ",tc");
535                       if (GET_FIELD (insn, 20, 20))
536                         (*info->fprintf_func) (info->stream, ",tsv");
537                       break;
538                     case 'B':
539                       (*info->fprintf_func) (info->stream, ",db");
540                       if (GET_FIELD (insn, 20, 20))
541                         (*info->fprintf_func) (info->stream, ",tsv");
542                       break;
543                     case 'b':
544                       (*info->fprintf_func) (info->stream, ",b");
545                       if (GET_FIELD (insn, 20, 20))
546                         (*info->fprintf_func) (info->stream, ",tsv");
547                       break;
548                     case 'T':
549                       if (GET_FIELD (insn, 25, 25))
550                         (*info->fprintf_func) (info->stream, ",tc");
551                       break;
552                     case 'S':
553                       /* EXTRD/W has a following condition.  */
554                       if (*(s + 1) == '?')
555                         (*info->fprintf_func)
556                           (info->stream, "%s", signed_unsigned_names[GET_FIELD
557                                                                     (insn, 21, 21)]);
558                       else
559                         (*info->fprintf_func)
560                           (info->stream, "%s ", signed_unsigned_names[GET_FIELD
561                                                                      (insn, 21, 21)]);
562                       break;
563                     case 'h':
564                       (*info->fprintf_func)
565                           (info->stream, "%s", mix_half_names[GET_FIELD
566                                                              (insn, 17, 17)]);
567                       break;
568                     case 'H':
569                       (*info->fprintf_func)
570                           (info->stream, "%s", saturation_names[GET_FIELD
571                                                                (insn, 24, 25)]);
572                       break;
573                     case '*':
574                       (*info->fprintf_func)
575                           (info->stream, ",%d%d%d%d ",
576                            GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
577                            GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
578                       break;
579                     }
580                   break;
581
582                 /* Handle conditions.  */
583                 case '?':
584                   {
585                     s++;
586                     switch (*s)
587                       {
588                       case 'f':
589                         (*info->fprintf_func) (info->stream, "%s ",
590                                                float_comp_names[GET_FIELD
591                                                                (insn, 27, 31)]);
592                         break;
593
594                       /* these four conditions are for the set of instructions
595                            which distinguish true/false conditions by opcode
596                            rather than by the 'f' bit (sigh): comb, comib,
597                            addb, addib */
598                       case 't':
599                         fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)],
600                                         info);
601                         break;
602                       case 'T':
603                         fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
604                                                           + 8], info);
605                         break;
606                       case 'r':
607                         fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)],
608                                         info);
609                         break;
610                       case 'R':
611                         fputs_filtered (compare_cond_64_names[GET_FIELD (insn, 16, 18)
612                                                              + 8], info);
613                         break;
614                       case 'Q':
615                         fputs_filtered (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
616                                         info);
617                         break;
618                       case 'n':
619                         fputs_filtered (compare_cond_names[GET_FIELD (insn, 16, 18)
620                                         + GET_FIELD (insn, 4, 4) * 8], info);
621                         break;
622                       case '@':
623                         fputs_filtered (add_cond_names[GET_FIELD (insn, 16, 18)
624                                         + GET_FIELD (insn, 4, 4) * 8], info);
625                         break;
626                       case 's':
627                         (*info->fprintf_func) (info->stream, "%s ",
628                                                compare_cond_names[GET_COND (insn)]);
629                         break;
630                       case 'S':
631                         (*info->fprintf_func) (info->stream, "%s ",
632                                                compare_cond_64_names[GET_COND (insn)]);
633                         break;
634                       case 'a':
635                         (*info->fprintf_func) (info->stream, "%s ",
636                                                add_cond_names[GET_COND (insn)]);
637                         break;
638                       case 'A':
639                         (*info->fprintf_func) (info->stream, "%s ",
640                                                add_cond_64_names[GET_COND (insn)]);
641                         break;
642                       case 'd':
643                         (*info->fprintf_func) (info->stream, "%s",
644                                                add_cond_names[GET_FIELD (insn, 16, 18)]);
645                         break;
646
647                       case 'D':
648                         (*info->fprintf_func) (info->stream, "%s",
649                                                add_cond_names[GET_FIELD (insn, 16, 18)
650                                                              + 8]);
651                         break;
652                       case 'w':
653                         (*info->fprintf_func) 
654                           (info->stream, "%s",
655                            wide_add_cond_names[GET_FIELD (insn, 16, 18)]);
656                         break;
657
658                       case 'W':
659                         (*info->fprintf_func) 
660                           (info->stream, "%s",
661                            wide_add_cond_names[GET_FIELD (insn, 16, 18) + 8]);
662                         break;
663
664                       case 'l':
665                         (*info->fprintf_func) (info->stream, "%s ",
666                                                logical_cond_names[GET_COND (insn)]);
667                         break;
668                       case 'L':
669                         (*info->fprintf_func) (info->stream, "%s ",
670                                                logical_cond_64_names[GET_COND (insn)]);
671                         break;
672                       case 'u':
673                         (*info->fprintf_func) (info->stream, "%s ",
674                                                unit_cond_names[GET_COND (insn)]);
675                         break;
676                       case 'U':
677                         (*info->fprintf_func) (info->stream, "%s ",
678                                                unit_cond_64_names[GET_COND (insn)]);
679                         break;
680                       case 'y':
681                       case 'x':
682                       case 'b':
683                         (*info->fprintf_func)
684                           (info->stream, "%s",
685                            shift_cond_names[GET_FIELD (insn, 16, 18)]);
686
687                         /* If the next character in args is 'n', it will handle
688                            putting out the space.  */
689                         if (s[1] != 'n')
690                           (*info->fprintf_func) (info->stream, " ");
691                         break;
692                       case 'X':
693                         (*info->fprintf_func) (info->stream, "%s",
694                                                shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
695                         break;
696                       case 'B':
697                         (*info->fprintf_func)
698                           (info->stream, "%s",
699                            bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
700
701                         /* If the next character in args is 'n', it will handle
702                            putting out the space.  */
703                         if (s[1] != 'n')
704                           (*info->fprintf_func) (info->stream, " ");
705                         break;
706                       }
707                     break;
708                   }
709
710                 case 'V':
711                   fput_const (extract_5_store (insn), info);
712                   break;
713                 case 'r':
714                   fput_const (extract_5r_store (insn), info);
715                   break;
716                 case 'R':
717                   fput_const (extract_5R_store (insn), info);
718                   break;
719                 case 'U':
720                   fput_const (extract_10U_store (insn), info);
721                   break;
722                 case 'Q':
723                   fput_const (extract_5Q_store (insn), info);
724                   break;
725                 case 'i':
726                   fput_const (extract_11 (insn), info);
727                   break;
728                 case 'j':
729                   fput_const (extract_14 (insn), info);
730                   break;
731                 case 'k':
732                   fput_const (extract_21 (insn), info);
733                   break;
734                 case 'n':
735                   if (insn & 0x2)
736                     (*info->fprintf_func) (info->stream, ",n ");
737                   else
738                     (*info->fprintf_func) (info->stream, " ");
739                   break;
740                 case 'N':
741                   if ((insn & 0x20) && s[1])
742                     (*info->fprintf_func) (info->stream, ",n ");
743                   else if (insn & 0x20)
744                     (*info->fprintf_func) (info->stream, ",n");
745                   else if (s[1])
746                     (*info->fprintf_func) (info->stream, " ");
747                   break;
748                 case 'w':
749                   (*info->print_address_func) (memaddr + 8 + extract_12 (insn),
750                                                info);
751                   break;
752                 case 'W':
753                   /* 17 bit PC-relative branch.  */
754                   (*info->print_address_func) ((memaddr + 8 
755                                                 + extract_17 (insn)),
756                                                info);
757                   break;
758                 case 'z':
759                   /* 17 bit displacement.  This is an offset from a register
760                      so it gets disasssembled as just a number, not any sort
761                      of address.  */
762                   fput_const (extract_17 (insn), info);
763                   break;
764
765                 case 'Z':
766                   /* addil %r1 implicit output.  */
767                   (*info->fprintf_func) (info->stream, "%%r1");
768                   break;
769                   
770                 case '.':
771                   (*info->fprintf_func) (info->stream, "%d",
772                                     GET_FIELD (insn, 24, 25));
773                   break;
774                 case '*':
775                   (*info->fprintf_func) (info->stream, "%d",
776                                     GET_FIELD (insn, 22, 25));
777                   break;
778                 case '!':
779                   (*info->fprintf_func) (info->stream, "%%sar");
780                   break;
781                 case 'p':
782                   (*info->fprintf_func) (info->stream, "%d",
783                                     31 - GET_FIELD (insn, 22, 26));
784                   break;
785                 case '~':
786                   {
787                     int num;
788                     num = GET_FIELD (insn, 20, 20) << 5;
789                     num |= GET_FIELD (insn, 22, 26);
790                     (*info->fprintf_func) (info->stream, "%d", 63 - num);
791                     break;
792                   }
793                 case 'P':
794                   (*info->fprintf_func) (info->stream, "%d",
795                                     GET_FIELD (insn, 22, 26));
796                   break;
797                 case 'q':
798                   {
799                     int num;
800                     num = GET_FIELD (insn, 20, 20) << 5;
801                     num |= GET_FIELD (insn, 22, 26);
802                     (*info->fprintf_func) (info->stream, "%d", num);
803                     break;
804                   }
805                 case 'T':
806                   (*info->fprintf_func) (info->stream, "%d",
807                                     32 - GET_FIELD (insn, 27, 31));
808                   break;
809                 case '%':
810                   {
811                     int num;
812                     num = (GET_FIELD (insn, 23, 23) + 1) * 32;
813                     num -= GET_FIELD (insn, 27, 31);
814                     (*info->fprintf_func) (info->stream, "%d", num);
815                     break;
816                   }
817                 case '|':
818                   {
819                     int num;
820                     num = (GET_FIELD (insn, 19, 19) + 1) * 32;
821                     num -= GET_FIELD (insn, 27, 31);
822                     (*info->fprintf_func) (info->stream, "%d", num);
823                     break;
824                   }
825                 case '$':
826                   fput_const (GET_FIELD (insn, 20, 28), info);
827                   break;
828                 case 'A':
829                   fput_const (GET_FIELD (insn, 6, 18), info);
830                   break;
831                 case 'D':
832                   fput_const (GET_FIELD (insn, 6, 31), info);
833                   break;
834                 case 'v':
835                   (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
836                   break;
837                 case 'O':
838                   fput_const ((GET_FIELD (insn, 6,20) << 5 |
839                                GET_FIELD (insn, 27, 31)), info);
840                   break;
841                 case 'o':
842                   fput_const (GET_FIELD (insn, 6, 20), info);
843                   break;
844                 case '2':
845                   fput_const ((GET_FIELD (insn, 6, 22) << 5 |
846                                GET_FIELD (insn, 27, 31)), info);
847                   break;
848                 case '1':
849                   fput_const ((GET_FIELD (insn, 11, 20) << 5 |
850                                GET_FIELD (insn, 27, 31)), info);
851                   break;
852                 case '0':
853                   fput_const ((GET_FIELD (insn, 16, 20) << 5 |
854                                GET_FIELD (insn, 27, 31)), info);
855                   break;
856                 case 'u':
857                   (*info->fprintf_func) (info->stream, ",%d", GET_FIELD (insn, 23, 25));
858                   break;
859                 case 'F':
860                   /* if no destination completer and not before a completer
861                      for fcmp, need a space here */
862                   if (s[1] == 'G' || s[1] == '?')
863                     fputs_filtered (float_format_names[GET_FIELD (insn, 19, 20)],
864                                     info);
865                   else
866                     (*info->fprintf_func) (info->stream, "%s ",
867                                            float_format_names[GET_FIELD
868                                                               (insn, 19, 20)]);
869                   break;
870                 case 'G':
871                   (*info->fprintf_func) (info->stream, "%s ",
872                                     float_format_names[GET_FIELD (insn,
873                                                                   17, 18)]);
874                   break;
875                 case 'H':
876                   if (GET_FIELD (insn, 26, 26) == 1)
877                     (*info->fprintf_func) (info->stream, "%s ",
878                                     float_format_names[0]);
879                   else
880                     (*info->fprintf_func) (info->stream, "%s ",
881                                     float_format_names[1]);
882                   break;
883                 case 'I':
884                   /* if no destination completer and not before a completer
885                      for fcmp, need a space here */
886                   if (s[1] == '?')
887                     fputs_filtered (float_format_names[GET_FIELD (insn, 20, 20)],
888                                     info);
889                   else
890                     (*info->fprintf_func) (info->stream, "%s ",
891                                            float_format_names[GET_FIELD
892                                                               (insn, 20, 20)]);
893                   break;
894                 default:
895                   (*info->fprintf_func) (info->stream, "%c", *s);
896                   break;
897                 }
898             }
899           return sizeof(insn);
900         }
901     }
902   (*info->fprintf_func) (info->stream, "#%8x", insn);
903   return sizeof(insn);
904 }