2001-02-04 Philip Blundell <philb@gnu.org>
[external/binutils.git] / opcodes / m68k-dis.c
index a316c21..7f4b110 100644 (file)
@@ -1,5 +1,5 @@
 /* Print Motorola 68k instructions.
-   Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 97, 1998
+   Copyright 1986, 87, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
 This file is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
+#include "sysdep.h"
 #include "dis-asm.h"
 #include "floatformat.h"
 #include <libiberty.h>
@@ -150,16 +151,17 @@ fetch_data (info, addr)
 /* This function is used to print to the bit-bucket. */
 static int
 #ifdef __STDC__
-dummy_printer (FILE * file, const char * format, ...)
+dummy_printer (FILE * file ATTRIBUTE_UNUSED,
+              const char * format ATTRIBUTE_UNUSED, ...)
 #else
-dummy_printer (file) FILE *file;
+dummy_printer (file) FILE *file ATTRIBUTE_UNUSED;
 #endif
  { return 0; }
 
 static void
 dummy_print_address (vma, info)
-     bfd_vma vma;
-     struct disassemble_info *info;
+     bfd_vma vma ATTRIBUTE_UNUSED;
+     struct disassemble_info *info ATTRIBUTE_UNUSED;
 {
 }
 
@@ -504,6 +506,18 @@ print_insn_arg (d, buffer, p0, addr, info)
       (*info->fprintf_func) (info->stream, "%%usp");
       break;
 
+    case 'E':
+      (*info->fprintf_func) (info->stream, "%%acc");
+      break;
+
+    case 'G':
+      (*info->fprintf_func) (info->stream, "%%macsr");
+      break;
+
+    case 'H':
+      (*info->fprintf_func) (info->stream, "%%mask");
+      break;
+
     case 'J':
       {
        static const struct { char *name; int value; } names[]
@@ -539,10 +553,19 @@ print_insn_arg (d, buffer, p0, addr, info)
       break;
 
     case 'M':
-      val = fetch_arg (buffer, place, 8, info);
-      if (val & 0x80)
-       val = val - 0x100;
-      (*info->fprintf_func) (info->stream, "#%d", val);
+      if (place == 'h')
+       {
+         static char *const scalefactor_name[] = { "<<", ">>" };
+         val = fetch_arg (buffer, place, 1, info);
+         (*info->fprintf_func) (info->stream, scalefactor_name[val]);
+       }
+      else
+       {
+         val = fetch_arg (buffer, place, 8, info);
+         if (val & 0x80)
+           val = val - 0x100;
+         (*info->fprintf_func) (info->stream, "#%d", val);
+       }
       break;
 
     case 'T':
@@ -979,6 +1002,22 @@ print_insn_arg (d, buffer, p0, addr, info)
       }
       break;
 
+    case 'u':
+      {
+       short is_upper = 0;
+       int reg = fetch_arg (buffer, place, 5, info);
+       
+       if (reg & 0x10)
+         {
+           is_upper = 1;
+           reg &= 0xf;
+         }
+       (*info->fprintf_func) (info->stream, "%s%s",
+                              reg_names[reg],
+                              is_upper ? "u" : "l");
+      }
+      break;
+       
     default:
       return -2;
     }
@@ -1082,12 +1121,40 @@ fetch_arg (buffer, code, bits, info)
       val = (buffer[1] >> 6);
       break;
 
+    case 'm': 
+      val = (buffer[1] & 0x40 ? 0x8 : 0)
+       | ((buffer[0] >> 1) & 0x7)
+       | (buffer[3] & 0x80 ? 0x10 : 0);
+      break;
+
+    case 'n': 
+      val = (buffer[1] & 0x40 ? 0x8 : 0) | ((buffer[0] >> 1) & 0x7);
+      break;
+
+    case 'o':
+      val = (buffer[2] >> 4) | (buffer[3] & 0x80 ? 0x10 : 0);
+      break;
+
+    case 'M':
+      val = buffer[1] | (buffer[3] & 0x40 ? 0x10 : 0);
+      break;
+
+    case 'N':
+      val = buffer[3] | (buffer[3] & 0x40 ? 0x10 : 0);
+      break;
+
+    case 'h':
+      val = buffer[2] >> 2;
+      break;
+
     default:
       abort ();
     }
 
   switch (bits)
     {
+    case 1:
+      return val & 1;
     case 2:
       return val & 3;
     case 3: