summaryrefslogtreecommitdiff
path: root/opcodes/cgen-dis.in
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2000-08-28 18:17:54 +0000
committerDave Brolley <brolley@redhat.com>2000-08-28 18:17:54 +0000
commit6bb95a0ff8ead058dbfff87384fd379f6f8aeb05 (patch)
tree93bb6a71bbe0f96262581dadf2fa3349e06dbcf9 /opcodes/cgen-dis.in
parentbf830eae8fe6e37ae2bd83b914bb701fb9616db5 (diff)
downloadbinutils-6bb95a0ff8ead058dbfff87384fd379f6f8aeb05.tar.gz
binutils-6bb95a0ff8ead058dbfff87384fd379f6f8aeb05.tar.bz2
binutils-6bb95a0ff8ead058dbfff87384fd379f6f8aeb05.zip
2000-08-28 Dave Brolley <brolley@redhat.com>
* cgen-ibld.in (cgen_put_insn_int_value): New function. (insert_normal): Allow for non-zero word_offset with CGEN_INT_INSN_P. (insert_insn_normal): Use cgen_put_insn_int_value with CGEN_INT_INSN_P. (extract_normal): Allow for non-zero word_offset with CGEN_INT_INSN_P. * cgen-dis.in (read_insn): New static function. (print_insn): Use read_insn to read the insn into the buffer and set up for disassembly. (print_insn): in CGEN_INT_INSN_P, make sure that the entire insn is in the buffer. * fr30-asm.c: Regenerated. * fr30-desc.c: Regenerated. * fr30-desc.h Regenerated. * fr30-dis.c: Regenerated. * fr30-ibld.c: Regenerated. * fr30-opc.c: Regenerated. * fr30-opc.h Regenerated. * m32r-asm.c: Regenerated. * m32r-desc.c: Regenerated. * m32r-desc.h Regenerated. * m32r-dis.c: Regenerated. * m32r-ibld.c: Regenerated. * m32r-opc.c: Regenerated.
Diffstat (limited to 'opcodes/cgen-dis.in')
-rw-r--r--opcodes/cgen-dis.in75
1 files changed, 59 insertions, 16 deletions
diff --git a/opcodes/cgen-dis.in b/opcodes/cgen-dis.in
index 4b3faf96a57..9fee32af2d5 100644
--- a/opcodes/cgen-dis.in
+++ b/opcodes/cgen-dis.in
@@ -187,43 +187,70 @@ print_insn_normal (cd, dis_info, insn, fields, pc, length)
}
}
-/* Utility to print an insn.
- BUF is the base part of the insn, target byte order, BUFLEN bytes long.
- The result is the size of the insn in bytes or zero for an unknown insn
- or -1 if an error occurs fetching data (memory_error_func will have
- been called). */
-
+/* Subroutine of print_insn. Reads an insn into the given buffers and updates
+ the extract info.
+ Returns 0 if all is well, non-zero otherwise. */
static int
-print_insn (cd, pc, info, buf, buflen)
+read_insn (cd, pc, info, buf, buflen, ex_info, insn_value)
CGEN_CPU_DESC cd;
bfd_vma pc;
disassemble_info *info;
char *buf;
int buflen;
+ CGEN_EXTRACT_INFO *ex_info;
+ unsigned long *insn_value;
{
- unsigned long insn_value;
- const CGEN_INSN_LIST *insn_list;
- CGEN_EXTRACT_INFO ex_info;
+ int status = (*info->read_memory_func) (pc, buf, buflen, info);
+ if (status != 0)
+ {
+ (*info->memory_error_func) (status, pc, info);
+ return -1;
+ }
- ex_info.dis_info = info;
- ex_info.valid = (1 << (cd->base_insn_bitsize / 8)) - 1;
- ex_info.insn_bytes = buf;
+ ex_info->dis_info = info;
+ ex_info->valid = (1 << buflen) - 1;
+ ex_info->insn_bytes = buf;
switch (buflen)
{
case 1:
- insn_value = buf[0];
+ *insn_value = buf[0];
break;
case 2:
- insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf);
+ *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf);
break;
case 4:
- insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf);
+ *insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb32 (buf) : bfd_getl32 (buf);
break;
default:
abort ();
}
+ return 0;
+}
+
+/* Utility to print an insn.
+ BUF is the base part of the insn, target byte order, BUFLEN bytes long.
+ The result is the size of the insn in bytes or zero for an unknown insn
+ or -1 if an error occurs fetching data (memory_error_func will have
+ been called). */
+
+static int
+print_insn (cd, pc, info, buf, buflen)
+ CGEN_CPU_DESC cd;
+ bfd_vma pc;
+ disassemble_info *info;
+ char *buf;
+ int buflen;
+{
+ unsigned long insn_value;
+ 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;
+
/* The instructions are stored in hash lists.
Pick the first one and keep trying until we find the right one. */
@@ -254,6 +281,22 @@ print_insn (cd, pc, info, buf, buflen)
machine insn and extracts the fields. The second pass prints
them. */
+#if CGEN_INT_INSN_P
+ /* Make sure the entire insn is loaded into insn_value. */
+ if (CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize)
+ {
+ unsigned long full_insn_value;
+ int rc = read_insn (cd, pc, info, buf,
+ CGEN_INSN_BITSIZE (insn) / 8,
+ & ex_info, & full_insn_value);
+ if (rc != 0)
+ return rc;
+ length = CGEN_EXTRACT_FN (cd, insn)
+ (cd, insn, &ex_info, full_insn_value, &fields, pc);
+ }
+ else
+#endif
+
length = CGEN_EXTRACT_FN (cd, insn)
(cd, insn, &ex_info, insn_value, &fields, pc);
/* length < 0 -> error */