Set the architecture (GDB multiarch needs it).
[deliverable/binutils-gdb.git] / opcodes / m10300-dis.c
index 7d7f74c947f7904428ea87b2ec0eddece7a9b24f..7dc899f099250207dbb79673ae279a6035d6fef4 100644 (file)
@@ -1,5 +1,5 @@
 /* Disassemble MN10300 instructions.
-   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 2000 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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include <stdio.h>
 
-#include "ansidecl.h"
+#include "sysdep.h"
 #include "opcode/mn10300.h" 
 #include "dis-asm.h"
 #include "opintl.h"
@@ -26,6 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 static void disassemble PARAMS ((bfd_vma, struct disassemble_info *,
                                 unsigned long insn, unsigned int));
 
+#define HAVE_AM33 (info->mach == AM33)
+#define HAVE_AM30 (info->mach == AM30)
+
 int 
 print_insn_mn10300 (memaddr, info)
      bfd_vma memaddr;
@@ -250,7 +253,8 @@ disassemble (memaddr, info, insn, size)
       if ((op->mask & insn) == op->opcode
          && size == (unsigned int) mysize
          && (op->machine == 0
-             || op->machine == info->mach))
+             || (op->machine == AM33 && HAVE_AM33)
+             || (op->machine == AM30 && HAVE_AM30)))
        {
          const unsigned char *opindex_ptr;
          unsigned int nocomma;
@@ -480,6 +484,8 @@ disassemble (memaddr, info, insn, size)
                  temp = extension >> operand->shift;
                  temp &= ((1 << (32 - operand->bits)) - 1);
                  value |= temp;
+                 value = ((value ^ (((unsigned long)1) << 31))
+                          - (((unsigned long)1) << 31));
                }
              else if ((operand->flags & MN10300_OPERAND_24BIT) != 0)
                {
@@ -490,7 +496,7 @@ disassemble (memaddr, info, insn, size)
                  temp &= ((1 << (24 - operand->bits)) - 1);
                  value |= temp;
                  if ((operand->flags & MN10300_OPERAND_SIGNED) != 0)
-                   value = ((value & 0xffffff) ^ (~0x7fffff)) + 0x800000;
+                   value = ((value & 0xffffff) ^ 0x800000) - 0x800000;
                }
              else if ((operand->flags & MN10300_OPERAND_EXTENDED) != 0)
                {
@@ -504,11 +510,10 @@ disassemble (memaddr, info, insn, size)
                }
 
              if ((operand->flags & MN10300_OPERAND_SIGNED) != 0
-                  /* These are properly extended by the code above.  */
-                  && ((operand->flags & MN10300_OPERAND_24BIT) == 0)
-                 )
-               value = ((long)(value << (32 - operand->bits))
-                         >> (32 - operand->bits));
+                 /* These are properly extended by the code above.  */
+                 && ((operand->flags & MN10300_OPERAND_24BIT) == 0))
+               value = ((value ^ (((unsigned long)1) << (operand->bits - 1)))
+                        - (((unsigned long)1) << (operand->bits - 1)));
 
              if (!nocomma
                  && (!paren
@@ -521,14 +526,14 @@ disassemble (memaddr, info, insn, size)
                {
                  value = ((insn >> (operand->shift + extra_shift))
                           & ((1 << operand->bits) - 1));
-                 (*info->fprintf_func) (info->stream, "d%d", value);
+                 (*info->fprintf_func) (info->stream, "d%d", (int)value);
                }
 
              else if ((operand->flags & MN10300_OPERAND_AREG) != 0)
                {
                  value = ((insn >> (operand->shift + extra_shift))
                           & ((1 << operand->bits) - 1));
-                 (*info->fprintf_func) (info->stream, "a%d", value);
+                 (*info->fprintf_func) (info->stream, "a%d", (int)value);
                }
 
              else if ((operand->flags & MN10300_OPERAND_SP) != 0)
@@ -545,11 +550,11 @@ disassemble (memaddr, info, insn, size)
                  value = ((insn >> (operand->shift + extra_shift))
                           & ((1 << operand->bits) - 1));
                  if (value < 8)
-                   (*info->fprintf_func) (info->stream, "r%d", value);
+                   (*info->fprintf_func) (info->stream, "r%d", (int)value);
                  else if (value < 12)
-                   (*info->fprintf_func) (info->stream, "a%d", value - 8);
+                   (*info->fprintf_func) (info->stream, "a%d", (int)value - 8);
                  else
-                   (*info->fprintf_func) (info->stream, "d%d", value - 12);
+                   (*info->fprintf_func) (info->stream, "d%d", (int)value - 12);
                }
 
              else if ((operand->flags & MN10300_OPERAND_XRREG) != 0)
@@ -559,7 +564,7 @@ disassemble (memaddr, info, insn, size)
                  if (value == 0)
                    (*info->fprintf_func) (info->stream, "sp", value);
                  else
-                 (*info->fprintf_func) (info->stream, "xr%d", value);
+                 (*info->fprintf_func) (info->stream, "xr%d", (int)value);
                }
 
              else if ((operand->flags & MN10300_OPERAND_USP) != 0)
@@ -666,7 +671,7 @@ disassemble (memaddr, info, insn, size)
                }
 
              else 
-               (*info->fprintf_func) (info->stream, "%d", value);
+               (*info->fprintf_func) (info->stream, "%ld", (long)value);
            }
          /* All done. */
          break;
This page took 0.024489 seconds and 4 git commands to generate.