This patch prevents a linker testsuite error if the checks are run with a
[deliverable/binutils-gdb.git] / opcodes / s390-dis.c
index b9eeb7976b7a6b362eccdc685eadbdd4a10745c4..252500c3cfc675aad6736fbcf3d823c5bf83d971 100644 (file)
@@ -1,6 +1,5 @@
 /* s390-dis.c -- Disassemble S390 instructions
-   Copyright 2000, 2001, 2002, 2003, 2005, 2007, 2008
-   Free Software Foundation, Inc.
+   Copyright (C) 2000-2014 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
 
    This file is part of the GNU opcodes library.
@@ -20,9 +19,9 @@
    Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include <stdio.h>
 #include "ansidecl.h"
-#include "sysdep.h"
 #include "dis-asm.h"
 #include "opintl.h"
 #include "opcode/s390.h"
@@ -65,17 +64,7 @@ init_disasm (struct disassemble_info *info)
     }
 
   if (!current_arch_mask)
-    switch (info->mach)
-      {
-      case bfd_mach_s390_31:
-       current_arch_mask = 1 << S390_OPCODE_ESA;
-       break;
-      case bfd_mach_s390_64:
-       current_arch_mask = 1 << S390_OPCODE_ZARCH;
-       break;
-      default:
-       abort ();
-      }
+    current_arch_mask = 1 << S390_OPCODE_ZARCH;
 
   init_flag = 1;
 }
@@ -166,6 +155,8 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info)
 
   if (status == 0)
     {
+      const struct s390_opcode *op;
+
       /* Find the first match in the opcode table.  */
       opcode_end = s390_opcodes + s390_num_opcodes;
       for (opcode = s390_opcodes + opc_index[(int) buffer[0]];
@@ -178,6 +169,7 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info)
          /* Check architecture.  */
          if (!(opcode->modes & current_arch_mask))
            continue;
+
          /* Check signature of the opcode.  */
          if ((buffer[1] & opcode->mask[1]) != opcode->opcode[1]
              || (buffer[2] & opcode->mask[2]) != opcode->opcode[2]
@@ -186,6 +178,28 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info)
              || (buffer[5] & opcode->mask[5]) != opcode->opcode[5])
            continue;
 
+         /* Advance to an opcode with a more specific mask.  */
+         for (op = opcode + 1; op < opcode_end; op++)
+           {
+             if ((buffer[0] & op->mask[0]) != op->opcode[0])
+               break;
+
+             if ((buffer[1] & op->mask[1]) != op->opcode[1]
+                 || (buffer[2] & op->mask[2]) != op->opcode[2]
+                 || (buffer[3] & op->mask[3]) != op->opcode[3]
+                 || (buffer[4] & op->mask[4]) != op->opcode[4]
+                 || (buffer[5] & op->mask[5]) != op->opcode[5])
+               continue;
+
+             if (((int)opcode->mask[0] + opcode->mask[1] +
+                  opcode->mask[2] + opcode->mask[3] +
+                  opcode->mask[4] + opcode->mask[5]) <
+                 ((int)op->mask[0] + op->mask[1] +
+                  op->mask[2] + op->mask[3] +
+                  op->mask[4] + op->mask[5]))
+               opcode = op;
+           }
+
          /* The instruction is valid.  */
          if (opcode->operands[0] != 0)
            (*info->fprintf_func) (info->stream, "%s\t", opcode->name);
This page took 0.024044 seconds and 4 git commands to generate.