aboutsummaryrefslogtreecommitdiff
path: root/opcodes/cgen-opc.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@redhat.com>2001-01-02 16:34:07 +0000
committerFrank Ch. Eigler <fche@redhat.com>2001-01-02 16:34:07 +0000
commitaed80daedfb2895a386538f2e25bd6e00fb7935c (patch)
treefce9f1c96c2484309084f7902e7c80433d56d04a /opcodes/cgen-opc.c
parent3d855632912f4bbfbd6c27dc78c08f2d65e9b638 (diff)
downloadgdb-aed80daedfb2895a386538f2e25bd6e00fb7935c.zip
gdb-aed80daedfb2895a386538f2e25bd6e00fb7935c.tar.gz
gdb-aed80daedfb2895a386538f2e25bd6e00fb7935c.tar.bz2
* generalization
2001-01-02 Richard Sandiford <rsandifo@redhat.com> * cgen-dis.c (hash_insn_array): Use bfd_put_bits(). (hash_insn_list): Likewise * cgen-ibld.in (insert_1): Use bfd_put_bits() and bfd_get_bits(). (extract_1): Use bfd_get_bits(). (extract_normal): Apply sign extension to both extraction methods. * cgen-opc.c (cgen_get_insn_value): Use bfd_get_bits() (cgen_put_insn_value): Use bfd_put_bits()
Diffstat (limited to 'opcodes/cgen-opc.c')
-rw-r--r--opcodes/cgen-opc.c47
1 files changed, 3 insertions, 44 deletions
diff --git a/opcodes/cgen-opc.c b/opcodes/cgen-opc.c
index 14936b3..1945f9b 100644
--- a/opcodes/cgen-opc.c
+++ b/opcodes/cgen-opc.c
@@ -374,30 +374,7 @@ cgen_get_insn_value (cd, buf, length)
unsigned char *buf;
int length;
{
- CGEN_INSN_INT value;
-
- switch (length)
- {
- case 8:
- value = *buf;
- break;
- case 16:
- if (cd->insn_endian == CGEN_ENDIAN_BIG)
- value = bfd_getb16 (buf);
- else
- value = bfd_getl16 (buf);
- break;
- case 32:
- if (cd->insn_endian == CGEN_ENDIAN_BIG)
- value = bfd_getb32 (buf);
- else
- value = bfd_getl32 (buf);
- break;
- default:
- abort ();
- }
-
- return value;
+ bfd_get_bits (buf, length, cd->insn_endian == CGEN_ENDIAN_BIG);
}
/* Cover function to store an insn value properly byteswapped. */
@@ -409,26 +386,8 @@ cgen_put_insn_value (cd, buf, length, value)
int length;
CGEN_INSN_INT value;
{
- switch (length)
- {
- case 8:
- buf[0] = value;
- break;
- case 16:
- if (cd->insn_endian == CGEN_ENDIAN_BIG)
- bfd_putb16 (value, buf);
- else
- bfd_putl16 (value, buf);
- break;
- case 32:
- if (cd->insn_endian == CGEN_ENDIAN_BIG)
- bfd_putb32 (value, buf);
- else
- bfd_putl32 (value, buf);
- break;
- default:
- abort ();
- }
+ bfd_put_bits ((bfd_vma) value, buf, length,
+ cd->insn_endian == CGEN_ENDIAN_BIG);
}
/* Look up instruction INSN_*_VALUE and extract its fields.