2002-11-12 Klee Dienes <kdienes@apple.com>
authorKlee Dienes <kdienes@apple.com>
Mon, 18 Nov 2002 16:54:08 +0000 (16:54 +0000)
committerKlee Dienes <kdienes@apple.com>
Mon, 18 Nov 2002 16:54:08 +0000 (16:54 +0000)
* avr-dis.c: Include libiberty.h (for xmalloc).
(struct avr_opcodes_s): Remove 'bin_mask' field (it's
automatically computed in the init routine).
(AVR_INSN): No longer provide bin_mask field in initializer.
(avr_opcodes_s): Declare as const.
(print_insn_avr): Store the bin_mask field in a separate table
(allocated with xmalloc); iterate through it at the same time as
we iterate through the opcodes.

opcodes/ChangeLog
opcodes/avr-dis.c

index ce23088e1dffc9870d1b05cff89f77ed0d765f40..56f62d89f94354c3fb0925d948f76e89f1e9bd63 100644 (file)
@@ -1,3 +1,14 @@
+2002-11-18  Klee Dienes  <kdienes@apple.com>
+
+       * avr-dis.c: Include libiberty.h (for xmalloc).
+       (struct avr_opcodes_s): Remove 'bin_mask' field (it's
+       automatically computed in the init routine).
+       (AVR_INSN): No longer provide bin_mask field in initializer.
+       (avr_opcodes_s): Declare as const.
+       (print_insn_avr): Store the bin_mask field in a separate table
+       (allocated with xmalloc); iterate through it at the same time as
+       we iterate through the opcodes.
+
 2002-11-18  Klee Dienes  <kdienes@apple.com>
 
        * h8300-dis.c: Include libiberty.h (for xmalloc).
index 4598cab4145cc20ca6464be96cb45c76d810ccfd..adc4680cd14bc85d006e9b77ab5ed13a81bdc19b 100644 (file)
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "sysdep.h"
 #include "dis-asm.h"
 #include "opintl.h"
-
+#include "libiberty.h"
 
 struct avr_opcodes_s
 {
@@ -31,16 +31,15 @@ struct avr_opcodes_s
   int insn_size;               /* in words */
   int isa;
   unsigned int bin_opcode;
-  unsigned int bin_mask;
 };
 
 #define AVR_INSN(NAME, CONSTR, OPCODE, SIZE, ISA, BIN) \
-{#NAME, CONSTR, OPCODE, SIZE, ISA, BIN, 0},
+{#NAME, CONSTR, OPCODE, SIZE, ISA, BIN},
 
-struct avr_opcodes_s avr_opcodes[] =
+const struct avr_opcodes_s avr_opcodes[] =
 {
   #include "opcode/avr.h"
-  {NULL, NULL, NULL, 0, 0, 0, 0}
+  {NULL, NULL, NULL, 0, 0, 0}
 };
 
 static int avr_operand PARAMS ((unsigned int, unsigned int,
@@ -257,9 +256,11 @@ print_insn_avr(addr, info)
      disassemble_info *info;
 {
   unsigned int insn, insn2;
-  struct avr_opcodes_s *opcode;
+  const struct avr_opcodes_s *opcode;
+  static unsigned int *maskptr;
   void *stream = info->stream;
   fprintf_ftype prin = info->fprintf_func;
+  static unsigned int *avr_bin_masks;
   static int initialized;
   int cmd_len = 2;
   int ok = 0;
@@ -267,9 +268,16 @@ print_insn_avr(addr, info)
 
   if (!initialized)
     {
-      initialized = 1;
+      unsigned int nopcodes;
+
+      nopcodes = sizeof (avr_opcodes) / sizeof (struct avr_opcodes_s);
       
-      for (opcode = avr_opcodes; opcode->name; opcode++)
+      avr_bin_masks = (unsigned int *)
+       xmalloc (nopcodes * sizeof (unsigned int));
+
+      for (opcode = avr_opcodes, maskptr = avr_bin_masks;
+          opcode->name;
+          opcode++, maskptr++)
        {
          char * s;
          unsigned int bin = 0;
@@ -284,15 +292,19 @@ print_insn_avr(addr, info)
            }
          assert (s - opcode->opcode == 16);
          assert (opcode->bin_opcode == bin);
-         opcode->bin_mask = mask;
+         *maskptr = mask;
        }
+
+      initialized = 1;
     }
 
   insn = avrdis_opcode (addr, info);
   
-  for (opcode = avr_opcodes; opcode->name; opcode++)
+  for (opcode = avr_opcodes, maskptr = avr_bin_masks;
+       opcode->name;
+       opcode++, maskptr++)
     {
-      if ((insn & opcode->bin_mask) == opcode->bin_opcode)
+      if ((insn & *maskptr) == opcode->bin_opcode)
        break;
     }
   
This page took 0.029125 seconds and 4 git commands to generate.