X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ppc-dis.c;h=f9ae53e1d1a661aa13517dd9c10089158c7b0abb;hb=d66846a14e191c75f4aa373623dd9a7aaa843ade;hp=354b2ac8cba6e141d2fbce607d833f13c3cac175;hpb=274da6b24b93e98119de92f22fff24f79ba173ba;p=qemu diff --git a/ppc-dis.c b/ppc-dis.c index 354b2ac..f9ae53e 100644 --- a/ppc-dis.c +++ b/ppc-dis.c @@ -646,7 +646,7 @@ const struct powerpc_operand powerpc_operands[] = same. */ /*ARGSUSED*/ -static unsigned long +static unsigned long insert_bat (insn, value, errmsg) uint32_t insn; int32_t value; @@ -1122,7 +1122,7 @@ insert_ras (insn, value, errmsg) extraction function just checks that the fields are the same. */ /*ARGSUSED*/ -static unsigned long +static unsigned long insert_rbs (insn, value, errmsg) uint32_t insn; int32_t value; @@ -3067,25 +3067,36 @@ const struct powerpc_macro powerpc_macros[] = { const int powerpc_num_macros = sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); -static int print_insn_powerpc(FILE *, uint32_t insn, unsigned memaddr, int dialect); +static int +print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, + int dialect); /* Print a big endian PowerPC instruction. For convenience, also disassemble instructions supported by the Motorola PowerPC 601. */ -#include "cpu.h" int print_insn_ppc (bfd_vma pc, disassemble_info *info) { uint32_t opc; - - (*info->read_memory_func)(pc, (bfd_byte *)(&opc), 4, info); - return print_insn_powerpc (info->stream, tswap32(opc), pc, - PPC | B32 | M601); + bfd_byte buf[4]; + + (*info->read_memory_func)(pc, buf, 4, info); + if (info->endian == BFD_ENDIAN_BIG) + opc = bfd_getb32(buf); + else + opc = bfd_getl32(buf); + if (info->mach == bfd_mach_ppc64) { + return print_insn_powerpc (info, opc, pc, + PPC | B64); + } else { + return print_insn_powerpc (info, opc, pc, + PPC | B32 | M601); + } } /* Print a PowerPC or POWER instruction. */ -int -print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, +static int +print_insn_powerpc (disassemble_info *info, uint32_t insn, unsigned memaddr, int dialect) { const struct powerpc_opcode *opcode; @@ -3131,9 +3142,9 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, continue; /* The instruction is valid. */ - fprintf(out, "%s", opcode->name); + (*info->fprintf_func)(info->stream, "%s", opcode->name); if (opcode->operands[0] != 0) - fprintf(out, "\t"); + (*info->fprintf_func)(info->stream, "\t"); /* Now extract and print the operands. */ need_comma = 0; @@ -3170,26 +3181,26 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, if (need_comma) { - fprintf(out, ","); + (*info->fprintf_func)(info->stream, ","); need_comma = 0; } /* Print the operand as directed by the flags. */ if ((operand->flags & PPC_OPERAND_GPR) != 0) - fprintf(out, "r%d", value); + (*info->fprintf_func)(info->stream, "r%d", value); else if ((operand->flags & PPC_OPERAND_FPR) != 0) - fprintf(out, "f%d", value); + (*info->fprintf_func)(info->stream, "f%d", value); else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) - fprintf(out, "%08X", memaddr + value); + (*info->fprintf_func)(info->stream, "%08X", memaddr + value); else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) - fprintf(out, "%08X", value & 0xffffffff); + (*info->fprintf_func)(info->stream, "%08X", value & 0xffffffff); else if ((operand->flags & PPC_OPERAND_CR) == 0 || (dialect & PPC_OPCODE_PPC) == 0) - fprintf(out, "%d", value); + (*info->fprintf_func)(info->stream, "%d", value); else { if (operand->bits == 3) - fprintf(out, "cr%d", value); + (*info->fprintf_func)(info->stream, "cr%d", value); else { static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; @@ -3198,20 +3209,20 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, cr = value >> 2; if (cr != 0) - fprintf(out, "4*cr%d", cr); + (*info->fprintf_func)(info->stream, "4*cr%d", cr); cc = value & 3; if (cc != 0) { if (cr != 0) - fprintf(out, "+"); - fprintf(out, "%s", cbnames[cc]); + (*info->fprintf_func)(info->stream, "+"); + (*info->fprintf_func)(info->stream, "%s", cbnames[cc]); } } } if (need_paren) { - fprintf(out, ")"); + (*info->fprintf_func)(info->stream, ")"); need_paren = 0; } @@ -3219,7 +3230,7 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, need_comma = 1; else { - fprintf(out, "("); + (*info->fprintf_func)(info->stream, "("); need_paren = 1; } } @@ -3229,7 +3240,7 @@ print_insn_powerpc (FILE *out, uint32_t insn, unsigned memaddr, } /* We could not find a match. */ - fprintf(out, ".long 0x%x", insn); + (*info->fprintf_func)(info->stream, ".long 0x%x", insn); return 4; }