Enhance the RX disassembler to detect and report bad instructions.

opcode	* rx.h (enum RX_Size): Add RX_Bad_Size entry.

opcodes	* rx-decode.opc (bwl): Use RX_Bad_Size.
	(sbwl): Likewise.
	(ubwl): Likewise.  Rename to ubw.
	(uBWL): Rename to uBW.
	Replace all references to uBWL with uBW.
	* rx-decode.c: Regenerate.
	* rx-dis.c (size_names): Add entry for RX_Bad_Size.
	(opsize_names): Likewise.
	(print_insn_rx): Detect and report RX_Bad_Size.
This commit is contained in:
Nick Clifton 2015-09-22 17:21:13 +01:00
parent bc1f8cdaf4
commit f04265eceb
6 changed files with 63 additions and 28 deletions

View file

@ -48,14 +48,14 @@ rx_get_byte (void * vdata)
return buf[0];
}
static char const * size_names[] =
static char const * size_names[RX_MAX_SIZE] =
{
"", ".b", ".ub", ".b", ".w", ".uw", ".w", ".a", ".l"
"", ".b", ".ub", ".b", ".w", ".uw", ".w", ".a", ".l", "<error>"
};
static char const * opsize_names[] =
static char const * opsize_names[RX_MAX_SIZE] =
{
"", ".b", ".b", ".b", ".w", ".w", ".w", ".a", ".l"
"", ".b", ".b", ".b", ".w", ".w", ".w", ".a", ".l", "<error>"
};
static char const * register_names[] =
@ -64,10 +64,10 @@ static char const * register_names[] =
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
/* control register */
"psw", "pc", "usp", "fpsw", "", "", "", "wr",
"bpsw", "bpc", "isp", "fintv", "intb", "", "", "",
"pbp", "pben", "", "", "", "", "", "",
"bbpsw", "bbpc", "", "", "", "", "", ""
"psw", "pc", "usp", "fpsw", NULL, NULL, NULL, NULL,
"bpsw", "bpc", "isp", "fintv", "intb", NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
static char const * condition_names[] =
@ -104,6 +104,23 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis)
#define PS (dis->stream)
#define PC(c) PR (PS, "%c", c)
/* Detect illegal instructions. */
if (opcode.op[0].size == RX_Bad_Size
|| register_names [opcode.op[0].reg] == NULL
|| register_names [opcode.op[1].reg] == NULL
|| register_names [opcode.op[2].reg] == NULL)
{
bfd_byte buf[10];
int i;
PR (PS, ".byte ");
rx_data.dis->read_memory_func (rx_data.pc - rv, buf, rv, rx_data.dis);
for (i = 0 ; i < rv; i++)
PR (PS, "0x%02x ", buf[i]);
return rv;
}
for (s = opcode.syntax; *s; s++)
{
if (*s != '%')