missed from 2005-07-18 commit
[deliverable/binutils-gdb.git] / opcodes / a29k-dis.c
index 2766902f22b80e30c126c12f74bc19e4801a0e5b..861e51be10409d09219e1f70cf09b666eea005f0 100644 (file)
@@ -1,23 +1,26 @@
 /* Instruction printing code for the AMD 29000
-   Copyright (C) 1990 Free Software Foundation, Inc.
+   Copyright 1990, 1993, 1994, 1995, 1998, 2000, 2001, 2002
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.  Written by Jim Kingdon.
 
-This file is part of GDB.
+   This file is part of GDB and GNU Binutils.
 
-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 of the License, or
-(at your option) any later version.
+   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 of the License, or
+   (at your option) any later version.
 
-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 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 this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "dis-asm.h"
 #include "opcode/a29k.h"
 
@@ -25,10 +28,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    register number NUM on STREAM.
    NUM is a number as found in the instruction, not as found in
    debugging symbols; it must be in the range 0-255.  */
+
 static void
-print_general (num, info)
-     int num;
-     struct disassemble_info *info;
+print_general (int num, struct disassemble_info *info)
 {
   if (num < 128)
     (*info->fprintf_func) (info->stream, "gr%d", num);
@@ -37,31 +39,35 @@ print_general (num, info)
 }
 
 /* Like print_general but a special-purpose register.
-   
+
    The mnemonics used by the AMD assembler are not quite the same
    as the ones in the User's Manual.  We use the ones that the
    assembler uses.  */
+
 static void
-print_special (num, info)
-     int num;
-     struct disassemble_info *info;
+print_special (unsigned int num, struct disassemble_info *info)
 {
   /* Register names of registers 0-SPEC0_NUM-1.  */
-  static char *spec0_names[] = {
-    "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr",
-    "pc0", "pc1", "pc2", "mmu", "lru"
+  static char *spec0_names[] =
+    {
+      "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr",
+      "pc0", "pc1", "pc2", "mmu", "lru", "rsn", "rma0", "rmc0", "rma1", "rmc1",
+      "spc0", "spc1", "spc2", "iba0", "ibc0", "iba1", "ibc1", "dba", "dbc",
+      "cir", "cdr"
     };
 #define SPEC0_NUM ((sizeof spec0_names) / (sizeof spec0_names[0]))
 
   /* Register names of registers 128-128+SPEC128_NUM-1.  */
-  static char *spec128_names[] = {
-    "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr"
+  static char *spec128_names[] =
+    {
+      "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr"
     };
 #define SPEC128_NUM ((sizeof spec128_names) / (sizeof spec128_names[0]))
 
   /* Register names of registers 160-160+SPEC160_NUM-1.  */
-  static char *spec160_names[] = {
-    "fpe", "inte", "fps", "sr163", "exop"
+  static char *spec160_names[] =
+    {
+      "fpe", "inte", "fps", "sr163", "exop"
     };
 #define SPEC160_NUM ((sizeof spec160_names) / (sizeof spec160_names[0]))
 
@@ -76,9 +82,9 @@ print_special (num, info)
 }
 
 /* Is an instruction with OPCODE a delayed branch?  */
+
 static int
-is_delayed_branch (opcode)
-     int opcode;
+is_delayed_branch (int opcode)
 {
   return (opcode == 0xa8 || opcode == 0xa9 || opcode == 0xa0 || opcode == 0xa1
          || opcode == 0xa4 || opcode == 0xa5
@@ -89,13 +95,13 @@ is_delayed_branch (opcode)
 }
 
 /* Now find the four bytes of INSN and put them in *INSN{0,8,16,24}.  */
+
 static void
-find_bytes_big (insn, insn0, insn8, insn16, insn24)
-     char *insn;
-     unsigned char *insn0;
-     unsigned char *insn8;
-     unsigned char *insn16;
-     unsigned char *insn24;
+find_bytes_big (char *insn,
+               unsigned char *insn0,
+               unsigned char *insn8,
+               unsigned char *insn16,
+               unsigned char *insn24)
 {
   *insn24 = insn[0];
   *insn16 = insn[1];
@@ -104,12 +110,11 @@ find_bytes_big (insn, insn0, insn8, insn16, insn24)
 }
 
 static void
-find_bytes_little (insn, insn0, insn8, insn16, insn24)
-     char *insn;
-     unsigned char *insn0;
-     unsigned char *insn8;
-     unsigned char *insn16;
-     unsigned char *insn24;
+find_bytes_little (char *insn,
+                  unsigned char *insn0,
+                  unsigned char *insn8,
+                  unsigned char *insn16,
+                  unsigned char *insn24)
 {
   *insn24 = insn[3];
   *insn16 = insn[2];
@@ -117,17 +122,15 @@ find_bytes_little (insn, insn0, insn8, insn16, insn24)
   *insn0 = insn[0];
 }
 
-typedef (*find_byte_func_type)
-     PARAMS ((char *, unsigned char *, unsigned char *,
-             unsigned char *, unsigned char *));
+typedef void (*find_byte_func_type)
+     (char *, unsigned char *, unsigned char *,
+      unsigned char *, unsigned char *);
 
 /* Print one instruction from MEMADDR on INFO->STREAM.
    Return the size of the instruction (always 4 on a29k).  */
 
 static int
-print_insn (memaddr, info)
-     bfd_vma memaddr;
-     struct disassemble_info *info;
+print_insn (bfd_vma memaddr, struct disassemble_info *info)
 {
   /* The raw instruction.  */
   char insn[4];
@@ -137,7 +140,7 @@ print_insn (memaddr, info)
 
   find_byte_func_type find_byte_func = (find_byte_func_type)info->private_data;
 
-  struct a29k_opcode CONST * opcode;
+  struct a29k_opcode const * opcode;
 
   {
     int status =
@@ -153,21 +156,25 @@ print_insn (memaddr, info)
 
   printf ("%02x%02x%02x%02x ", insn24, insn16, insn8, insn0);
 
-  /* Handle the nop (aseq 0x40,gr1,gr1) specially */
-  if ((insn24==0x70) && (insn16==0x40) && (insn8==0x01) && (insn0==0x01)) {
-    (*info->fprintf_func) (info->stream,"nop");
-    return 4;
-  }
+  /* Handle the nop (aseq 0x40,gr1,gr1) specially.  */
+  if (   (insn24 == 0x70)
+      && (insn16 == 0x40)
+      && (insn8 == 0x01)
+      && (insn0 == 0x01))
+    {
+      (*info->fprintf_func) (info->stream,"nop");
+      return 4;
+    }
 
   /* The opcode is always in insn24.  */
   for (opcode = &a29k_opcodes[0];
        opcode < &a29k_opcodes[num_opcodes];
        ++opcode)
     {
-      if ((insn24<<24) == opcode->opcode)
+      if (((unsigned long) insn24 << 24) == opcode->opcode)
        {
          char *s;
-         
+
          (*info->fprintf_func) (info->stream, "%s ", opcode->name);
          for (s = opcode->args; *s != '\0'; ++s)
            {
@@ -176,7 +183,7 @@ print_insn (memaddr, info)
                case 'a':
                  print_general (insn8, info);
                  break;
-                 
+
                case 'b':
                  print_general (insn0, info);
                  break;
@@ -190,18 +197,19 @@ print_insn (memaddr, info)
                  break;
 
                case 'x':
-                 (*info->fprintf_func) (info->stream, "0x%x", (insn16 << 8) + insn0);
+                 (*info->fprintf_func) (info->stream, "0x%x",
+                                        (insn16 << 8) + insn0);
                  break;
 
                case 'h':
                  /* This used to be %x for binutils.  */
                  (*info->fprintf_func) (info->stream, "0x%x",
-                                   (insn16 << 24) + (insn0 << 16));
+                                        (insn16 << 24) + (insn0 << 16));
                  break;
 
                case 'X':
                  (*info->fprintf_func) (info->stream, "%d",
-                                   ((insn16 << 8) + insn0) | 0xffff0000);
+                                        ((insn16 << 8) + insn0) | 0xffff0000);
                  break;
 
                case 'P':
@@ -244,6 +252,11 @@ print_insn (memaddr, info)
                  (*info->fprintf_func) (info->stream, "%d", (insn0 >> 4) & 7);
                  break;
 
+               case 'I':
+                 if ((insn16 & 3) != 0)
+                   (*info->fprintf_func) (info->stream, "%d", insn16 & 3);
+                 break;
+
                case 'd':
                  (*info->fprintf_func) (info->stream, "%d", (insn0 >> 2) & 3);
                  break;
@@ -253,7 +266,8 @@ print_insn (memaddr, info)
                  break;
 
                case 'F':
-                 (*info->fprintf_func) (info->stream, "%d", (insn16 >> 2) & 15);
+                 (*info->fprintf_func) (info->stream, "%d",
+                                        (insn16 >> 2) & 15);
                  break;
 
                case 'C':
@@ -272,7 +286,7 @@ print_insn (memaddr, info)
              int errcode;
              char prev_insn[4];
              unsigned char prev_insn0, prev_insn8, prev_insn16, prev_insn24;
-             
+
              errcode = (*info->read_memory_func) (memaddr - 4,
                                                   (bfd_byte *) &prev_insn[0],
                                                   4,
@@ -282,22 +296,22 @@ print_insn (memaddr, info)
                  /* If it is a delayed branch, we need to look at the
                     instruction before the delayed brach to handle
                     things like
-                    
+
                     const _foo
                     call _printf
                     consth _foo
                     */
-                 (*find_byte_func) (prev_insn, &prev_insn0, &prev_insn8,
-                                    &prev_insn16, &prev_insn24);
+                 (*find_byte_func) (prev_insn, & prev_insn0, & prev_insn8,
+                                    & prev_insn16, & prev_insn24);
                  if (is_delayed_branch (prev_insn24))
                    {
                      errcode = (*info->read_memory_func)
-                       (memaddr - 8, (bfd_byte *) &prev_insn[0], 4, info);
-                     (*find_byte_func) (prev_insn, &prev_insn0, &prev_insn8,
-                                        &prev_insn16, &prev_insn24);
+                       (memaddr - 8, (bfd_byte *) & prev_insn[0], 4, info);
+                     (*find_byte_func) (prev_insn, & prev_insn0, & prev_insn8,
+                                        & prev_insn16, & prev_insn24);
                    }
                }
-                 
+
              /* If there was a problem reading memory, then assume
                 the previous instruction was not const.  */
              if (errcode == 0)
@@ -326,20 +340,18 @@ print_insn (memaddr, info)
 }
 
 /* Disassemble an big-endian a29k instruction.  */
+
 int
-print_insn_big_a29k (memaddr, info)
-     bfd_vma memaddr;
-     struct disassemble_info *info;
+print_insn_big_a29k (bfd_vma memaddr, struct disassemble_info *info)
 {
   info->private_data = (PTR) find_bytes_big;
   return print_insn (memaddr, info);
 }
 
 /* Disassemble a little-endian a29k instruction.  */
+
 int
-print_insn_little_a29k (memaddr, info)
-     bfd_vma memaddr;
-     struct disassemble_info *info;
+print_insn_little_a29k (bfd_vma memaddr, struct disassemble_info *info)
 {
   info->private_data = (PTR) find_bytes_little;
   return print_insn (memaddr, info);
This page took 0.03516 seconds and 4 git commands to generate.