Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/opcodes/sh-dis.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Disassemble SH instructions.
    2    Copyright 1993, 1994, 1995, 1997, 1998, 2000
     2   Copyright 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44
    5 This program is free software; you can redistribute it and/or modify
    6 it under the terms of the GNU General Public License as published by
    7 the Free Software Foundation; either version 2 of the License, or
    8 (at your option) any later version.
    9 
    10 This program is distributed in the hope that it will be useful,
    11 but WITHOUT ANY WARRANTY; without even the implied warranty of
    12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13 GNU General Public License for more details.
    14 
    15 You should have received a copy of the GNU General Public License
    16 along with this program; if not, write to the Free Software
    17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     5   This program is free software; you can redistribute it and/or modify
     6   it under the terms of the GNU General Public License as published by
     7   the Free Software Foundation; either version 2 of the License, or
     8   (at your option) any later version.
     9
     10   This program is distributed in the hope that it will be useful,
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13   GNU General Public License for more details.
     14
     15   You should have received a copy of the GNU General Public License
     16   along with this program; if not, write to the Free Software
     17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    1818
    1919#include <stdio.h>
     
    2525#include "dis-asm.h"
    2626
    27 #define LITTLE_BIT 2
     27#ifdef ARCH_all
     28#define INCLUDE_SHMEDIA
     29#endif
     30
     31static void print_movxy
     32  PARAMS ((const sh_opcode_info *, int, int, fprintf_ftype, void *));
     33static void print_insn_ddt PARAMS ((int, struct disassemble_info *));
     34static void print_dsp_reg PARAMS ((int, fprintf_ftype, void *));
     35static void print_insn_ppi PARAMS ((int, struct disassemble_info *));
    2836
    2937static void
    3038print_movxy (op, rn, rm, fprintf_fn, stream)
    31      sh_opcode_info *op;
     39     const sh_opcode_info *op;
    3240     int rn, rm;
    3341     fprintf_ftype fprintf_fn;
     
    98106  else
    99107    {
    100       static sh_opcode_info *first_movx, *first_movy;
    101       sh_opcode_info *opx, *opy;
     108      static const sh_opcode_info *first_movx, *first_movy;
     109      const sh_opcode_info *opx, *opy;
    102110      unsigned int insn_x, insn_y;
    103111
     
    185193  unsigned int nib1, nib2, nib3;
    186194  char *dc = NULL;
    187   sh_opcode_info *op;
     195  const sh_opcode_info *op;
    188196
    189197  if ((field_b & 0xe800) == 0)
     
    280288}
    281289
    282 static int
    283 print_insn_shx (memaddr, info)
     290int
     291print_insn_sh (memaddr, info)
    284292     bfd_vma memaddr;
    285293     struct disassemble_info *info;
     
    291299  int status;
    292300  bfd_vma relmask = ~(bfd_vma) 0;
    293   sh_opcode_info *op;
     301  const sh_opcode_info *op;
    294302  int target_arch;
    295303
     
    298306    case bfd_mach_sh:
    299307      target_arch = arch_sh1;
     308      /* SH coff object files lack information about the machine type, so
     309         we end up with bfd_mach_sh unless it was set explicitly (which
     310         could have happended if this is a call from gdb or the simulator.)  */
     311      if (info->symbols
     312          && bfd_asymbol_flavour(*info->symbols) == bfd_target_coff_flavour)
     313        target_arch = arch_sh4;
    300314      break;
    301315    case bfd_mach_sh2:
    302316      target_arch = arch_sh2;
    303317      break;
     318    case bfd_mach_sh2e:
     319      target_arch = arch_sh2e;
     320      break;
    304321    case bfd_mach_sh_dsp:
    305322      target_arch = arch_sh_dsp;
     
    317334      target_arch = arch_sh4;
    318335      break;
     336    case bfd_mach_sh5:
     337#ifdef INCLUDE_SHMEDIA
     338      status = print_insn_sh64 (memaddr, info);
     339      if (status != -2)
     340        return status;
     341#endif
     342      /* When we get here for sh64, it's because we want to disassemble
     343         SHcompact, i.e. arch_sh4.  */
     344      target_arch = arch_sh4;
     345      break;
    319346    default:
    320347      abort ();
     
    329356    }
    330357
    331   if (info->flags & LITTLE_BIT)
     358  if (info->endian == BFD_ENDIAN_LITTLE)
    332359    {
    333360      nibs[0] = (insn[1] >> 4) & 0xf;
     
    360387            }
    361388
    362           if (info->flags & LITTLE_BIT)
     389          if (info->endian == BFD_ENDIAN_LITTLE)
    363390            field_b = insn[1] << 8 | insn[0];
    364391          else
     
    459486                goto fail;
    460487              rn = rn & 0x3;
    461               rn |= (rn & 2) << 1;
     488              rn |= (!(rn & 2)) << 2;
    462489              break;
    463490            case PPI:
     
    666693          info->flags |= 1;
    667694          fprintf_fn (stream, "\t(slot ");
    668           print_insn_shx (memaddr + 2, info);
     695          print_insn_sh (memaddr + 2, info);
    669696          info->flags &= ~1;
    670697          fprintf_fn (stream, ")");
     
    689716              if (size == 2)
    690717                {
    691                   if ((info->flags & LITTLE_BIT) != 0)
     718                  if (info->endian == BFD_ENDIAN_LITTLE)
    692719                    val = bfd_getl16 (bytes);
    693720                  else
     
    696723              else
    697724                {
    698                   if ((info->flags & LITTLE_BIT) != 0)
     725                  if (info->endian == BFD_ENDIAN_LITTLE)
    699726                    val = bfd_getl32 (bytes);
    700727                  else
     
    713740  return 2;
    714741}
    715 
    716 int
    717 print_insn_shl (memaddr, info)
    718      bfd_vma memaddr;
    719      struct disassemble_info *info;
    720 {
    721   int r;
    722 
    723   info->flags = LITTLE_BIT;
    724   r = print_insn_shx (memaddr, info);
    725   return r;
    726 }
    727 
    728 int
    729 print_insn_sh (memaddr, info)
    730      bfd_vma memaddr;
    731      struct disassemble_info *info;
    732 {
    733   int r;
    734 
    735   info->flags = 0;
    736   r = print_insn_shx (memaddr, info);
    737   return r;
    738 }
Note: See TracChangeset for help on using the changeset viewer.