arc: Change max instruction length to 64-bits
[deliverable/binutils-gdb.git] / opcodes / i960-dis.c
index 9210d02d80098ee67da9f3d61dadee5be00ecbdb..bf00c842847b6bd726dc682464b4a5e49078301b 100644 (file)
@@ -1,21 +1,22 @@
 /* Disassemble i80960 instructions.
-   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2016 Free Software Foundation, Inc.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+   This file is part of the GNU opcodes library.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This library is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
 
-You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+   It is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to the
+   Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 #include "sysdep.h"
 #include "dis-asm.h"
@@ -31,26 +32,24 @@ static const char *const reg_names[] = {
 
 static FILE *stream;           /* Output goes here */
 static struct disassemble_info *info;
-static void print_addr PARAMS ((bfd_vma));
-static void ctrl PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void cobr PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void reg PARAMS ((unsigned long));
-static int mem PARAMS ((bfd_vma, unsigned long, unsigned long, int));
-static void ea PARAMS ((bfd_vma, int, const char *, const char *, int, unsigned int));
-static void dstop PARAMS ((int, int, int));
-static void regop PARAMS ((int, int, int, int));
-static void invalid PARAMS ((int));
-static int pinsn PARAMS ((bfd_vma, unsigned long, unsigned long));
-static void put_abs PARAMS ((unsigned long, unsigned long));
+static void print_addr (bfd_vma);
+static void ctrl (bfd_vma, unsigned long, unsigned long);
+static void cobr (bfd_vma, unsigned long, unsigned long);
+static void reg (unsigned long);
+static int mem (bfd_vma, unsigned long, unsigned long, int);
+static void ea (bfd_vma, int, const char *, const char *, int, unsigned int);
+static void dstop (int, int, int);
+static void regop (int, int, int, int);
+static void invalid (int);
+static int pinsn (bfd_vma, unsigned long, unsigned long);
+static void put_abs (unsigned long, unsigned long);
 
 
 /* Print the i960 instruction at address 'memaddr' in debugged memory,
    on INFO->STREAM.  Returns length of the instruction, in bytes.  */
 
 int
-print_insn_i960 (memaddr, info_arg)
-    bfd_vma memaddr;
-    struct disassemble_info *info_arg;
+print_insn_i960 (bfd_vma memaddr, struct disassemble_info *info_arg)
 {
   unsigned int word1, word2 = 0xdeadbeef;
   bfd_byte buffer[8];
@@ -118,12 +117,10 @@ struct sparse_tabent {
 };
 
 static int
-pinsn (memaddr, word1, word2)
-     bfd_vma memaddr;
-     unsigned long word1, word2;
+pinsn (bfd_vma memaddr, unsigned long word1, unsigned long word2)
 {
   int instr_len;
-  
+
   instr_len = 4;
   put_abs (word1, word2);
 
@@ -161,10 +158,7 @@ pinsn (memaddr, word1, word2)
 /* CTRL format.. */
 
 static void
-ctrl (memaddr, word1, word2)
-     bfd_vma memaddr;
-     unsigned long word1;
-     unsigned long word2 ATTRIBUTE_UNUSED;
+ctrl (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
 {
   int i;
   static const struct tabent ctrl_tab[] = {
@@ -209,7 +203,7 @@ ctrl (memaddr, word1, word2)
       return;
     }
 
-  (*info->fprintf_func) (stream, ctrl_tab[i].name);
+  (*info->fprintf_func) (stream, "%s", ctrl_tab[i].name);
   if (word1 & 2)
     /* Predicts branch not taken.  */
     (*info->fprintf_func) (stream, ".f");
@@ -233,15 +227,12 @@ ctrl (memaddr, word1, word2)
 /* COBR format.  */
 
 static void
-cobr (memaddr, word1, word2)
-     bfd_vma memaddr;
-     unsigned long word1;
-     unsigned long word2 ATTRIBUTE_UNUSED;
+cobr (bfd_vma memaddr, unsigned long word1, unsigned long word2 ATTRIBUTE_UNUSED)
 {
   int src1;
   int src2;
   int i;
-  
+
   static const struct tabent cobr_tab[] = {
     { "testno",        1, },   /* 0x20 */
     { "testg", 1, },   /* 0x21 */
@@ -284,7 +275,7 @@ cobr (memaddr, word1, word2)
       return;
     }
 
-  (*info->fprintf_func) (stream, cobr_tab[i].name);
+  (*info->fprintf_func) (stream, "%s", cobr_tab[i].name);
 
   /* Predicts branch not taken.  */
   if (word1 & 2)
@@ -299,7 +290,7 @@ cobr (memaddr, word1, word2)
     /* M1 is 1 */
     (*info->fprintf_func) (stream, "%d", src1);
   else
-    (*info->fprintf_func) (stream, reg_names[src1]);
+    (*info->fprintf_func) (stream, "%s", reg_names[src1]);
 
   if (cobr_tab[i].numops > 1)
     {
@@ -324,18 +315,14 @@ cobr (memaddr, word1, word2)
 /* Returns instruction length: 4 or 8.  */
 
 static int
-mem (memaddr, word1, word2, noprint)
-     bfd_vma memaddr;
-     unsigned long word1, word2;
-     int noprint;              /* If TRUE, return instruction length, but
-                                  don't output any text.  */
+mem (bfd_vma memaddr, unsigned long word1, unsigned long word2, int noprint)
 {
   int i, j;
   int len;
   int mode;
   int offset;
   const char *reg1, *reg2, *reg3;
-  
+
   /* This lookup table is too sparse to make it worth typing in, but not
      so large as to make a sparse array necessary.  We create the table
      at runtime.  */
@@ -395,7 +382,7 @@ mem (memaddr, word1, word2, noprint)
       && ((mode == 5) || (mode >= 12)))
     /* With 32-bit displacement.  */
     len = 8;
-  else 
+  else
     len = 4;
 
   if (noprint)
@@ -426,7 +413,7 @@ mem (memaddr, word1, word2, noprint)
        {                               /* MEMA FORMAT */
          (*info->fprintf_func) (stream, "0x%x", (unsigned) offset);
 
-         if (mode & 8) 
+         if (mode & 8)
            (*info->fprintf_func) (stream, "(%s)", reg2);
 
          (*info->fprintf_func)(stream, ",%s", reg1);
@@ -445,7 +432,7 @@ mem (memaddr, word1, word2, noprint)
          /* MEMA FORMAT */
          (*info->fprintf_func) (stream, "%s,0x%x", reg1, (unsigned) offset);
 
-         if (mode & 8) 
+         if (mode & 8)
            (*info->fprintf_func) (stream, "(%s)", reg2);
        }
       break;
@@ -472,8 +459,7 @@ mem (memaddr, word1, word2, noprint)
 /* REG format.  */
 
 static void
-reg (word1)
-     unsigned long word1;
+reg (unsigned long word1)
 {
   int i, j;
   int opcode;
@@ -488,14 +474,14 @@ reg (word1)
      at runtime.  */
 
   /* NOTE: In this table, the meaning of 'numops' is:
-        1: single operand, which is NOT a destination.
-       -1: single operand, which IS a destination.
-        2: 2 operands, the 2nd of which is NOT a destination.
-       -2: 2 operands, the 2nd of which IS a destination.
-        3: 3 operands
-   
-       If an opcode mnemonic begins with "F", it is a floating-point
-       opcode (the "F" is not printed).  */
+        1: single operand, which is NOT a destination.
+       -1: single operand, which IS a destination.
+        2: 2 operands, the 2nd of which is NOT a destination.
+       -2: 2 operands, the 2nd of which IS a destination.
+        3: 3 operands
+
+       If an opcode mnemonic begins with "F", it is a floating-point
+       opcode (the "F" is not printed).  */
 
   static struct tabent *reg_tab;
   static const struct sparse_tabent reg_init[] =
@@ -730,7 +716,7 @@ reg (word1)
       fp = 0;
     }
 
-  (*info->fprintf_func) (stream, mnemp);
+  (*info->fprintf_func) (stream, "%s", mnemp);
 
   s1   = (word1 >> 5)  & 1;
   s2   = (word1 >> 6)  & 1;
@@ -777,13 +763,8 @@ reg (word1)
 /* Print out effective address for memb instructions.  */
 
 static void
-ea (memaddr, mode, reg2, reg3, word1, word2)
-     bfd_vma memaddr;
-     int mode;
-     const char *reg2;
-     const char *reg3;
-     int word1;
-     unsigned int word2;
+ea (bfd_vma memaddr, int mode, const char *reg2, const char *reg3, int word1,
+    unsigned int word2)
 {
   int scale;
   static const int scale_tab[] = { 1, 2, 4, 8, 16 };
@@ -842,8 +823,7 @@ ea (memaddr, mode, reg2, reg3, word1, word2)
 /* Register Instruction Operand.  */
 
 static void
-regop (mode, spec, reg, fp)
-     int mode, spec, reg, fp;
+regop (int mode, int spec, int fp_reg, int fp)
 {
   if (fp)
     {
@@ -851,7 +831,7 @@ regop (mode, spec, reg, fp)
       if (mode == 1)
        {
          /* FP operand.  */
-         switch (reg)
+         switch (fp_reg)
            {
            case 0:  (*info->fprintf_func) (stream, "fp0");
              break;
@@ -872,7 +852,7 @@ regop (mode, spec, reg, fp)
       else
        {
          /* Non-FP register.  */
-         (*info->fprintf_func) (stream, reg_names[reg]);
+         (*info->fprintf_func) (stream, "%s", reg_names[fp_reg]);
        }
     }
   else
@@ -881,15 +861,15 @@ regop (mode, spec, reg, fp)
       if (mode == 1)
        {
          /* Literal.  */
-         (*info->fprintf_func) (stream, "%d", reg);
+         (*info->fprintf_func) (stream, "%d", fp_reg);
        }
       else
        {
          /* Register.  */
          if (spec == 0)
-           (*info->fprintf_func) (stream, reg_names[reg]);
+           (*info->fprintf_func) (stream, "%s", reg_names[fp_reg]);
          else
-           (*info->fprintf_func) (stream, "sf%d", reg);
+           (*info->fprintf_func) (stream, "sf%d", fp_reg);
        }
     }
 }
@@ -897,36 +877,32 @@ regop (mode, spec, reg, fp)
 /* Register Instruction Destination Operand.  */
 
 static void
-dstop (mode, reg, fp)
-     int mode, reg, fp;
+dstop (int mode, int dest_reg, int fp)
 {
   /* 'dst' operand can't be a literal. On non-FP instructions,  register
      mode is assumed and "m3" acts as if were "s3";  on FP-instructions,
      sf registers are not allowed so m3 acts normally.  */
   if (fp)
-    regop (mode, 0, reg, fp);
+    regop (mode, 0, dest_reg, fp);
   else
-    regop (0, mode, reg, fp);
+    regop (0, mode, dest_reg, fp);
 }
 
 static void
-invalid (word1)
-     int word1;
+invalid (int word1)
 {
   (*info->fprintf_func) (stream, ".word\t0x%08x", (unsigned) word1);
 }
 
 static void
-print_addr (a)
-     bfd_vma a;
+print_addr (bfd_vma a)
 {
   (*info->print_address_func) (a, info);
 }
 
 static void
-put_abs (word1, word2)
-     unsigned long word1 ATTRIBUTE_UNUSED;
-     unsigned long word2 ATTRIBUTE_UNUSED;
+put_abs (unsigned long word1 ATTRIBUTE_UNUSED,
+        unsigned long word2 ATTRIBUTE_UNUSED)
 {
 #ifdef IN_GDB
   return;
This page took 0.029248 seconds and 4 git commands to generate.