From e202fa84e706abb043aed457473a764c76672297 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Thu, 13 Sep 2012 22:24:51 +0000 Subject: Bi-endian patches for moxie --- opcodes/ChangeLog | 4 ++++ opcodes/moxie-dis.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'opcodes') diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 13b0173..a1b2bfe 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2012-09-13 Anthony Green + + * moxie-dis.c (print_insn_moxie): Handle bi-endian encodings. + 2012-09-10 Matthias Klose * config.in: Disable sanity check for kfreebsd. diff --git a/opcodes/moxie-dis.c b/opcodes/moxie-dis.c index 79ef099..77821bb 100644 --- a/opcodes/moxie-dis.c +++ b/opcodes/moxie-dis.c @@ -53,7 +53,11 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) if ((status = info->read_memory_func (addr, buffer, 2, info))) goto fail; - iword = bfd_getb16 (buffer); + + if (info->endian == BFD_ENDIAN_BIG) + iword = bfd_getb16 (buffer); + else + iword = bfd_getl16 (buffer); /* Form 1 instructions have the high bit set to 0. */ if ((iword & (1<<15)) == 0) @@ -79,7 +83,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr + 2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t%s, 0x%x", opcode->name, reg_names[OP_A(iword)], imm); length = 6; @@ -90,7 +97,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr + 2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t0x%x", opcode->name, imm); length = 6; } @@ -100,7 +110,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr + 2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t", opcode->name); info->print_address_func ((bfd_vma) imm, info); length = 6; @@ -119,7 +132,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr + 2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t0x%x, %s", opcode->name, imm, reg_names[OP_A(iword)]); length = 6; @@ -130,7 +146,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr+2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t0x%x(%s), %s", opcode->name, imm, reg_names[OP_A(iword)], @@ -143,7 +162,10 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) unsigned imm; if ((status = info->read_memory_func (addr+2, buffer, 4, info))) goto fail; - imm = bfd_getb32 (buffer); + if (info->endian == BFD_ENDIAN_BIG) + imm = bfd_getb32 (buffer); + else + imm = bfd_getl32 (buffer); fpr (stream, "%s\t%s, 0x%x(%s)", opcode->name, reg_names[OP_A(iword)], -- cgit v1.1