Some get_last_target_status tweaks
[deliverable/binutils-gdb.git] / opcodes / xgate-dis.c
index 8c722f5d5c0eaa3b684b7dcd59daf99025baab51..9d84431978e7367804846693d7dbe5e152153120 100644 (file)
@@ -1,6 +1,5 @@
 /* xgate-dis.c -- Freescale XGATE disassembly
-   Copyright 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
    Written by Sean Keys (skeys@ipdatasys.com)
 
    This file is part of the GNU opcodes library.
@@ -22,7 +21,7 @@
 
 #include "sysdep.h"
 #include <assert.h>
-#include "dis-asm.h"
+#include "disassemble.h"
 #include "opintl.h"
 #include "libiberty.h"
 #include "ansidecl.h"
@@ -124,92 +123,69 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info)
           (*info->fprintf_func)(info->stream, "%s", decodePTR->opcodePTR->name);
 
           /* First we compare the shorthand format of the constraints. If we
-            still are unable to pinpoint the operands
-            we analyze the opcodes constraint string.  */
-          switch (decodePTR->opcodePTR->sh_format)
-          {
-          case XG_R_C:
-            (*info->fprintf_func)(info->stream, " R%x, CCR",
-                (raw_code >> 8) & 0x7);
-            break;
-          case XG_C_R:
-            (*info->fprintf_func)(info->stream, " CCR, R%x",
-                (raw_code >> 8) & 0x7);
-            break;
-          case XG_R_P:
-            (*info->fprintf_func)(info->stream, " R%x, PC",
-                (raw_code >> 8) & 0x7);
-            break;
-          case XG_INH:
-            break;
-          case XG_R_R_R:
-            if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI))
-              {
-                (*info->fprintf_func)(info->stream, " R%x, R%x, R%x",
-                    (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
-                    (raw_code >> 2) & 0x7);
-              }
-            else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR))
-              {
-                if (raw_code & 0x01)
-                  {
-                    (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)",
-                        (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
-                        (raw_code >> 2) & 0x7);
-                  }
-                else if (raw_code & 0x02)
-                  {
-                    (*info->fprintf_func)(info->stream, " R%x, (R%x, -R%x)",
-                        (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
-                        (raw_code >> 2) & 0x7);
-                  }
-                else
-                  {
-                    (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)",
-                        (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
-                        (raw_code >> 2) & 0x7);
-                  }
-              }
-            else
-              {
-                (*info->fprintf_func)(info->stream, " unhandled mode %s",
-                    decodePTR->opcodePTR->constraints);
-              }
-            break;
-          case XG_R_R:
-            if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA_MON))
-              {
-                operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
-                    raw_code);
-                operandTwo = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
-                    raw_code);
-                (*info->fprintf_func)(info->stream, " R%x, R%x", operandOne,
-                    operandTwo);
-              }
-            else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA))
-              {
-                operandOne = ripBits (&operMaskReg, 3, opcodePTR, raw_code);
-                operandTwo = ripBits (&operMaskReg, 3, opcodePTR, raw_code);
-                (*info->fprintf_func)(info->stream, " R%x, R%x", operandOne,
-                    operandTwo);
-              }
-            else
-              {
-                (*info->fprintf_func)(info->stream, " unhandled mode %s",
-                    opcodePTR->constraints);
-              }
-            break;
-          case XG_R_R_I:
-            (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)",
-                (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0x1f);
-            break;
-          case XG_R:
-            operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
-                raw_code);
-            (*info->fprintf_func)(info->stream, " R%x", operandOne);
-            break;
-          case XG_I | XG_PCREL:
-          if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9))
+             still are unable to pinpoint the operands
+             we analyze the opcodes constraint string.  */
+          if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_C))
+               {
+                 (*info->fprintf_func)(info->stream, " R%x, CCR",
+                         (raw_code >> 8) & 0x7);
+               }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_C_R))
+            {
+                 (*info->fprintf_func)(info->stream, " CCR, R%x",
+                     (raw_code >> 8) & 0x7);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON_R_P))
+            {
+                 (*info->fprintf_func)(info->stream, " R%x, PC",
+                     (raw_code >> 8) & 0x7);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_TRI))
+            {
+                  (*info->fprintf_func)(info->stream, " R%x, R%x, R%x",
+                      (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
+                      (raw_code >> 2) & 0x7);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDR))
+            {
+                  if (raw_code & 0x01)
+                    {
+                      (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x+)",
+                          (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
+                          (raw_code >> 2) & 0x7);
+                    }
+                   else if (raw_code & 0x02)
+                          {
+                            (*info->fprintf_func)(info->stream, " R%x, (R%x, -R%x)",
+                                (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
+                                (raw_code >> 2) & 0x7);
+                          }
+                   else
+                     {
+                       (*info->fprintf_func)(info->stream, " R%x, (R%x, R%x)",
+                           (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7,
+                           (raw_code >> 2) & 0x7);
+                     }
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_DYA))
+            {
+                 operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, raw_code);
+                 operandTwo = ripBits (&operMaskReg, 3, decodePTR->opcodePTR, raw_code);
+                ( *info->fprintf_func)(info->stream, " R%x, R%x", operandOne,
+                     operandTwo);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IDO5))
+            {
+                 (*info->fprintf_func)(info->stream, " R%x, (R%x, #0x%x)",
+                     (raw_code >> 8) & 0x7, (raw_code >> 5) & 0x7, raw_code & 0x1f);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_MON))
+            {
+                 operandOne = ripBits (&operMaskReg, 3, decodePTR->opcodePTR,
+                    raw_code);
+                (*info->fprintf_func)(info->stream, " R%x", operandOne);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL9))
             {
               /* If address is negative handle it accordingly.  */
               if (raw_code & XGATE_NINE_SIGNBIT)
@@ -224,10 +200,10 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info)
                   relAddr = raw_code & 0xff;
                   relAddr = (relAddr << 1) + 2;
                 }
-              (*info->fprintf_func)(info->stream, " *%d", relAddr);
-              (*info->fprintf_func)(info->stream, "  Abs* 0x");
-              (*info->print_address_func)(memaddr + relAddr, info);
-            }
+             (*info->fprintf_func)(info->stream, " *%d", relAddr);
+             (*info->fprintf_func)(info->stream, "  Abs* 0x");
+             (*info->print_address_func)(memaddr + relAddr, info);
+           }
           else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_REL10))
             {
               /* If address is negative handle it accordingly.  */
@@ -247,54 +223,44 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info)
               (*info->fprintf_func)(info->stream, "  Abs* 0x");
               (*info->print_address_func)(memaddr + relAddr, info);
             }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4))
+            {
+              (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
+              (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8))
+            {
+              if (macro_search (decodePTR->opcodePTR->name, previousOpName) &&
+                 previousOpName[0])
+               {
+                 absAddress = (0xFF & raw_code) << 8;
+                 absAddress |= perviousBin & 0xFF;
+                 (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x",
+                     (raw_code >> 8) & 0x7, raw_code & 0xff);
+                 (*info->print_address_func)(absAddress, info);
+                 previousOpName[0] = 0;
+               }
+              else
+               {
+                 strcpy (previousOpName, decodePTR->opcodePTR->name);
+                 (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
+                     (raw_code >> 8) & 0x7, raw_code & 0xff);
+               }
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM3))
+            {
+                 (*info->fprintf_func)(info->stream, " #0x%x",
+                    (raw_code >> 8) & 0x7);
+            }
+          else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_INH))
+            {
+                 //
+            }
           else
             {
-              (*info->fprintf_func)(info->stream,
-                  " Can't disassemble for mode) %s",
-                  decodePTR->opcodePTR->constraints);
+              (*info->fprintf_func)(info->stream, " unhandled mode %s",
+                                   decodePTR->opcodePTR->constraints);
             }
-          break;
-          case XG_R_I:
-            if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM4))
-              {
-                (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
-                    (raw_code >> 8) & 0x7, (raw_code >> 4) & 0xF);
-              }
-            else if (!strcmp (decodePTR->opcodePTR->constraints, XGATE_OP_IMM8))
-              {
-                if (macro_search (decodePTR->opcodePTR->name, previousOpName) &&
-                    previousOpName[0])
-                  {
-                    absAddress = (0xFF & raw_code) << 8;
-                    absAddress |= perviousBin & 0xFF;
-                    (*info->fprintf_func)(info->stream, " R%x, #0x%02x Abs* 0x",
-                        (raw_code >> 8) & 0x7, raw_code & 0xff);
-                    (*info->print_address_func)(absAddress, info);
-                    previousOpName[0] = 0;
-                  }
-                else
-                  {
-                    strcpy (previousOpName, decodePTR->opcodePTR->name);
-                    (*info->fprintf_func)(info->stream, " R%x, #0x%02x",
-                        (raw_code >> 8) & 0x7, raw_code & 0xff);
-                  }
-              }
-            else
-              {
-                (*info->fprintf_func)(info->stream,
-                    " Can't disassemble for mode %s",
-                    decodePTR->opcodePTR->constraints);
-              }
-            break;
-          case XG_I:
-            (*info->fprintf_func)(info->stream, " #0x%x",
-                (raw_code >> 8) & 0x7);
-            break;
-          default:
-            (*info->fprintf_func)(info->stream, "address mode not found\t %x",
-                opcodePTR->bin_opcode);
-            break;
-          }
           perviousBin = raw_code;
         }
       else
This page took 0.026062 seconds and 4 git commands to generate.