]> git.proxmox.com Git - qemu.git/blobdiff - ppc-dis.c
Fix NAME2/FIELD2 warnings
[qemu.git] / ppc-dis.c
index 354b2ac8cba6e141d2fbce607d833f13c3cac175..dc640227840a8a9cf12b66f08499c4e72efa5189 100644 (file)
--- a/ppc-dis.c
+++ b/ppc-dis.c
@@ -16,7 +16,7 @@ the GNU General Public License for more details.
 
 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
@@ -37,7 +37,7 @@ the GNU General Public License for more details.
 
 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.  */
 
@@ -273,7 +273,8 @@ the GNU General Public License for more details.
 
 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
@@ -646,7 +647,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 +1123,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 +3068,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 +3143,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 +3182,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 +3210,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 +3231,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 +3241,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;
 }