#include "opcode/h8300.h"
#include "dis-asm.h"
#include "opintl.h"
+#include "libiberty.h"
+
+struct h8_instruction
+{
+ int length;
+ const struct h8_opcode *opcode;
+};
+
+struct h8_instruction *h8_instructions;
static void bfd_h8_disassemble_init PARAMS ((void));
static unsigned int bfd_h8_disassemble
bfd_h8_disassemble_init ()
{
unsigned int i;
- struct h8_opcode *p;
+ unsigned int nopcodes;
+ const struct h8_opcode *p;
+ struct h8_instruction *pi;
- for (p = h8_opcodes; p->name; p++)
+ nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
+
+ h8_instructions = (struct h8_instruction *)
+ xmalloc (nopcodes * sizeof (struct h8_instruction));
+
+ for (p = h8_opcodes, pi = h8_instructions; p->name; p++, pi++)
{
int n1 = 0;
int n2 = 0;
if (i & 1)
abort ();
- p->length = i / 2;
+ pi->length = i / 2;
+ pi->opcode = p;
}
+
+ /* Add entry for the NULL vector terminator. */
+ pi->length = 0;
+ pi->opcode = p;
}
static unsigned int
int abs = 0;
int bit = 0;
int plen = 0;
- static boolean init = 0;
- struct h8_opcode *q;
+ static bfd_boolean init = 0;
+ const struct h8_instruction *qi;
char const **pregnames = mode != 0 ? lregnames : wregnames;
int status;
int l;
status = info->read_memory_func (addr + l, data + l, 2, info);
/* Find the exact opcode/arg combo. */
- for (q = h8_opcodes; q->name; q++)
+ for (qi = h8_instructions; qi->opcode->name; qi++)
{
+ const struct h8_opcode *q = qi->opcode;
op_type *nib = q->data.nib;
unsigned int len = 0;
{
int i;
- for (i = 0; i < q->length; i++)
+ for (i = 0; i < qi->length; i++)
fprintf (stream, "%02x ", data[i]);
for (; i < 6; i++)
high = data[3] & 0x7;
fprintf (stream, "@sp+,er%d-er%d", high - count, high);
- return q->length;
+ return qi->length;
}
if (strcmp (q->name, "stm.l") == 0)
low = data[3] & 0x7;
fprintf (stream, "er%d-er%d,@-sp", low, low + count);
- return q->length;
+ return qi->length;
}
/* Fill in the args. */
}
}
- return q->length;
+ return qi->length;
}
else
/* xgettext:c-format */