You should have received a copy of the GNU General Public License
along with this file; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "dis-asm.h"
/* ppc.h -- Header file for PowerPC opcode table
You should have received a copy of the GNU General Public License
along with this file; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
/* The opcode table is an array of struct powerpc_opcode. */
You should have received a copy of the GNU General Public License
along with this file; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+02110-1301, USA. */
/* This file holds the PowerPC opcode table. The opcode table
includes almost all of the extended instruction mnemonics. This
same. */
/*ARGSUSED*/
-static unsigned long
+static unsigned long
insert_bat (insn, value, errmsg)
uint32_t insn;
int32_t value;
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;
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;
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;
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" };
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;
}
need_comma = 1;
else
{
- fprintf(out, "(");
+ (*info->fprintf_func)(info->stream, "(");
need_paren = 1;
}
}
}
/* We could not find a match. */
- fprintf(out, ".long 0x%x", insn);
+ (*info->fprintf_func)(info->stream, ".long 0x%x", insn);
return 4;
}