Remove dup inftarg.o from NATDEPFILES.
[deliverable/binutils-gdb.git] / gdb / i386-pinsn.c
index 50cf14bd937d4ff18b2fb2bd05684516d9610a7b..bbc622f281d6cbad2e1c16c9d91dceffcfaa3421 100644 (file)
@@ -1,21 +1,21 @@
 /* Print i386 instructions for GDB, the GNU debugger.
-   Copyright (C) 1988, 1989 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
-GDB is free software; you can redistribute it and/or modify
+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 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
-GDB is distributed in the hope that it will be useful,
+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.
 
 You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /*
  * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
@@ -31,9 +31,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  * the Intel manual for details.
  */
 
-#include <stdio.h>
+#include "defs.h"
+
 #include <ctype.h>
 
+/* For the GDB interface at the bottom of the file... */
+#include "gdbcore.h"
+
 #define Eb OP_E, b_mode
 #define indirEb OP_indirE, b_mode
 #define Gb OP_G, b_mode
@@ -100,6 +104,8 @@ int OP_J(), OP_SEG();
 int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C();
 int OP_D(), OP_T(), OP_rm();
 
+static void dofloat (), putop (), append_prefix (), set_op ();
+static int get16 (), get32 ();
 
 #define b_mode 1
 #define v_mode 2
@@ -841,6 +847,7 @@ struct dis386 grps[][8] = {
 
 static int prefixes;
 
+static void
 ckprefix ()
 {
   prefixes = 0;
@@ -912,13 +919,14 @@ extern void fputs_filtered ();
  *   100 bytes is certainly enough, unless symbol printing is added later
  * The function returns the length of this instruction in bytes.
  */
+
+int
 i386dis (pc, inbuf, stream)
      int pc;
      unsigned char *inbuf;
      FILE *stream;
 {
   struct dis386 *dp;
-  char *p;
   int i;
   int enter_instruction;
   char *first, *second, *third;
@@ -1293,7 +1301,7 @@ char *fgrps[][8] = {
   },
 };
 
-
+static void
 dofloat ()
 {
   struct dis386 *dp;
@@ -1331,20 +1339,27 @@ dofloat ()
 }
 
 /* ARGSUSED */
+int
 OP_ST (ignore)
+     int ignore;
 {
   oappend ("%st");
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_STi (ignore)
+     int ignore;
 {
   sprintf (scratchbuf, "%%st(%d)", rm);
   oappend (scratchbuf);
+  return (0);
 }
 
 
 /* capital letters in template are macros */
+static void
 putop (template)
      char *template;
 {
@@ -1379,13 +1394,14 @@ putop (template)
 
 static void
 oappend (s)
-char *s;
+     char *s;
 {
   strcpy (obufp, s);
   obufp += strlen (s);
   *obufp = 0;
 }
 
+static void
 append_prefix ()
 {
   if (prefixes & PREFIX_CS)
@@ -1402,17 +1418,21 @@ append_prefix ()
     oappend ("%gs:");
 }
 
+int
 OP_indirE (bytemode)
+     int bytemode;
 {
   oappend ("*");
   OP_E (bytemode);
+  return (0);
 }
 
+int
 OP_E (bytemode)
+     int bytemode;
 {
   int disp;
   int havesib;
-  int didoutput = 0;
   int base;
   int index;
   int scale;
@@ -1445,7 +1465,7 @@ OP_E (bytemode)
          oappend ("<bad dis table>");
          break;
        }
-      return;
+      return (0);
     }
   
   append_prefix ();
@@ -1500,7 +1520,7 @@ OP_E (bytemode)
   
   if (mod != 0 || rm == 5 || (havesib && base == 5))
     {
-      sprintf (scratchbuf, "%d", disp);
+      sprintf (scratchbuf, "0x%x", disp);
       oappend (scratchbuf);
     }
   
@@ -1521,9 +1541,12 @@ OP_E (bytemode)
        }
       oappend (")");
     }
+  return (0);
 }
 
+int
 OP_G (bytemode)
+     int bytemode;
 {
   switch (bytemode) 
     {
@@ -1546,8 +1569,10 @@ OP_G (bytemode)
       oappend ("<internal disassembler error>");
       break;
     }
+  return (0);
 }
 
+static int
 get32 ()
 {
   int x = 0;
@@ -1559,6 +1584,7 @@ get32 ()
   return (x);
 }
 
+static int
 get16 ()
 {
   int x = 0;
@@ -1568,14 +1594,17 @@ get16 ()
   return (x);
 }
 
+static void
 set_op (op)
-int op;
+     int op;
 {
   op_index[op_ad] = op_ad;
   op_address[op_ad] = op;
 }
 
+int
 OP_REG (code)
+     int code;
 {
   char *s;
   
@@ -1606,9 +1635,12 @@ OP_REG (code)
       break;
     }
   oappend (s);
+  return (0);
 }
 
+int
 OP_I (bytemode)
+     int bytemode;
 {
   int op;
   
@@ -1628,13 +1660,16 @@ OP_I (bytemode)
       break;
     default:
       oappend ("<internal disassembler error>");
-      return;
+      return (0);
     }
   sprintf (scratchbuf, "$0x%x", op);
   oappend (scratchbuf);
+  return (0);
 }
 
+int
 OP_sI (bytemode)
+     int bytemode;
 {
   int op;
   
@@ -1654,13 +1689,16 @@ OP_sI (bytemode)
       break;
     default:
       oappend ("<internal disassembler error>");
-      return;
+      return (0);
     }
   sprintf (scratchbuf, "$0x%x", op);
   oappend (scratchbuf);
+  return (0);
 }
 
+int
 OP_J (bytemode)
+     int bytemode;
 {
   int disp;
   int mask = -1;
@@ -1684,25 +1722,31 @@ OP_J (bytemode)
       break;
     default:
       oappend ("<internal disassembler error>");
-      return;
+      return (0);
     }
   disp = (start_pc + codep - start_codep + disp) & mask;
   set_op (disp);
   sprintf (scratchbuf, "0x%x", disp);
   oappend (scratchbuf);
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_SEG (dummy)
+     int dummy;
 {
   static char *sreg[] = {
     "%es","%cs","%ss","%ds","%fs","%gs","%?","%?",
   };
 
   oappend (sreg[reg]);
+  return (0);
 }
 
+int
 OP_DIR (size)
+     int size;
 {
   int seg, offset;
   
@@ -1737,10 +1781,13 @@ OP_DIR (size)
       oappend ("<internal disassembler error>");
       break;
     }
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_OFF (bytemode)
+     int bytemode;
 {
   int off;
   
@@ -1751,55 +1798,76 @@ OP_OFF (bytemode)
   
   sprintf (scratchbuf, "0x%x", off);
   oappend (scratchbuf);
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_ESDI (dummy)
+    int dummy;
 {
   oappend ("%es:(");
   oappend (aflag ? "%edi" : "%di");
   oappend (")");
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_DSSI (dummy)
+    int dummy;
 {
   oappend ("%ds:(");
   oappend (aflag ? "%esi" : "%si");
   oappend (")");
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_ONE (dummy)
+    int dummy;
 {
   oappend ("1");
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_C (dummy)
+    int dummy;
 {
   codep++; /* skip mod/rm */
   sprintf (scratchbuf, "%%cr%d", reg);
   oappend (scratchbuf);
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_D (dummy)
+    int dummy;
 {
   codep++; /* skip mod/rm */
   sprintf (scratchbuf, "%%db%d", reg);
   oappend (scratchbuf);
+  return (0);
 }
 
 /* ARGSUSED */
+int
 OP_T (dummy)
+     int dummy;
 {
   codep++; /* skip mod/rm */
   sprintf (scratchbuf, "%%tr%d", reg);
   oappend (scratchbuf);
+  return (0);
 }
 
+int
 OP_rm (bytemode)
+     int bytemode;
 {
   switch (bytemode) 
     {
@@ -1810,24 +1878,19 @@ OP_rm (bytemode)
       oappend (names16[rm]);
       break;
     }
+  return (0);
 }
        
-/* GDB interface */
-#include "defs.h"
-#include "param.h"
-#include "symtab.h"
-#include "frame.h"
-#include "inferior.h"
-#include "gdbcore.h"
-
 #define MAXLEN 20
+
+int
 print_insn (memaddr, stream)
      CORE_ADDR memaddr;
      FILE *stream;
 {
   unsigned char buffer[MAXLEN];
   
-  read_memory (memaddr, buffer, MAXLEN);
+  read_memory (memaddr, (char *) buffer, MAXLEN);
   
   return (i386dis ((int)memaddr, buffer, stream));
 }
This page took 0.028735 seconds and 4 git commands to generate.