aboutsummaryrefslogtreecommitdiff
path: root/opcodes/m32r-dis.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2001-05-04 17:45:19 +0000
committerFrank Ch. Eigler <fche@redhat.com>2001-05-04 17:45:19 +0000
commit5264623336b345f3fe0a6b5cf855d89ad49fcb9e (patch)
tree21a2685773f2f7e48ae5bb5e1ed8f5d98ff9ae72 /opcodes/m32r-dis.c
parent992aaec9a9e9657ab62a5fb3282a48ec778c903c (diff)
downloadgdb-5264623336b345f3fe0a6b5cf855d89ad49fcb9e.zip
gdb-5264623336b345f3fe0a6b5cf855d89ad49fcb9e.tar.gz
gdb-5264623336b345f3fe0a6b5cf855d89ad49fcb9e.tar.bz2
* m32r disasm bug fix
2001-05-04 Frank Ch. Eigler <fche@redhat.com> * m32r-dis.c, -asm.c, -ibld.c: Regenerated with disassembler fixes. 2001-05-04 Frank Ch. Eigler <fche@redhat.com> * cgen-dis.in (print_insn): Remove call to read_insn. Instead, assume incoming buffer already has the base insn loaded. Handle case of smaller-than-base instructions for variable-length case.
Diffstat (limited to 'opcodes/m32r-dis.c')
-rw-r--r--opcodes/m32r-dis.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/opcodes/m32r-dis.c b/opcodes/m32r-dis.c
index 7164a40..477a85b 100644
--- a/opcodes/m32r-dis.c
+++ b/opcodes/m32r-dis.c
@@ -438,9 +438,15 @@ print_insn (cd, pc, info, buf, buflen)
const CGEN_INSN_LIST *insn_list;
CGEN_EXTRACT_INFO ex_info;
- int rc = read_insn (cd, pc, info, buf, buflen, & ex_info, & insn_value);
- if (rc != 0)
- return rc;
+ /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
+ insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
+
+ /* Fill in ex_info fields like read_insn would. Don't actually call
+ read_insn, since the incoming buffer is already read (and possibly
+ modified a la m32r). */
+ ex_info.valid = (1 << buflen) - 1;
+ ex_info.dis_info = info;
+ ex_info.insn_bytes = buf;
/* The instructions are stored in hash lists.
Pick the first one and keep trying until we find the right one. */
@@ -451,6 +457,7 @@ print_insn (cd, pc, info, buf, buflen)
const CGEN_INSN *insn = insn_list->insn;
CGEN_FIELDS fields;
int length;
+ unsigned long insn_value_cropped;
#ifdef CGEN_VALIDATE_INSN_SUPPORTED
/* not needed as insn shouldn't be in hash lists if not supported */
@@ -465,7 +472,17 @@ print_insn (cd, pc, info, buf, buflen)
/* Basic bit mask must be correct. */
/* ??? May wish to allow target to defer this check until the extract
handler. */
- if ((insn_value & CGEN_INSN_BASE_MASK (insn))
+
+ /* Base size may exceed this instruction's size. Extract the
+ relevant part from the buffer. */
+ if ((CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
+ (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
+ insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
+ info->endian == BFD_ENDIAN_BIG);
+ else
+ insn_value_cropped = insn_value;
+
+ if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
== CGEN_INSN_BASE_VALUE (insn))
{
/* Printing is handled in two passes. The first pass parses the