OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [opcodes/] [mmix-dis.c] - Diff between revs 156 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 156 Rev 816
/* mmix-dis.c -- Disassemble MMIX instructions.
/* mmix-dis.c -- Disassemble MMIX instructions.
   Copyright 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
   Copyright 2000, 2001, 2002, 2007 Free Software Foundation, Inc.
   Written by Hans-Peter Nilsson (hp@bitrange.com)
   Written by Hans-Peter Nilsson (hp@bitrange.com)
 
 
   This file is part of the GNU opcodes library.
   This file is part of the GNU opcodes library.
 
 
   This library is free software; you can redistribute it and/or modify
   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   the Free Software Foundation; either version 3, or (at your option)
   any later version.
   any later version.
 
 
   It is distributed in the hope that it will be useful, but WITHOUT
   It is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.
   License for more details.
 
 
   You should have received a copy of the GNU General Public License
   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
   along with this file; see the file COPYING.  If not, write to the Free
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */
   MA 02110-1301, USA.  */
 
 
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include "opcode/mmix.h"
#include "opcode/mmix.h"
#include "dis-asm.h"
#include "dis-asm.h"
#include "libiberty.h"
#include "libiberty.h"
#include "bfd.h"
#include "bfd.h"
#include "opintl.h"
#include "opintl.h"
 
 
#define BAD_CASE(x)                             \
#define BAD_CASE(x)                             \
 do                                             \
 do                                             \
   {                                            \
   {                                            \
     fprintf (stderr,                           \
     fprintf (stderr,                           \
              _("Bad case %d (%s) in %s:%d\n"), \
              _("Bad case %d (%s) in %s:%d\n"), \
              x, #x, __FILE__, __LINE__);       \
              x, #x, __FILE__, __LINE__);       \
     abort ();                                  \
     abort ();                                  \
   }                                            \
   }                                            \
 while (0)
 while (0)
 
 
#define FATAL_DEBUG                                                     \
#define FATAL_DEBUG                                                     \
 do                                                                     \
 do                                                                     \
   {                                                                    \
   {                                                                    \
     fprintf (stderr,                                                   \
     fprintf (stderr,                                                   \
              _("Internal: Non-debugged code (test-case missing): %s:%d"),\
              _("Internal: Non-debugged code (test-case missing): %s:%d"),\
              __FILE__, __LINE__);                                      \
              __FILE__, __LINE__);                                      \
     abort ();                                                          \
     abort ();                                                          \
   }                                                                    \
   }                                                                    \
 while (0)
 while (0)
 
 
#define ROUND_MODE(n)                                   \
#define ROUND_MODE(n)                                   \
 ((n) == 1 ? "ROUND_OFF" : (n) == 2 ? "ROUND_UP" :      \
 ((n) == 1 ? "ROUND_OFF" : (n) == 2 ? "ROUND_UP" :      \
  (n) == 3 ? "ROUND_DOWN" : (n) == 4 ? "ROUND_NEAR" :   \
  (n) == 3 ? "ROUND_DOWN" : (n) == 4 ? "ROUND_NEAR" :   \
  _("(unknown)"))
  _("(unknown)"))
 
 
#define INSN_IMMEDIATE_BIT (IMM_OFFSET_BIT << 24)
#define INSN_IMMEDIATE_BIT (IMM_OFFSET_BIT << 24)
#define INSN_BACKWARD_OFFSET_BIT (1 << 24)
#define INSN_BACKWARD_OFFSET_BIT (1 << 24)
 
 
struct mmix_dis_info
struct mmix_dis_info
 {
 {
   const char *reg_name[256];
   const char *reg_name[256];
   const char *spec_reg_name[32];
   const char *spec_reg_name[32];
 
 
   /* Waste a little memory so we don't have to allocate each separately.
   /* Waste a little memory so we don't have to allocate each separately.
      We could have an array with static contents for these, but on the
      We could have an array with static contents for these, but on the
      other hand, we don't have to.  */
      other hand, we don't have to.  */
   char basic_reg_name[256][sizeof ("$255")];
   char basic_reg_name[256][sizeof ("$255")];
 };
 };
 
 
/* Initialize a target-specific array in INFO.  */
/* Initialize a target-specific array in INFO.  */
 
 
static bfd_boolean
static bfd_boolean
initialize_mmix_dis_info (struct disassemble_info *info)
initialize_mmix_dis_info (struct disassemble_info *info)
{
{
  struct mmix_dis_info *minfop = malloc (sizeof (struct mmix_dis_info));
  struct mmix_dis_info *minfop = malloc (sizeof (struct mmix_dis_info));
  int i;
  int i;
 
 
  if (minfop == NULL)
  if (minfop == NULL)
    return FALSE;
    return FALSE;
 
 
  memset (minfop, 0, sizeof (*minfop));
  memset (minfop, 0, sizeof (*minfop));
 
 
  /* Initialize register names from register symbols.  If there's no
  /* Initialize register names from register symbols.  If there's no
     register section, then there are no register symbols.  */
     register section, then there are no register symbols.  */
  if ((info->section != NULL && info->section->owner != NULL)
  if ((info->section != NULL && info->section->owner != NULL)
      || (info->symbols != NULL
      || (info->symbols != NULL
          && info->symbols[0] != NULL
          && info->symbols[0] != NULL
          && bfd_asymbol_bfd (info->symbols[0]) != NULL))
          && bfd_asymbol_bfd (info->symbols[0]) != NULL))
    {
    {
      bfd *abfd = info->section && info->section->owner != NULL
      bfd *abfd = info->section && info->section->owner != NULL
        ? info->section->owner
        ? info->section->owner
        : bfd_asymbol_bfd (info->symbols[0]);
        : bfd_asymbol_bfd (info->symbols[0]);
      asection *reg_section = bfd_get_section_by_name (abfd, "*REG*");
      asection *reg_section = bfd_get_section_by_name (abfd, "*REG*");
 
 
      if (reg_section != NULL)
      if (reg_section != NULL)
        {
        {
          /* The returned symcount *does* include the ending NULL.  */
          /* The returned symcount *does* include the ending NULL.  */
          long symsize = bfd_get_symtab_upper_bound (abfd);
          long symsize = bfd_get_symtab_upper_bound (abfd);
          asymbol **syms = malloc (symsize);
          asymbol **syms = malloc (symsize);
          long nsyms;
          long nsyms;
          long i;
          long i;
 
 
          if (syms == NULL)
          if (syms == NULL)
            {
            {
              FATAL_DEBUG;
              FATAL_DEBUG;
              free (minfop);
              free (minfop);
              return FALSE;
              return FALSE;
            }
            }
          nsyms = bfd_canonicalize_symtab (abfd, syms);
          nsyms = bfd_canonicalize_symtab (abfd, syms);
 
 
          /* We use the first name for a register.  If this is MMO, then
          /* We use the first name for a register.  If this is MMO, then
             it's the name with the first sequence number, presumably the
             it's the name with the first sequence number, presumably the
             first in the source.  */
             first in the source.  */
          for (i = 0; i < nsyms && syms[i] != NULL; i++)
          for (i = 0; i < nsyms && syms[i] != NULL; i++)
            {
            {
              if (syms[i]->section == reg_section
              if (syms[i]->section == reg_section
                  && syms[i]->value < 256
                  && syms[i]->value < 256
                  && minfop->reg_name[syms[i]->value] == NULL)
                  && minfop->reg_name[syms[i]->value] == NULL)
                minfop->reg_name[syms[i]->value] = syms[i]->name;
                minfop->reg_name[syms[i]->value] = syms[i]->name;
            }
            }
        }
        }
    }
    }
 
 
  /* Fill in the rest with the canonical names.  */
  /* Fill in the rest with the canonical names.  */
  for (i = 0; i < 256; i++)
  for (i = 0; i < 256; i++)
    if (minfop->reg_name[i] == NULL)
    if (minfop->reg_name[i] == NULL)
      {
      {
        sprintf (minfop->basic_reg_name[i], "$%d", i);
        sprintf (minfop->basic_reg_name[i], "$%d", i);
        minfop->reg_name[i] = minfop->basic_reg_name[i];
        minfop->reg_name[i] = minfop->basic_reg_name[i];
      }
      }
 
 
  /* We assume it's actually a one-to-one mapping of number-to-name.  */
  /* We assume it's actually a one-to-one mapping of number-to-name.  */
  for (i = 0; mmix_spec_regs[i].name != NULL; i++)
  for (i = 0; mmix_spec_regs[i].name != NULL; i++)
    minfop->spec_reg_name[mmix_spec_regs[i].number] = mmix_spec_regs[i].name;
    minfop->spec_reg_name[mmix_spec_regs[i].number] = mmix_spec_regs[i].name;
 
 
  info->private_data = (void *) minfop;
  info->private_data = (void *) minfop;
  return TRUE;
  return TRUE;
}
}
 
 
/* A table indexed by the first byte is constructed as we disassemble each
/* A table indexed by the first byte is constructed as we disassemble each
   tetrabyte.  The contents is a pointer into mmix_insns reflecting the
   tetrabyte.  The contents is a pointer into mmix_insns reflecting the
   first found entry with matching match-bits and lose-bits.  Further
   first found entry with matching match-bits and lose-bits.  Further
   entries are considered one after one until the operand constraints
   entries are considered one after one until the operand constraints
   match or the match-bits and lose-bits do not match.  Normally a
   match or the match-bits and lose-bits do not match.  Normally a
   "further entry" will just show that there was no other match.  */
   "further entry" will just show that there was no other match.  */
 
 
static const struct mmix_opcode *
static const struct mmix_opcode *
get_opcode (unsigned long insn)
get_opcode (unsigned long insn)
{
{
  static const struct mmix_opcode **opcodes = NULL;
  static const struct mmix_opcode **opcodes = NULL;
  const struct mmix_opcode *opcodep = mmix_opcodes;
  const struct mmix_opcode *opcodep = mmix_opcodes;
  unsigned int opcode_part = (insn >> 24) & 255;
  unsigned int opcode_part = (insn >> 24) & 255;
 
 
  if (opcodes == NULL)
  if (opcodes == NULL)
    opcodes = xcalloc (256, sizeof (struct mmix_opcode *));
    opcodes = xcalloc (256, sizeof (struct mmix_opcode *));
 
 
  opcodep = opcodes[opcode_part];
  opcodep = opcodes[opcode_part];
  if (opcodep == NULL
  if (opcodep == NULL
      || (opcodep->match & insn) != opcodep->match
      || (opcodep->match & insn) != opcodep->match
      || (opcodep->lose & insn) != 0)
      || (opcodep->lose & insn) != 0)
    {
    {
      /* Search through the table.  */
      /* Search through the table.  */
      for (opcodep = mmix_opcodes; opcodep->name != NULL; opcodep++)
      for (opcodep = mmix_opcodes; opcodep->name != NULL; opcodep++)
        {
        {
          /* FIXME: Break out this into an initialization function.  */
          /* FIXME: Break out this into an initialization function.  */
          if ((opcodep->match & (opcode_part << 24)) == opcode_part
          if ((opcodep->match & (opcode_part << 24)) == opcode_part
              && (opcodep->lose & (opcode_part << 24)) == 0)
              && (opcodep->lose & (opcode_part << 24)) == 0)
            opcodes[opcode_part] = opcodep;
            opcodes[opcode_part] = opcodep;
 
 
          if ((opcodep->match & insn) == opcodep->match
          if ((opcodep->match & insn) == opcodep->match
              && (opcodep->lose & insn) == 0)
              && (opcodep->lose & insn) == 0)
            break;
            break;
        }
        }
    }
    }
 
 
  if (opcodep->name == NULL)
  if (opcodep->name == NULL)
    return NULL;
    return NULL;
 
 
  /* Check constraints.  If they don't match, loop through the next opcode
  /* Check constraints.  If they don't match, loop through the next opcode
     entries.  */
     entries.  */
  do
  do
    {
    {
      switch (opcodep->operands)
      switch (opcodep->operands)
        {
        {
          /* These have no restraint on what can be in the lower three
          /* These have no restraint on what can be in the lower three
             bytes.  */
             bytes.  */
        case mmix_operands_regs:
        case mmix_operands_regs:
        case mmix_operands_reg_yz:
        case mmix_operands_reg_yz:
        case mmix_operands_regs_z_opt:
        case mmix_operands_regs_z_opt:
        case mmix_operands_regs_z:
        case mmix_operands_regs_z:
        case mmix_operands_jmp:
        case mmix_operands_jmp:
        case mmix_operands_pushgo:
        case mmix_operands_pushgo:
        case mmix_operands_pop:
        case mmix_operands_pop:
        case mmix_operands_sync:
        case mmix_operands_sync:
        case mmix_operands_x_regs_z:
        case mmix_operands_x_regs_z:
        case mmix_operands_neg:
        case mmix_operands_neg:
        case mmix_operands_pushj:
        case mmix_operands_pushj:
        case mmix_operands_regaddr:
        case mmix_operands_regaddr:
        case mmix_operands_get:
        case mmix_operands_get:
        case mmix_operands_set:
        case mmix_operands_set:
        case mmix_operands_save:
        case mmix_operands_save:
        case mmix_operands_unsave:
        case mmix_operands_unsave:
        case mmix_operands_xyz_opt:
        case mmix_operands_xyz_opt:
          return opcodep;
          return opcodep;
 
 
          /* For a ROUND_MODE, the middle byte must be 0..4.  */
          /* For a ROUND_MODE, the middle byte must be 0..4.  */
        case mmix_operands_roundregs_z:
        case mmix_operands_roundregs_z:
        case mmix_operands_roundregs:
        case mmix_operands_roundregs:
          {
          {
            int midbyte = (insn >> 8) & 255;
            int midbyte = (insn >> 8) & 255;
 
 
            if (midbyte <= 4)
            if (midbyte <= 4)
              return opcodep;
              return opcodep;
          }
          }
        break;
        break;
 
 
        case mmix_operands_put:
        case mmix_operands_put:
          /* A "PUT".  If it is "immediate", then no restrictions,
          /* A "PUT".  If it is "immediate", then no restrictions,
             otherwise we have to make sure the register number is < 32.  */
             otherwise we have to make sure the register number is < 32.  */
          if ((insn & INSN_IMMEDIATE_BIT)
          if ((insn & INSN_IMMEDIATE_BIT)
              || ((insn >> 16) & 255) < 32)
              || ((insn >> 16) & 255) < 32)
            return opcodep;
            return opcodep;
          break;
          break;
 
 
        case mmix_operands_resume:
        case mmix_operands_resume:
          /* Middle bytes must be zero.  */
          /* Middle bytes must be zero.  */
          if ((insn & 0x00ffff00) == 0)
          if ((insn & 0x00ffff00) == 0)
            return opcodep;
            return opcodep;
          break;
          break;
 
 
        default:
        default:
          BAD_CASE (opcodep->operands);
          BAD_CASE (opcodep->operands);
        }
        }
 
 
      opcodep++;
      opcodep++;
    }
    }
  while ((opcodep->match & insn) == opcodep->match
  while ((opcodep->match & insn) == opcodep->match
         && (opcodep->lose & insn) == 0);
         && (opcodep->lose & insn) == 0);
 
 
  /* If we got here, we had no match.  */
  /* If we got here, we had no match.  */
  return NULL;
  return NULL;
}
}
 
 
/* The main disassembly function.  */
/* The main disassembly function.  */
 
 
int
int
print_insn_mmix (bfd_vma memaddr, struct disassemble_info *info)
print_insn_mmix (bfd_vma memaddr, struct disassemble_info *info)
{
{
  unsigned char buffer[4];
  unsigned char buffer[4];
  unsigned long insn;
  unsigned long insn;
  unsigned int x, y, z;
  unsigned int x, y, z;
  const struct mmix_opcode *opcodep;
  const struct mmix_opcode *opcodep;
  int status = (*info->read_memory_func) (memaddr, buffer, 4, info);
  int status = (*info->read_memory_func) (memaddr, buffer, 4, info);
  struct mmix_dis_info *minfop;
  struct mmix_dis_info *minfop;
 
 
  if (status != 0)
  if (status != 0)
    {
    {
      (*info->memory_error_func) (status, memaddr, info);
      (*info->memory_error_func) (status, memaddr, info);
      return -1;
      return -1;
    }
    }
 
 
  /* FIXME: Is -1 suitable?  */
  /* FIXME: Is -1 suitable?  */
  if (info->private_data == NULL
  if (info->private_data == NULL
      && ! initialize_mmix_dis_info (info))
      && ! initialize_mmix_dis_info (info))
    return -1;
    return -1;
 
 
  minfop = (struct mmix_dis_info *) info->private_data;
  minfop = (struct mmix_dis_info *) info->private_data;
  x = buffer[1];
  x = buffer[1];
  y = buffer[2];
  y = buffer[2];
  z = buffer[3];
  z = buffer[3];
 
 
  insn = bfd_getb32 (buffer);
  insn = bfd_getb32 (buffer);
 
 
  opcodep = get_opcode (insn);
  opcodep = get_opcode (insn);
 
 
  if (opcodep == NULL)
  if (opcodep == NULL)
    {
    {
      (*info->fprintf_func) (info->stream, _("*unknown*"));
      (*info->fprintf_func) (info->stream, _("*unknown*"));
      return 4;
      return 4;
    }
    }
 
 
  (*info->fprintf_func) (info->stream, "%s ", opcodep->name);
  (*info->fprintf_func) (info->stream, "%s ", opcodep->name);
 
 
  /* Present bytes in the order they are laid out in memory.  */
  /* Present bytes in the order they are laid out in memory.  */
  info->display_endian = BFD_ENDIAN_BIG;
  info->display_endian = BFD_ENDIAN_BIG;
 
 
  info->insn_info_valid = 1;
  info->insn_info_valid = 1;
  info->bytes_per_chunk = 4;
  info->bytes_per_chunk = 4;
  info->branch_delay_insns = 0;
  info->branch_delay_insns = 0;
  info->target = 0;
  info->target = 0;
  switch (opcodep->type)
  switch (opcodep->type)
    {
    {
    case mmix_type_normal:
    case mmix_type_normal:
    case mmix_type_memaccess_block:
    case mmix_type_memaccess_block:
      info->insn_type = dis_nonbranch;
      info->insn_type = dis_nonbranch;
      break;
      break;
 
 
    case mmix_type_branch:
    case mmix_type_branch:
      info->insn_type = dis_branch;
      info->insn_type = dis_branch;
      break;
      break;
 
 
    case mmix_type_condbranch:
    case mmix_type_condbranch:
      info->insn_type = dis_condbranch;
      info->insn_type = dis_condbranch;
      break;
      break;
 
 
    case mmix_type_memaccess_octa:
    case mmix_type_memaccess_octa:
      info->insn_type = dis_dref;
      info->insn_type = dis_dref;
      info->data_size = 8;
      info->data_size = 8;
      break;
      break;
 
 
    case mmix_type_memaccess_tetra:
    case mmix_type_memaccess_tetra:
      info->insn_type = dis_dref;
      info->insn_type = dis_dref;
      info->data_size = 4;
      info->data_size = 4;
      break;
      break;
 
 
    case mmix_type_memaccess_wyde:
    case mmix_type_memaccess_wyde:
      info->insn_type = dis_dref;
      info->insn_type = dis_dref;
      info->data_size = 2;
      info->data_size = 2;
      break;
      break;
 
 
    case mmix_type_memaccess_byte:
    case mmix_type_memaccess_byte:
      info->insn_type = dis_dref;
      info->insn_type = dis_dref;
      info->data_size = 1;
      info->data_size = 1;
      break;
      break;
 
 
    case mmix_type_jsr:
    case mmix_type_jsr:
      info->insn_type = dis_jsr;
      info->insn_type = dis_jsr;
      break;
      break;
 
 
    default:
    default:
      BAD_CASE(opcodep->type);
      BAD_CASE(opcodep->type);
    }
    }
 
 
  switch (opcodep->operands)
  switch (opcodep->operands)
    {
    {
    case mmix_operands_regs:
    case mmix_operands_regs:
      /*  All registers: "$X,$Y,$Z".  */
      /*  All registers: "$X,$Y,$Z".  */
      (*info->fprintf_func) (info->stream, "%s,%s,%s",
      (*info->fprintf_func) (info->stream, "%s,%s,%s",
                             minfop->reg_name[x],
                             minfop->reg_name[x],
                             minfop->reg_name[y],
                             minfop->reg_name[y],
                             minfop->reg_name[z]);
                             minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_reg_yz:
    case mmix_operands_reg_yz:
      /* Like SETH - "$X,YZ".  */
      /* Like SETH - "$X,YZ".  */
      (*info->fprintf_func) (info->stream, "%s,0x%x",
      (*info->fprintf_func) (info->stream, "%s,0x%x",
                             minfop->reg_name[x], y * 256 + z);
                             minfop->reg_name[x], y * 256 + z);
      break;
      break;
 
 
    case mmix_operands_regs_z_opt:
    case mmix_operands_regs_z_opt:
    case mmix_operands_regs_z:
    case mmix_operands_regs_z:
    case mmix_operands_pushgo:
    case mmix_operands_pushgo:
      /* The regular "$X,$Y,$Z|Z".  */
      /* The regular "$X,$Y,$Z|Z".  */
      if (insn & INSN_IMMEDIATE_BIT)
      if (insn & INSN_IMMEDIATE_BIT)
        (*info->fprintf_func) (info->stream, "%s,%s,%d",
        (*info->fprintf_func) (info->stream, "%s,%s,%d",
                               minfop->reg_name[x], minfop->reg_name[y], z);
                               minfop->reg_name[x], minfop->reg_name[y], z);
      else
      else
        (*info->fprintf_func) (info->stream, "%s,%s,%s",
        (*info->fprintf_func) (info->stream, "%s,%s,%s",
                               minfop->reg_name[x],
                               minfop->reg_name[x],
                               minfop->reg_name[y],
                               minfop->reg_name[y],
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_jmp:
    case mmix_operands_jmp:
      /* Address; only JMP.  */
      /* Address; only JMP.  */
      {
      {
        bfd_signed_vma offset = (x * 65536 + y * 256 + z) * 4;
        bfd_signed_vma offset = (x * 65536 + y * 256 + z) * 4;
 
 
        if (insn & INSN_BACKWARD_OFFSET_BIT)
        if (insn & INSN_BACKWARD_OFFSET_BIT)
          offset -= (256 * 65536) * 4;
          offset -= (256 * 65536) * 4;
 
 
        info->target = memaddr + offset;
        info->target = memaddr + offset;
        (*info->print_address_func) (memaddr + offset, info);
        (*info->print_address_func) (memaddr + offset, info);
      }
      }
      break;
      break;
 
 
    case mmix_operands_roundregs_z:
    case mmix_operands_roundregs_z:
      /* Two registers, like FLOT, possibly with rounding: "$X,$Z|Z"
      /* Two registers, like FLOT, possibly with rounding: "$X,$Z|Z"
         "$X,ROUND_MODE,$Z|Z".  */
         "$X,ROUND_MODE,$Z|Z".  */
      if (y != 0)
      if (y != 0)
        {
        {
          if (insn & INSN_IMMEDIATE_BIT)
          if (insn & INSN_IMMEDIATE_BIT)
            (*info->fprintf_func) (info->stream, "%s,%s,%d",
            (*info->fprintf_func) (info->stream, "%s,%s,%d",
                                   minfop->reg_name[x],
                                   minfop->reg_name[x],
                                   ROUND_MODE (y), z);
                                   ROUND_MODE (y), z);
          else
          else
            (*info->fprintf_func) (info->stream, "%s,%s,%s",
            (*info->fprintf_func) (info->stream, "%s,%s,%s",
                                   minfop->reg_name[x],
                                   minfop->reg_name[x],
                                   ROUND_MODE (y),
                                   ROUND_MODE (y),
                                   minfop->reg_name[z]);
                                   minfop->reg_name[z]);
        }
        }
      else
      else
        {
        {
          if (insn & INSN_IMMEDIATE_BIT)
          if (insn & INSN_IMMEDIATE_BIT)
            (*info->fprintf_func) (info->stream, "%s,%d",
            (*info->fprintf_func) (info->stream, "%s,%d",
                                   minfop->reg_name[x], z);
                                   minfop->reg_name[x], z);
          else
          else
            (*info->fprintf_func) (info->stream, "%s,%s",
            (*info->fprintf_func) (info->stream, "%s,%s",
                                   minfop->reg_name[x],
                                   minfop->reg_name[x],
                                   minfop->reg_name[z]);
                                   minfop->reg_name[z]);
        }
        }
      break;
      break;
 
 
    case mmix_operands_pop:
    case mmix_operands_pop:
      /* Like POP - "X,YZ".  */
      /* Like POP - "X,YZ".  */
      (*info->fprintf_func) (info->stream, "%d,%d", x, y*256 + z);
      (*info->fprintf_func) (info->stream, "%d,%d", x, y*256 + z);
      break;
      break;
 
 
    case mmix_operands_roundregs:
    case mmix_operands_roundregs:
      /* Two registers, possibly with rounding: "$X,$Z" or
      /* Two registers, possibly with rounding: "$X,$Z" or
         "$X,ROUND_MODE,$Z".  */
         "$X,ROUND_MODE,$Z".  */
      if (y != 0)
      if (y != 0)
        (*info->fprintf_func) (info->stream, "%s,%s,%s",
        (*info->fprintf_func) (info->stream, "%s,%s,%s",
                               minfop->reg_name[x],
                               minfop->reg_name[x],
                               ROUND_MODE (y),
                               ROUND_MODE (y),
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      else
      else
        (*info->fprintf_func) (info->stream, "%s,%s",
        (*info->fprintf_func) (info->stream, "%s,%s",
                               minfop->reg_name[x],
                               minfop->reg_name[x],
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_sync:
    case mmix_operands_sync:
        /* Like SYNC - "XYZ".  */
        /* Like SYNC - "XYZ".  */
      (*info->fprintf_func) (info->stream, "%u",
      (*info->fprintf_func) (info->stream, "%u",
                             x * 65536 + y * 256 + z);
                             x * 65536 + y * 256 + z);
      break;
      break;
 
 
    case mmix_operands_x_regs_z:
    case mmix_operands_x_regs_z:
      /* Like SYNCD - "X,$Y,$Z|Z".  */
      /* Like SYNCD - "X,$Y,$Z|Z".  */
      if (insn & INSN_IMMEDIATE_BIT)
      if (insn & INSN_IMMEDIATE_BIT)
        (*info->fprintf_func) (info->stream, "%d,%s,%d",
        (*info->fprintf_func) (info->stream, "%d,%s,%d",
                               x, minfop->reg_name[y], z);
                               x, minfop->reg_name[y], z);
      else
      else
        (*info->fprintf_func) (info->stream, "%d,%s,%s",
        (*info->fprintf_func) (info->stream, "%d,%s,%s",
                               x, minfop->reg_name[y],
                               x, minfop->reg_name[y],
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_neg:
    case mmix_operands_neg:
      /* Like NEG and NEGU - "$X,Y,$Z|Z".  */
      /* Like NEG and NEGU - "$X,Y,$Z|Z".  */
      if (insn & INSN_IMMEDIATE_BIT)
      if (insn & INSN_IMMEDIATE_BIT)
        (*info->fprintf_func) (info->stream, "%s,%d,%d",
        (*info->fprintf_func) (info->stream, "%s,%d,%d",
                               minfop->reg_name[x], y, z);
                               minfop->reg_name[x], y, z);
      else
      else
        (*info->fprintf_func) (info->stream, "%s,%d,%s",
        (*info->fprintf_func) (info->stream, "%s,%d,%s",
                               minfop->reg_name[x], y,
                               minfop->reg_name[x], y,
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_pushj:
    case mmix_operands_pushj:
    case mmix_operands_regaddr:
    case mmix_operands_regaddr:
      /* Like GETA or branches - "$X,Address".  */
      /* Like GETA or branches - "$X,Address".  */
      {
      {
        bfd_signed_vma offset = (y * 256 + z) * 4;
        bfd_signed_vma offset = (y * 256 + z) * 4;
 
 
        if (insn & INSN_BACKWARD_OFFSET_BIT)
        if (insn & INSN_BACKWARD_OFFSET_BIT)
          offset -= 65536 * 4;
          offset -= 65536 * 4;
 
 
        info->target = memaddr + offset;
        info->target = memaddr + offset;
 
 
        (*info->fprintf_func) (info->stream, "%s,", minfop->reg_name[x]);
        (*info->fprintf_func) (info->stream, "%s,", minfop->reg_name[x]);
        (*info->print_address_func) (memaddr + offset, info);
        (*info->print_address_func) (memaddr + offset, info);
      }
      }
      break;
      break;
 
 
    case mmix_operands_get:
    case mmix_operands_get:
      /* GET - "X,spec_reg".  */
      /* GET - "X,spec_reg".  */
      (*info->fprintf_func) (info->stream, "%s,%s",
      (*info->fprintf_func) (info->stream, "%s,%s",
                             minfop->reg_name[x],
                             minfop->reg_name[x],
                             minfop->spec_reg_name[z]);
                             minfop->spec_reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_put:
    case mmix_operands_put:
      /* PUT - "spec_reg,$Z|Z".  */
      /* PUT - "spec_reg,$Z|Z".  */
      if (insn & INSN_IMMEDIATE_BIT)
      if (insn & INSN_IMMEDIATE_BIT)
        (*info->fprintf_func) (info->stream, "%s,%d",
        (*info->fprintf_func) (info->stream, "%s,%d",
                               minfop->spec_reg_name[x], z);
                               minfop->spec_reg_name[x], z);
      else
      else
        (*info->fprintf_func) (info->stream, "%s,%s",
        (*info->fprintf_func) (info->stream, "%s,%s",
                               minfop->spec_reg_name[x],
                               minfop->spec_reg_name[x],
                               minfop->reg_name[z]);
                               minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_set:
    case mmix_operands_set:
      /*  Two registers, "$X,$Y".  */
      /*  Two registers, "$X,$Y".  */
      (*info->fprintf_func) (info->stream, "%s,%s",
      (*info->fprintf_func) (info->stream, "%s,%s",
                             minfop->reg_name[x],
                             minfop->reg_name[x],
                             minfop->reg_name[y]);
                             minfop->reg_name[y]);
      break;
      break;
 
 
    case mmix_operands_save:
    case mmix_operands_save:
      /* SAVE - "$X,0".  */
      /* SAVE - "$X,0".  */
      (*info->fprintf_func) (info->stream, "%s,0", minfop->reg_name[x]);
      (*info->fprintf_func) (info->stream, "%s,0", minfop->reg_name[x]);
      break;
      break;
 
 
    case mmix_operands_unsave:
    case mmix_operands_unsave:
      /* UNSAVE - "0,$Z".  */
      /* UNSAVE - "0,$Z".  */
      (*info->fprintf_func) (info->stream, "0,%s", minfop->reg_name[z]);
      (*info->fprintf_func) (info->stream, "0,%s", minfop->reg_name[z]);
      break;
      break;
 
 
    case mmix_operands_xyz_opt:
    case mmix_operands_xyz_opt:
      /* Like SWYM or TRAP - "X,Y,Z".  */
      /* Like SWYM or TRAP - "X,Y,Z".  */
      (*info->fprintf_func) (info->stream, "%d,%d,%d", x, y, z);
      (*info->fprintf_func) (info->stream, "%d,%d,%d", x, y, z);
      break;
      break;
 
 
    case mmix_operands_resume:
    case mmix_operands_resume:
      /* Just "Z", like RESUME.  */
      /* Just "Z", like RESUME.  */
      (*info->fprintf_func) (info->stream, "%d", z);
      (*info->fprintf_func) (info->stream, "%d", z);
      break;
      break;
 
 
    default:
    default:
      (*info->fprintf_func) (info->stream, _("*unknown operands type: %d*"),
      (*info->fprintf_func) (info->stream, _("*unknown operands type: %d*"),
                             opcodep->operands);
                             opcodep->operands);
      break;
      break;
    }
    }
 
 
  return 4;
  return 4;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.