recording file death
[deliverable/binutils-gdb.git] / binutils / sparc-pinsn.c
index 68d057cdc047382e8840e9d26a050f3bcdc8ec01..b639d86649c2d7eaddd8f3a23b6396ded9e82bfc 100644 (file)
@@ -18,14 +18,11 @@ You should have received a copy of the GNU General Public License
 along with the binutils; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
-/* $Id$ */
-
 #include "bfd.h"
 #include "sysdep.h"
 #include <stdio.h>
 #include "opcode/sparc.h"
-
-extern int fputs();
+#include "objdump.h"
 extern int print_address();
 
 static  char *reg_names[] =
@@ -165,12 +162,12 @@ memcpy(&insn,buffer, sizeof (insn));
              && insn.rs1 == insn.rd)
            imm_added_to_rs1 = 1;
 
-         if (index (opcode->args, 'S') != 0)
+         if (strchr (opcode->args, 'S') != 0)
            /* Reject the special case for `set'.
               The real `sethi' will match.  */
            continue;
          if (insn.rs1 != insn.rd
-             && index (opcode->args, 'r') != 0)
+             && strchr (opcode->args, 'r') != 0)
              /* Can't do simple format if source and dest are different.  */
              continue;
 
@@ -181,32 +178,34 @@ memcpy(&insn,buffer, sizeof (insn));
 
            if (opcode->args[0] != ',')
              fputs (" ", stream);
-           for (s = opcode->args; *s != '\0'; ++s) {
-               while (*s == ',') {
-                       fputs (",", stream);
-                       ++s;
-
-                       switch (*s) {
-                       case 'a':
-                               fputs ("a", stream);
-                               ++s;
-                               continue;
+           for (s = opcode->args; *s != '\0'; ++s)
+             {
+               while (*s == ',')
+                 {
+                   fputs (",", stream);
+                   ++s;
+
+                   switch (*s) {
+                   case 'a':
+                     fputs ("a", stream);
+                     ++s;
+                     continue;
 #ifndef NO_V9
-                       case 'N':
-                               fputs("pn", stream);
-                               ++s;
-                               continue;
-
-                       case 'T':
-                               fputs("pt", stream);
-                               ++s;
-                               continue;
-#endif /* NO_V9 */
-
-                       default:
-                               break;
-                       } /* switch on arg */
-               } /* while there are comma started args */
+                   case 'N':
+                     fputs("pn", stream);
+                     ++s;
+                     continue;
+
+                   case 'T':
+                     fputs("pt", stream);
+                     ++s;
+                     continue;
+#endif                         /* NO_V9 */
+
+                   default:
+                     break;
+                   }           /* switch on arg */
+                 }             /* while there are comma started args */
 
                fputs (" ", stream);
                        
@@ -241,14 +240,20 @@ memcpy(&insn,buffer, sizeof (insn));
 
 #define        freg(n) fprintf (stream, "%%%s", freg_names[n])
                  case 'e':
+                 case 'v':     /* double/even */
+                 case 'V':     /* quad/multiple of 4 */
                    freg (insn.rs1);
                    break;
 
                  case 'f':
+                 case 'B':     /* double/even */
+                 case 'R':     /* quad/multiple of 4 */
                    freg (insn.rs2);
                    break;
 
                  case 'g':
+                 case 'H':     /* double/even */
+                 case 'J':     /* quad/multiple of 4 */
                    freg (insn.rd);
                    break;
 #undef freg
@@ -269,7 +274,7 @@ memcpy(&insn,buffer, sizeof (insn));
 
                  case 'h':
                    fprintf (stream, "%%hi(%#x)",
-                                     (unsigned int) insn.imm22 << 10);
+                            (unsigned int) insn.imm22 << 10);
                    break;
 
                  case 'i':
@@ -280,7 +285,7 @@ memcpy(&insn,buffer, sizeof (insn));
 
                      /* Check to see whether we have a 1+i, and take
                         note of that fact.
-
+                        
                         Note: because of the way we sort the table,
                         we will be matching 1+i rather than i+1,
                         so it is OK to assume that i is after +,
@@ -296,6 +301,38 @@ memcpy(&insn,buffer, sizeof (insn));
                    break;
 
 #ifndef NO_V9
+                 case 'I':     /* 11 bit immediate.  */
+                 case 'j':     /* 10 bit immediate.  */
+                   {
+                     /* We cannot trust the compiler to sign-extend
+                        when extracting the bitfield, hence the shifts.  */
+                     int imm;
+
+                     if (*s == 'I')
+                       imm = ((int) insn.imm13 << 21) >> 21;
+                     else
+                       imm = ((int) insn.imm13 << 22) >> 22;
+
+                     /* Check to see whether we have a 1+i, and take
+                        note of that fact.
+                        
+                        Note: because of the way we sort the table,
+                        we will be matching 1+i rather than i+1,
+                        so it is OK to assume that i is after +,
+                        not before it.  */
+                     if (found_plus)
+                       imm_added_to_rs1 = 1;
+                     
+                     if (imm <= 9)
+                       fprintf (stream, "%d", imm);
+                     else
+                       fprintf (stream, "%#x", (unsigned) imm);
+                   }
+                   break;
+
+
+
+
                  case 'k':
                    print_address ((bfd_vma)
                                   (memaddr
@@ -303,28 +340,47 @@ memcpy(&insn,buffer, sizeof (insn));
                                   stream);
                    break;
 
-                 case 'K':
+                 case 'G':
                    print_address ((bfd_vma)
                                   (memaddr
-                                   + (((int) insn.disp21 << 11) >> 11) * 4),
+                                   /* We use only 19 of the 21 bits.  */
+                                   + (((int) insn.disp21 << 13) >> 13) * 4),
                                   stream);
                    break;
 
-           case 'Y':
-                   fputs ("%amr", stream);
+                 case '6':
+                 case '7':
+                 case '8':
+                 case '9':
+                   fprintf (stream, "fcc%c", *s - '6' + '0');
                    break;
 
-#endif /* NO_V9 */
+                 case 'z':
+                   fputs ("icc", stream);
+                   break;
+
+                 case 'Z':
+                   fputs ("xcc", stream);
+                   break;
+
+                 case 'E':
+                   fputs ("%ccr", stream);
+                   break;
+
+                 case 's':
+                   fputs ("%fprs", stream);
+                   break;
+#endif                         /* NO_V9 */
 
-           case 'M':
+                 case 'M':
                    fprintf(stream, "%%asr%d", insn.rs1);
                    break;
                    
-           case 'm':
+                 case 'm':
                    fprintf(stream, "%%asr%d", insn.rd);
                    break;
                    
-           case 'L':
+                 case 'L':
                    print_address ((bfd_vma) memaddr + insn.disp30 * 4,
                                   stream);
                    break;
@@ -334,7 +390,7 @@ memcpy(&insn,buffer, sizeof (insn));
                      /* Special case for `unimp'.  Don't try to turn
                         it's operand into a function offset.  */
                      fprintf (stream, "%#x",
-                                       (unsigned) (((int) insn.disp22 << 10) >> 10));
+                              (unsigned) (((int) insn.disp22 << 10) >> 10));
                    else
                      /* We cannot trust the compiler to sign-extend
                         when extracting the bitfield, hence the shifts.  */
@@ -392,7 +448,7 @@ memcpy(&insn,buffer, sizeof (insn));
          if (imm_added_to_rs1)
            {
              union sparc_insn prev_insn;
-             int errcode;
+             int errcode = 0;
 
              memcpy(&prev_insn, buffer -4,  sizeof (prev_insn));
 
@@ -501,8 +557,8 @@ compare_opcodes (a, b)
 
   /* Put 1+i before i+1.  */
   {
-    char *p0 = (char *) index(op0->args, '+');
-    char *p1 = (char *) index(op1->args, '+');
+    char *p0 = (char *) strchr(op0->args, '+');
+    char *p1 = (char *) strchr(op1->args, '+');
 
     if (p0 && p1)
       {
This page took 0.038959 seconds and 4 git commands to generate.