Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/opcodes/avr-dis.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    2222#include "dis-asm.h"
    2323#include "opintl.h"
    24 
     24#include "libiberty.h"
    2525
    2626struct avr_opcodes_s
     
    3232  int isa;
    3333  unsigned int bin_opcode;
    34   unsigned int bin_mask;
    3534};
    3635
    3736#define AVR_INSN(NAME, CONSTR, OPCODE, SIZE, ISA, BIN) \
    38 {#NAME, CONSTR, OPCODE, SIZE, ISA, BIN, 0},
    39 
    40 struct avr_opcodes_s avr_opcodes[] =
     37{#NAME, CONSTR, OPCODE, SIZE, ISA, BIN},
     38
     39const struct avr_opcodes_s avr_opcodes[] =
    4140{
    4241  #include "opcode/avr.h"
    43   {NULL, NULL, NULL, 0, 0, 0, 0}
     42  {NULL, NULL, NULL, 0, 0, 0}
    4443};
    4544
     
    258257{
    259258  unsigned int insn, insn2;
    260   struct avr_opcodes_s *opcode;
     259  const struct avr_opcodes_s *opcode;
     260  static unsigned int *maskptr;
    261261  void *stream = info->stream;
    262262  fprintf_ftype prin = info->fprintf_func;
     263  static unsigned int *avr_bin_masks;
    263264  static int initialized;
    264265  int cmd_len = 2;
     
    268269  if (!initialized)
    269270    {
    270       initialized = 1;
    271      
    272       for (opcode = avr_opcodes; opcode->name; opcode++)
     271      unsigned int nopcodes;
     272
     273      nopcodes = sizeof (avr_opcodes) / sizeof (struct avr_opcodes_s);
     274     
     275      avr_bin_masks = (unsigned int *)
     276        xmalloc (nopcodes * sizeof (unsigned int));
     277
     278      for (opcode = avr_opcodes, maskptr = avr_bin_masks;
     279           opcode->name;
     280           opcode++, maskptr++)
    273281        {
    274282          char * s;
     
    285293          assert (s - opcode->opcode == 16);
    286294          assert (opcode->bin_opcode == bin);
    287           opcode->bin_mask = mask;
     295          *maskptr = mask;
    288296        }
     297
     298      initialized = 1;
    289299    }
    290300
    291301  insn = avrdis_opcode (addr, info);
    292302 
    293   for (opcode = avr_opcodes; opcode->name; opcode++)
    294     {
    295       if ((insn & opcode->bin_mask) == opcode->bin_opcode)
     303  for (opcode = avr_opcodes, maskptr = avr_bin_masks;
     304       opcode->name;
     305       opcode++, maskptr++)
     306    {
     307      if ((insn & *maskptr) == opcode->bin_opcode)
    296308        break;
    297309    }
Note: See TracChangeset for help on using the changeset viewer.