]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - opcodes/z8k-dis.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / opcodes / z8k-dis.c
index b2533b082752b1336152077e5247f14cd8585216..11786c85e142fee1034a4d58d7792f0bf99c0664 100644 (file)
@@ -1,5 +1,5 @@
 /* Disassemble z8000 code.
-   Copyright (C) 1992-2019 Free Software Foundation, Inc.
+   Copyright (C) 1992-2021 Free Software Foundation, Inc.
 
    This file is part of the GNU opcodes library.
 
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "disassemble.h"
+#include "libiberty.h"
 
 #define DEFINE_TABLE
 #include "z8k-opc.h"
@@ -35,7 +36,7 @@ typedef struct
   unsigned short words[24];
 
   /* Nibble number of first word not yet fetched.  */
-  int max_fetched;
+  unsigned int max_fetched;
   bfd_vma insn_start;
   OPCODES_SIGJMP_BUF bailout;
 
@@ -189,7 +190,7 @@ print_insn_z8002 (bfd_vma addr, disassemble_info *info)
 int
 z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info)
 {
-  int nibl_index, tabl_index;
+  unsigned int nibl_index, tabl_index;
   int nibl_matched;
   int need_fetch = 0;
   unsigned short instr_nibl;
@@ -202,7 +203,9 @@ z8k_lookup_instr (unsigned char *nibbles, disassemble_info *info)
     {
       nibl_matched = 1;
       for (nibl_index = 0;
-          nibl_index < z8k_table[tabl_index].length * 2 && nibl_matched;
+          nibl_matched
+            && nibl_index < ARRAY_SIZE (z8k_table[0].byte_info)
+            && nibl_index < z8k_table[tabl_index].length * 2;
           nibl_index++)
        {
          if ((nibl_index % 4) == 0)
@@ -281,7 +284,7 @@ output_instr (instr_data_s *instr_data,
               unsigned long addr ATTRIBUTE_UNUSED,
               disassemble_info *info)
 {
-  int num_bytes;
+  unsigned int num_bytes;
   char out_str[100];
 
   out_str[0] = 0;
@@ -297,7 +300,7 @@ output_instr (instr_data_s *instr_data,
 static void
 unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info)
 {
-  int nibl_count, loop;
+  unsigned int nibl_count, loop;
   unsigned short instr_nibl, instr_byte, instr_word;
   long instr_long;
   unsigned int tabl_datum, datum_class;
@@ -366,8 +369,8 @@ unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info
              break;
            case ARG_IMM32:
              FETCH_DATA (info, nibl_count + 8);
-             instr_long = (instr_data->words[nibl_count] << 16)
-               | (instr_data->words[nibl_count + 4]);
+             instr_long = ((unsigned) instr_data->words[nibl_count] << 16
+                           | instr_data->words[nibl_count + 4]);
              instr_data->immediate = instr_long;
              nibl_count += 7;
              break;
@@ -399,17 +402,17 @@ unpack_instr (instr_data_s *instr_data, int is_segmented, disassemble_info *info
              if (instr_nibl & 0x8)
                {
                  FETCH_DATA (info, nibl_count + 8);
-                 instr_long = (instr_data->words[nibl_count] << 16)
-                   | (instr_data->words[nibl_count + 4]);
-                 instr_data->address = ((instr_word & 0x7f00) << 16)
-                   + (instr_long & 0xffff);
+                 instr_long = ((unsigned) instr_data->words[nibl_count] << 16
+                               | instr_data->words[nibl_count + 4]);
+                 instr_data->address = ((instr_word & 0x7f00) << 16
+                                        | (instr_long & 0xffff));
                  nibl_count += 7;
                  seg_length = 2;
                }
              else
                {
-                 instr_data->address = ((instr_word & 0x7f00) << 16)
-                   + (instr_word & 0x00ff);
+                 instr_data->address = ((instr_word & 0x7f00) << 16
+                                        | (instr_word & 0x00ff));
                  nibl_count += 3;
                }
            }