]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/ns32k-dis.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / opcodes / ns32k-dis.c
index 51b39260c4f68cb5efb854ce07fe950de521fbc0..34ef3b09881cc28a9feb2705ff7edcd64735ac30 100644 (file)
@@ -1,5 +1,5 @@
 /* Print National Semiconductor 32000 instructions.
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2021 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -347,9 +347,7 @@ flip_bytes (char *ptr, int count)
 }
 \f
 /* Given a character C, does it represent a general addressing mode?  */
-#define Is_gen(c) \
-  ((c) == 'F' || (c) == 'L' || (c) == 'B' \
-   || (c) == 'W' || (c) == 'D' || (c) == 'A' || (c) == 'I' || (c) == 'Z')
+#define Is_gen(c) (strchr ("FLBWDAIZf", (c)) != NULL)
 
 /* Adressing modes.  */
 #define Adrmod_index_byte        0x1c
@@ -448,7 +446,7 @@ invalid_float (float_type_u *p, int len)
    bit position of the addressing extension.  BUFFER contains the
    instruction.  ADDR is where BUFFER was read from.  Put the disassembled
    version of the operand in RESULT.  INDEX_OFFSET is the bit position
-   of the index byte (it contains garbage if this operand is not a
+   of the index byte (it contains -1 if this operand is not a
    general operand using scaled indexed addressing mode).  */
 
 static int
@@ -526,9 +524,7 @@ print_insn_arg (int d,
          /* Immediate.  */
          switch (d)
            {
-           case 'I':
-           case 'Z':
-           case 'A':
+           default:
              /* I and Z are output operands and can`t be immediate
                 A is an address and we can`t have the address of
                 an immediate either. We don't know how much to increase
@@ -792,10 +788,8 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
   if (*d)
     {
       /* Offset in bits of the first thing beyond each index byte.
-        Element 0 is for operand A and element 1 is for operand B.
-        The rest are irrelevant, but we put them here so we don't
-        index outside the array.  */
-      int index_offset[MAX_ARGS];
+        Element 0 is for operand A and element 1 is for operand B.  */
+      int index_offset[2];
 
       /* 0 for operand A, 1 for operand B, greater for other args.  */
       int whicharg = 0;
@@ -808,9 +802,12 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
         if we are using scaled indexed addressing mode, since the index
         bytes occur right after the basic instruction, not as part
         of the addressing extension.  */
-      if (Is_gen(d[1]))
+      index_offset[0] = -1;
+      index_offset[1] = -1;
+      if (Is_gen (d[1]))
        {
-         int addr_mode = bit_extract (buffer, ioffset - 5, 5);
+         int bitoff = d[1] == 'f' ? 10 : 5;
+         int addr_mode = bit_extract (buffer, ioffset - bitoff, 5);
 
          if (Adrmod_is_index (addr_mode))
            {
@@ -819,7 +816,7 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
            }
        }
 
-      if (d[2] && Is_gen(d[3]))
+      if (d[2] && Is_gen (d[3]))
        {
          int addr_mode = bit_extract (buffer, ioffset - 10, 5);
 
@@ -833,15 +830,16 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info)
       while (*d)
        {
          argnum = *d - '1';
+         if (argnum >= MAX_ARGS)
+           abort ();
          d++;
-         if (argnum > maxarg && argnum < MAX_ARGS)
+         if (argnum > maxarg)
            maxarg = argnum;
          ioffset = print_insn_arg (*d, ioffset, &aoffset, buffer,
                                    memaddr, arg_bufs[argnum],
-                                   index_offset[whicharg]);
+                                   whicharg > 1 ? -1 : index_offset[whicharg]);
          d++;
-         if (whicharg++ >= 1)
-           break;
+         whicharg++;
        }
 
       for (argnum = 0; argnum <= maxarg; argnum++)