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/sparc-dis.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Print SPARC instructions.
    22   Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000 Free Software Foundation, Inc.
    4 
    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.  */
     3   2000, 2002, 2003 Free Software Foundation, Inc.
     4
     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>
     
    4747#define HASH_INSN(INSN) \
    4848  ((((INSN) >> 24) & 0xc0) | (((INSN) & opcode_bits[((INSN) >> 30) & 3]) >> 19))
    49 struct opcode_hash {
     49struct opcode_hash
     50{
    5051  struct opcode_hash *next;
    5152  const struct sparc_opcode *opcode;
     
    189190  for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next)
    190191    {
    191       CONST struct sparc_opcode *opcode = op->opcode;
     192      const struct sparc_opcode *opcode = op->opcode;
    192193      if ((opcode->match & insn) == opcode->match
    193194          && (opcode->lose & insn) == 0)
     
    258259
    259260  /* On SPARClite variants such as DANlite (sparc86x), instructions
    260      are always big-endian even when the machine is in little-endian mode. */
     261     are always big-endian even when the machine is in little-endian mode.  */
    261262  if (info->endian == BFD_ENDIAN_BIG || info->mach == bfd_mach_sparc_sparclite)
    262263    getword = bfd_getb32;
     
    266267  insn = getword (buffer);
    267268
    268   info->insn_info_valid = 1;                    /* We do return this info */
    269   info->insn_type = dis_nonbranch;              /* Assume non branch insn */
    270   info->branch_delay_insns = 0;                 /* Assume no delay */
    271   info->target = 0;                             /* Assume no target known */
     269  info->insn_info_valid = 1;                    /* We do return this info. */
     270  info->insn_type = dis_nonbranch;              /* Assume non branch insn. */
     271  info->branch_delay_insns = 0;                 /* Assume no delay. */
     272  info->target = 0;                             /* Assume no target known. */
    272273
    273274  for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next)
    274275    {
    275       CONST struct sparc_opcode *opcode = op->opcode;
     276      const struct sparc_opcode *opcode = op->opcode;
    276277
    277278      /* If the insn isn't supported by the current architecture, skip it.  */
     
    313314
    314315          {
    315             register CONST char *s;
     316            register const char *s;
    316317
    317318            if (opcode->args[0] != ',')
    318319              (*info->fprintf_func) (stream, " ");
     320
    319321            for (s = opcode->args; *s != '\0'; ++s)
    320322              {
     
    323325                    (*info->fprintf_func) (stream, ",");
    324326                    ++s;
    325                     switch (*s) {
    326                     case 'a':
    327                       (*info->fprintf_func) (stream, "a");
    328                       is_annulled = 1;
    329                       ++s;
    330                       continue;
    331                     case 'N':
    332                       (*info->fprintf_func) (stream, "pn");
    333                       ++s;
    334                       continue;
    335 
    336                     case 'T':
    337                       (*info->fprintf_func) (stream, "pt");
    338                       ++s;
    339                       continue;
    340 
    341                     default:
    342                       break;
    343                     }           /* switch on arg */
    344                   }             /* while there are comma started args */
     327                    switch (*s)
     328                      {
     329                      case 'a':
     330                        (*info->fprintf_func) (stream, "a");
     331                        is_annulled = 1;
     332                        ++s;
     333                        continue;
     334                      case 'N':
     335                        (*info->fprintf_func) (stream, "pn");
     336                        ++s;
     337                        continue;
     338
     339                      case 'T':
     340                        (*info->fprintf_func) (stream, "pt");
     341                        ++s;
     342                        continue;
     343
     344                      default:
     345                        break;
     346                      }
     347                  }
    345348
    346349                (*info->fprintf_func) (stream, " ");
     
    420423                  case 'h':
    421424                    (*info->fprintf_func) (stream, "%%hi(%#x)",
    422                                            (0xFFFFFFFF
     425                                           ((unsigned) 0xFFFFFFFF
    423426                                            & ((int) X_IMM22 (insn) << 10)));
    424427                    break;
     
    683686              int errcode;
    684687
    685               errcode =
    686                 (*info->read_memory_func)
     688              if (memaddr >= 4)
     689                errcode =
     690                  (*info->read_memory_func)
    687691                  (memaddr - 4, buffer, sizeof (buffer), info);
     692              else
     693                errcode = 1;
     694
    688695              prev_insn = getword (buffer);
    689696
     
    692699                  /* If it is a delayed branch, we need to look at the
    693700                     instruction before the delayed branch.  This handles
    694                      sequences such as
     701                     sequences such as:
    695702
    696703                     sethi %o1, %hi(_foo), %o1
    697704                     call _printf
    698                      or %o1, %lo(_foo), %o1
    699                      */
     705                     or %o1, %lo(_foo), %o1  */
    700706
    701707                  if (is_delayed_branch (prev_insn))
    702708                    {
    703                       errcode = (*info->read_memory_func)
    704                         (memaddr - 8, buffer, sizeof (buffer), info);
     709                      if (memaddr >= 8)
     710                        errcode = (*info->read_memory_func)
     711                          (memaddr - 8, buffer, sizeof (buffer), info);
     712                      else
     713                        errcode = 1;
     714
    705715                      prev_insn = getword (buffer);
    706716                    }
     
    717727                      (*info->fprintf_func) (stream, "\t! ");
    718728                      info->target =
    719                         (0xFFFFFFFF & (int) X_IMM22 (prev_insn) << 10);
     729                        ((unsigned) 0xFFFFFFFF
     730                         & ((int) X_IMM22 (prev_insn) << 10));
    720731                      if (imm_added_to_rs1)
    721732                        info->target += X_SIMM (insn, 13);
     
    746757    }
    747758
    748   info->insn_type = dis_noninsn;        /* Mark as non-valid instruction */
     759  info->insn_type = dis_noninsn;        /* Mark as non-valid instruction. */
    749760  (*info->fprintf_func) (stream, _("unknown"));
    750761  return sizeof (buffer);
Note: See TracChangeset for help on using the changeset viewer.