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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Instruction printing code for the ARM
    2    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
     2   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44   Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
    55   Modification by James G. Smith (jsmith@cygnus.co.uk)
    66
    7 This file is part of libopcodes.
    8 
    9 This program is free software; you can redistribute it and/or modify it under
    10 the terms of the GNU General Public License as published by the Free
    11 Software Foundation; either version 2 of the License, or (at your option)
    12 any later version.
    13 
    14 This program is distributed in the hope that it will be useful, but WITHOUT
    15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    17 more details.
    18 
    19 You should have received a copy of the GNU General Public License
    20 along with this program; if not, write to the Free Software
    21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     7   This file is part of libopcodes.
     8
     9   This program is free software; you can redistribute it and/or modify it under
     10   the terms of the GNU General Public License as published by the Free
     11   Software Foundation; either version 2 of the License, or (at your option)
     12   any later version.
     13
     14   This program is distributed in the hope that it will be useful, but WITHOUT
     15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     16   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     17   more details.
     18
     19   You should have received a copy of the GNU General Public License
     20   along with this program; if not, write to the Free Software
     21   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2222
    2323#include "sysdep.h"
     
    2929#include "opintl.h"
    3030
    31 /* FIXME: This shouldn't be done here */
     31/* FIXME: This shouldn't be done here. */
    3232#include "elf-bfd.h"
    3333#include "elf/internal.h"
     
    7171    { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "v4", "v5", "v6", "v7",  "v8",  "IP",  "SP",  "LR",  "PC" }},
    7272  { "special-atpcs", "Select special register names used in the ATPCS",
    73     { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "WR", "v5", "SB", "SL",  "FP",  "IP",  "SP",  "LR",  "PC" }}
     73    { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "WR", "v5", "SB", "SL",  "FP",  "IP",  "SP",  "LR",  "PC" }},
     74  { "iwmmxt_regnames", "Select register names used on the Intel Wireless MMX technology coprocessor",
     75    { "wr0", "wr1", "wr2", "wr3", "wr4", "wr5", "wr6", "wr7", "wr8", "wr9", "wr10", "wr11", "wr12", "wr13", "wr14", "wr15"}},
     76  { "iwmmxt_Cregnames", "Select control register names used on the Intel Wireless MMX technology coprocessor",
     77    {"wcid", "wcon", "wcssf", "wcasf", "reserved", "reserved", "reserved", "reserved", "wcgr0", "wcgr1", "wcgr2", "wcgr3", "reserved", "reserved", "reserved", "reserved"}}
     78};
     79
     80static char * iwmmxt_wwnames[] =
     81{"b", "h", "w", "d"};
     82
     83static char * iwmmxt_wwssnames[] =
     84{"b", "bus", "b", "bss",
     85 "h", "hus", "h", "hss",
     86 "w", "wus", "w", "wss",
     87 "d", "dus", "d", "dss"
    7488};
    7589
     
    8094#define arm_regnames      regnames[regname_selected].reg_names
    8195
    82 static boolean force_thumb = false;
     96static bfd_boolean force_thumb = FALSE;
    8397
    8498static char * arm_fp_const[] =
    8599{"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0"};
    86100
    87 static char * arm_shift[] = 
     101static char * arm_shift[] =
    88102{"lsl", "lsr", "asr", "ror"};
    89103
    90104
    91105/* Forward declarations.  */
    92 static void arm_decode_shift PARAMS ((long, fprintf_ftype, void *));
    93 static int  print_insn_arm   PARAMS ((bfd_vma, struct disassemble_info *, long));
    94 static int  print_insn_thumb PARAMS ((bfd_vma, struct disassemble_info *, long));
    95 static void parse_disassembler_options PARAMS ((char *));
    96 static int  print_insn       PARAMS ((bfd_vma, struct disassemble_info *, boolean));
    97 int get_arm_regname_num_options (void);
    98 int set_arm_regname_option (int option);
    99 int get_arm_regnames (int option, const char **setname,
    100                       const char **setdescription,
    101                       const char ***register_names);
    102 
    103 
    104 /* Functions. */
     106static void arm_decode_shift
     107  PARAMS ((long, fprintf_ftype, void *));
     108static int  print_insn_arm
     109  PARAMS ((bfd_vma, struct disassemble_info *, long));
     110static int  print_insn_thumb
     111  PARAMS ((bfd_vma, struct disassemble_info *, long));
     112static void parse_disassembler_options
     113  PARAMS ((char *));
     114static int  print_insn
     115  PARAMS ((bfd_vma, struct disassemble_info *, bfd_boolean));
     116static int set_iwmmxt_regnames
     117  PARAMS ((void));
     118
     119int get_arm_regname_num_options
     120  PARAMS ((void));
     121int set_arm_regname_option
     122  PARAMS ((int));
     123int get_arm_regnames
     124  PARAMS ((int, const char **, const char **, const char ***));
     125
     126
     127/* Functions.  */
    105128int
    106 get_arm_regname_num_options (void)
     129get_arm_regname_num_options ()
    107130{
    108131  return NUM_ARM_REGNAMES;
     
    110133
    111134int
    112 set_arm_regname_option (int option)
     135set_arm_regname_option (option)
     136     int option;
    113137{
    114138  int old = regname_selected;
     
    118142
    119143int
    120 get_arm_regnames (int option, const char **setname,
    121                   const char **setdescription,
    122                   const char ***register_names)
     144get_arm_regnames (option, setname, setdescription, register_names)
     145     int option;
     146     const char **setname;
     147     const char **setdescription;
     148     const char ***register_names;
    123149{
    124150  *setname = regnames[option].name;
     
    135161{
    136162  func (stream, "%s", arm_regnames[given & 0xf]);
    137  
     163
    138164  if ((given & 0xff0) != 0)
    139165    {
     
    142168          int amount = (given & 0xf80) >> 7;
    143169          int shift = (given & 0x60) >> 5;
    144          
     170
    145171          if (amount == 0)
    146172            {
     
    150176                  return;
    151177                }
    152              
     178
    153179              amount = 32;
    154180            }
    155          
     181
    156182          func (stream, ", %s #%d", arm_shift[shift], amount);
    157183        }
     
    162188}
    163189
     190static int
     191set_iwmmxt_regnames ()
     192{
     193  const char * setname;
     194  const char * setdesc;
     195  const char ** regnames;
     196  int iwmmxt_regnames = 0;
     197  int num_regnames = get_arm_regname_num_options ();
     198
     199  get_arm_regnames (iwmmxt_regnames, &setname,
     200                    &setdesc, &regnames);
     201  while ((strcmp ("iwmmxt_regnames", setname))
     202         && (iwmmxt_regnames < num_regnames))
     203    get_arm_regnames (++iwmmxt_regnames, &setname, &setdesc, &regnames);
     204
     205  return iwmmxt_regnames;
     206}
     207                         
    164208/* Print one instruction from PC on INFO->STREAM.
    165209   Return the size of the instruction (always 4 on ARM). */
     210
    166211static int
    167212print_insn_arm (pc, info, given)
    168      bfd_vma                   pc;
    169      struct disassemble_info * info;
    170      long                      given;
    171 {
    172   struct arm_opcode *  insn;
    173   void *               stream = info->stream;
    174   fprintf_ftype        func   = info->fprintf_func;
     213     bfd_vma pc;
     214     struct disassemble_info *info;
     215     long given;
     216{
     217  const struct arm_opcode *insn;
     218  void *stream = info->stream;
     219  fprintf_ftype func   = info->fprintf_func;
     220  static int iwmmxt_regnames = 0;
    175221
    176222  for (insn = arm_opcodes; insn->assembler; insn++)
    177223    {
     224      if (insn->value == FIRST_IWMMXT_INSN
     225          && info->mach != bfd_mach_arm_XScale
     226          && info->mach != bfd_mach_arm_iWMMXt)
     227        insn = insn + IWMMXT_INSN_COUNT;
     228
    178229      if ((given & insn->mask) == insn->value)
    179230        {
    180231          char * c;
    181          
     232
    182233          for (c = insn->assembler; *c; c++)
    183234            {
     
    195246                        {
    196247                          int offset = given & 0xfff;
    197                          
     248
    198249                          func (stream, "[pc");
    199  
     250
    200251                          if (given & 0x01000000)
    201252                            {
    202253                              if ((given & 0x00800000) == 0)
    203254                                offset = - offset;
    204                          
    205                               /* pre-indexed */
    206                               func (stream, ", #%x]", offset);
     255
     256                              /* Pre-indexed. */
     257                              func (stream, ", #%d]", offset);
    207258
    208259                              offset += pc + 8;
     
    218269                            {
    219270                              /* Post indexed.  */
    220                               func (stream, "], #%x", offset);
    221 
    222                               offset = pc + 8;  /* ie ignore the offset.  */
     271                              func (stream, "], #%d", offset);
     272
     273                              /* ie ignore the offset.  */
     274                              offset = pc + 8;
    223275                            }
    224                          
     276
    225277                          func (stream, "\t; ");
    226278                          info->print_address_func (offset, info);
     
    228280                      else
    229281                        {
    230                           func (stream, "[%s", 
     282                          func (stream, "[%s",
    231283                                arm_regnames[(given >> 16) & 0xf]);
    232284                          if ((given & 0x01000000) != 0)
     
    248300                                }
    249301
    250                               func (stream, "]%s", 
     302                              func (stream, "]%s",
    251303                                    ((given & 0x00200000) != 0) ? "!" : "");
    252304                            }
     
    260312                                          (((given & 0x00800000) == 0)
    261313                                           ? "-" : ""), offset);
    262                                   else 
     314                                  else
    263315                                    func (stream, "]");
    264316                                }
     
    266318                                {
    267319                                  func (stream, "], %s",
    268                                         (((given & 0x00800000) == 0) 
     320                                        (((given & 0x00800000) == 0)
    269321                                         ? "-" : ""));
    270322                                  arm_decode_shift (given, func, stream);
     
    279331                          /* PC relative with immediate offset.  */
    280332                          int offset = ((given & 0xf00) >> 4) | (given & 0xf);
    281                          
     333
    282334                          if ((given & 0x00800000) == 0)
    283335                            offset = -offset;
    284                          
    285                           func (stream, "[pc, #%x]\t; ", offset);
    286                          
     336
     337                          func (stream, "[pc, #%d]\t; ", offset);
     338
    287339                          (*info->print_address_func)
    288340                            (offset + pc + 8, info);
     
    290342                      else
    291343                        {
    292                           func (stream, "[%s", 
     344                          func (stream, "[%s",
    293345                                arm_regnames[(given >> 16) & 0xf]);
    294346                          if ((given & 0x01000000) != 0)
     
    313365                                }
    314366
    315                               func (stream, "]%s", 
     367                              func (stream, "]%s",
    316368                                    ((given & 0x00200000) != 0) ? "!" : "");
    317369                            }
     
    327379                                          (((given & 0x00800000) == 0)
    328380                                           ? "-" : ""), offset);
    329                                   else 
     381                                  else
    330382                                    func (stream, "]");
    331383                                }
     
    341393                        }
    342394                      break;
    343                          
     395
    344396                    case 'b':
    345397                      (*info->print_address_func)
     
    391443                      if ((given & 0x01200000) == 0x00200000)
    392444                        func (stream, "t");
    393                       break;
    394 
    395                     case 'h':
    396                       if ((given & 0x00000020) == 0x00000020)
    397                         func (stream, "h");
    398                       else
    399                         func (stream, "b");
    400445                      break;
    401446
     
    430475                        bfd_vma address;
    431476                        bfd_vma offset = 0;
    432                        
     477
    433478                        if (given & 0x00800000)
    434479                          /* Is signed, hi bits should be ones.  */
     
    439484                        offset <<= 2;
    440485                        address = offset + pc + 8;
    441                        
     486
    442487                        if (given & 0x01000000)
    443488                          /* H bit allows addressing to 2-byte boundaries.  */
     
    446491                        info->print_address_func (address, info);
    447492                      }
     493                      break;
     494
     495                    case 'I':
     496                      /* Print a Cirrus/DSP shift immediate.  */
     497                      /* Immediates are 7bit signed ints with bits 0..3 in
     498                         bits 0..3 of opcode and bits 4..6 in bits 5..7
     499                         of opcode.  */
     500                      {
     501                        int imm;
     502
     503                        imm = (given & 0xf) | ((given & 0xe0) >> 1);
     504
     505                        /* Is ``imm'' a negative number?  */
     506                        if (imm & 0x40)
     507                          imm |= (-1 << 7);
     508
     509                        func (stream, "%d", imm);
     510                      }
     511
    448512                      break;
    449513
     
    476540                        }
    477541                      break;
    478                        
     542
    479543                    case 'P':
    480544                      switch (given & 0x00080080)
     
    528592                      break;
    529593
    530                     case '0': case '1': case '2': case '3': case '4': 
     594                    case '0': case '1': case '2': case '3': case '4':
    531595                    case '5': case '6': case '7': case '8': case '9':
    532596                      {
     
    540604                          case '-':
    541605                            c++;
    542                            
     606
    543607                            while (*c >= '0' && *c <= '9')
    544608                              bitend = (bitend * 10) + *c++ - '0';
    545                            
     609
    546610                            if (!bitend)
    547611                              abort ();
    548                            
     612
    549613                            switch (*c)
    550614                              {
     
    552616                                {
    553617                                  long reg;
    554                                  
     618
    555619                                  reg = given >> bitstart;
    556620                                  reg &= (2 << (bitend - bitstart)) - 1;
    557                                  
     621
    558622                                  func (stream, "%s", arm_regnames[reg]);
    559623                                }
     
    562626                                {
    563627                                  long reg;
    564                                  
     628
    565629                                  reg = given >> bitstart;
    566630                                  reg &= (2 << (bitend - bitstart)) - 1;
    567                                  
     631
    568632                                  func (stream, "%d", reg);
    569633                                }
     
    572636                                {
    573637                                  long reg;
    574                                  
     638
    575639                                  reg = given >> bitstart;
    576640                                  reg &= (2 << (bitend - bitstart)) - 1;
    577                                  
     641
    578642                                  func (stream, "0x%08x", reg);
    579                                  
     643
    580644                                  /* Some SWI instructions have special
    581645                                     meanings.  */
     
    589653                                {
    590654                                  long reg;
    591                                  
     655
    592656                                  reg = given >> bitstart;
    593657                                  reg &= (2 << (bitend - bitstart)) - 1;
    594                                  
     658
    595659                                  func (stream, "%01x", reg & 0xf);
    596660                                }
     
    599663                                {
    600664                                  long reg;
    601                                  
     665
    602666                                  reg = given >> bitstart;
    603667                                  reg &= (2 << (bitend - bitstart)) - 1;
    604                                  
     668
    605669                                  if (reg > 7)
    606670                                    func (stream, "#%s",
     
    610674                                }
    611675                                break;
     676
     677                              case 'w':
     678                                {
     679                                  long reg;
     680
     681                                  if (bitstart != bitend)
     682                                    {
     683                                      reg = given >> bitstart;
     684                                      reg &= (2 << (bitend - bitstart)) - 1;
     685                                      if (bitend - bitstart == 1)
     686                                        func (stream, "%s", iwmmxt_wwnames[reg]);
     687                                      else
     688                                        func (stream, "%s", iwmmxt_wwssnames[reg]);
     689                                    }
     690                                  else
     691                                    {
     692                                      reg = (((given >> 8)  & 0x1) |
     693                                             ((given >> 22) & 0x1));
     694                                      func (stream, "%s", iwmmxt_wwnames[reg]);
     695                                    }
     696                                }
     697                                break;
     698
     699                              case 'g':
     700                                {
     701                                  long reg;
     702                                  int current_regnames;
     703
     704                                  if (! iwmmxt_regnames)
     705                                    iwmmxt_regnames = set_iwmmxt_regnames ();
     706                                  current_regnames = set_arm_regname_option
     707                                    (iwmmxt_regnames);
     708
     709                                  reg = given >> bitstart;
     710                                  reg &= (2 << (bitend - bitstart)) - 1;
     711                                  func (stream, "%s", arm_regnames[reg]);
     712                                  set_arm_regname_option (current_regnames);
     713                                }
     714                                break;
     715
     716                              case 'G':
     717                                {
     718                                  long reg;
     719                                  int current_regnames;
     720
     721                                  if (! iwmmxt_regnames)
     722                                    iwmmxt_regnames = set_iwmmxt_regnames ();
     723                                  current_regnames = set_arm_regname_option
     724                                    (iwmmxt_regnames + 1);
     725
     726                                  reg = given >> bitstart;
     727                                  reg &= (2 << (bitend - bitstart)) - 1;
     728                                  func (stream, "%s", arm_regnames[reg]);
     729                                  set_arm_regname_option (current_regnames);
     730                                }
     731                                break;
     732
    612733                              default:
    613734                                abort ();
    614735                              }
    615736                            break;
    616                            
     737
     738                          case 'y':
     739                          case 'z':
     740                            {
     741                              int single = *c == 'y';
     742                              int regno;
     743
     744                              switch (bitstart)
     745                                {
     746                                case 4: /* Sm pair */
     747                                  func (stream, "{");
     748                                  /* Fall through.  */
     749                                case 0: /* Sm, Dm */
     750                                  regno = given & 0x0000000f;
     751                                  if (single)
     752                                    {
     753                                      regno <<= 1;
     754                                      regno += (given >> 5) & 1;
     755                                    }
     756                                  break;
     757
     758                                case 1: /* Sd, Dd */
     759                                  regno = (given >> 12) & 0x0000000f;
     760                                  if (single)
     761                                    {
     762                                      regno <<= 1;
     763                                      regno += (given >> 22) & 1;
     764                                    }
     765                                  break;
     766
     767                                case 2: /* Sn, Dn */
     768                                  regno = (given >> 16) & 0x0000000f;
     769                                  if (single)
     770                                    {
     771                                      regno <<= 1;
     772                                      regno += (given >> 7) & 1;
     773                                    }
     774                                  break;
     775
     776                                case 3: /* List */
     777                                  func (stream, "{");
     778                                  regno = (given >> 12) & 0x0000000f;
     779                                  if (single)
     780                                    {
     781                                      regno <<= 1;
     782                                      regno += (given >> 22) & 1;
     783                                    }
     784                                  break;
     785
     786
     787                                default:
     788                                  abort ();
     789                                }
     790
     791                              func (stream, "%c%d", single ? 's' : 'd', regno);
     792
     793                              if (bitstart == 3)
     794                                {
     795                                  int count = given & 0xff;
     796
     797                                  if (single == 0)
     798                                    count >>= 1;
     799
     800                                  if (--count)
     801                                    {
     802                                      func (stream, "-%c%d",
     803                                            single ? 's' : 'd',
     804                                            regno + count);
     805                                    }
     806
     807                                  func (stream, "}");
     808                                }
     809                              else if (bitstart == 4)
     810                                func (stream, ", %c%d}", single ? 's' : 'd',
     811                                      regno + 1);
     812
     813                              break;
     814                            }
     815
    617816                          case '`':
    618817                            c++;
     
    637836                        break;
    638837
     838                      case 'L':
     839                        switch (given & 0x00400100)
     840                          {
     841                          case 0x00000000: func (stream, "b"); break;
     842                          case 0x00400000: func (stream, "h"); break;
     843                          case 0x00000100: func (stream, "w"); break;
     844                          case 0x00400100: func (stream, "d"); break;
     845                          default:
     846                            break;
     847                          }
     848                        break;
     849
     850                      case 'Z':
     851                        {
     852                          int value;
     853                          /* given (20, 23) | given (0, 3) */
     854                          value = ((given >> 16) & 0xf0) | (given & 0xf);
     855                          func (stream, "%d", value);
     856                        }
     857                        break;
     858
     859                      case 'l':
     860                        /* This is like the 'A' operator, except that if
     861                           the width field "M" is zero, then the offset is
     862                           *not* multiplied by four.  */
     863                        {
     864                          int offset = given & 0xff;
     865                          int multiplier = (given & 0x00000100) ? 4 : 1;
     866
     867                          func (stream, "[%s", arm_regnames [(given >> 16) & 0xf]);
     868
     869                          if (offset)
     870                            {
     871                              if ((given & 0x01000000) != 0)
     872                                func (stream, ", %s#%d]%s",
     873                                      ((given & 0x00800000) == 0 ? "-" : ""),
     874                                      offset * multiplier,
     875                                      ((given & 0x00200000) != 0 ? "!" : ""));
     876                              else
     877                                func (stream, "], %s#%d",
     878                                      ((given & 0x00800000) == 0 ? "-" : ""),
     879                                      offset * multiplier);
     880                            }
     881                          else
     882                            func (stream, "]");
     883                        }
     884                        break;
     885
    639886                      default:
    640887                        abort ();
     
    653900/* Print one instruction from PC on INFO->STREAM.
    654901   Return the size of the instruction. */
     902
    655903static int
    656904print_insn_thumb (pc, info, given)
    657      bfd_vma                   pc;
    658      struct disassemble_info * info;
    659      long                      given;
    660 {
    661   struct thumb_opcode * insn;
    662   void *                stream = info->stream;
    663   fprintf_ftype         func = info->fprintf_func;
     905     bfd_vma pc;
     906     struct disassemble_info *info;
     907     long given;
     908{
     909  const struct thumb_opcode *insn;
     910  void *stream = info->stream;
     911  fprintf_ftype func = info->fprintf_func;
    664912
    665913  for (insn = thumb_opcodes; insn->assembler; insn++)
     
    672920          if (!*c) /* Check for empty (not NULL) assembler string.  */
    673921            {
     922              long offset;
     923
    674924              info->bytes_per_chunk = 4;
    675925              info->bytes_per_line  = 4;
    676              
     926
     927              offset = BDISP23 (given);
     928              offset = offset * 2 + pc + 4;
     929
    677930              if ((given & 0x10000000) == 0)
    678                  func (stream, "blx\t");
     931                {
     932                  func (stream, "blx\t");
     933                  offset &= 0xfffffffc;
     934                }
    679935              else
    680                 func (stream, "bl\t");
    681                
    682               info->print_address_func (BDISP23 (given) * 2 + pc + 4, info);
     936                func (stream, "bl\t");
     937
     938              info->print_address_func (offset, info);
    683939              return 4;
    684940            }
     
    687943              info->bytes_per_chunk = 2;
    688944              info->bytes_per_line  = 4;
    689                      
     945
    690946              given &= 0xffff;
    691              
     947
    692948              for (; *c; c++)
    693949                {
     
    696952                      int domaskpc = 0;
    697953                      int domasklr = 0;
    698                      
     954
    699955                      switch (*++c)
    700956                        {
     
    706962                          {
    707963                            long reg;
    708                            
     964
    709965                            reg = (given >> 3) & 0x7;
    710966                            if (given & (1 << 6))
    711967                              reg += 8;
    712                            
     968
    713969                            func (stream, "%s", arm_regnames[reg]);
    714970                          }
     
    718974                          {
    719975                            long reg;
    720                            
     976
    721977                            reg = given & 0x7;
    722978                            if (given & (1 << 7))
    723979                             reg += 8;
    724                            
     980
    725981                            func (stream, "%s", arm_regnames[reg]);
    726982                          }
     
    7441000                            int started = 0;
    7451001                            int reg;
    746                            
     1002
    7471003                            func (stream, "{");
    748                            
     1004
    7491005                            /* It would be nice if we could spot
    7501006                               ranges, and generate the rS-rE format: */
     
    7781034
    7791035
    780                         case '0': case '1': case '2': case '3': case '4': 
     1036                        case '0': case '1': case '2': case '3': case '4':
    7811037                        case '5': case '6': case '7': case '8': case '9':
    7821038                          {
    7831039                            int bitstart = *c++ - '0';
    7841040                            int bitend = 0;
    785                            
     1041
    7861042                            while (*c >= '0' && *c <= '9')
    7871043                              bitstart = (bitstart * 10) + *c++ - '0';
     
    7921048                                {
    7931049                                  long reg;
    794                                  
     1050
    7951051                                  c++;
    7961052                                  while (*c >= '0' && *c <= '9')
     
    8841140
    8851141/* Parse an individual disassembler option.  */
     1142
    8861143void
    8871144parse_arm_disassembler_option (option)
     
    8901147  if (option == NULL)
    8911148    return;
    892      
     1149
    8931150  if (strneq (option, "reg-names-", 10))
    8941151    {
    8951152      int i;
    896        
     1153
    8971154      option += 10;
    8981155
     
    9031160            break;
    9041161          }
    905      
     1162
    9061163      if (i < 0)
    9071164        fprintf (stderr, _("Unrecognised register name set: %s\n"), option);
     
    9131170  else
    9141171    fprintf (stderr, _("Unrecognised disassembler option: %s\n"), option);
    915  
     1172
    9161173  return;
    9171174}
    9181175
    9191176/* Parse the string of disassembler options, spliting it at whitespaces.  */
     1177
    9201178static void
    9211179parse_disassembler_options (options)
     
    9231181{
    9241182  char * space;
    925  
     1183
    9261184  if (options == NULL)
    9271185    return;
     
    9461204/* NOTE: There are no checks in these routines that
    9471205   the relevant number of data bytes exist.  */
     1206
    9481207static int
    9491208print_insn (pc, info, little)
    9501209     bfd_vma pc;
    9511210     struct disassemble_info * info;
    952      boolean little;
     1211     bfd_boolean little;
    9531212{
    9541213  unsigned char      b[4];
     
    9601219    {
    9611220      parse_disassembler_options (info->disassembler_options);
    962      
     1221
    9631222      /* To avoid repeated parsing of these options, we remove them here.  */
    9641223      info->disassembler_options = NULL;
    9651224    }
    966  
     1225
    9671226  is_thumb = force_thumb;
    968  
     1227
    9691228  if (!is_thumb && info->symbols != NULL)
    9701229    {
     
    9721231        {
    9731232          coff_symbol_type * cs;
    974          
     1233
    9751234          cs = coffsymbol (*info->symbols);
    9761235          is_thumb = (   cs->native->u.syment.n_sclass == C_THUMBEXT
     
    9841243          elf_symbol_type *  es;
    9851244          unsigned int       type;
    986          
     1245
    9871246          es = *(elf_symbol_type **)(info->symbols);
    9881247          type = ELF_ST_TYPE (es->internal_elf_sym.st_info);
    989          
     1248
    9901249          is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT);
    9911250        }
    9921251    }
    993  
     1252
    9941253  info->bytes_per_chunk = 4;
    9951254  info->display_endian  = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
     
    10011260        {
    10021261          info->bytes_per_chunk = 2;
    1003          
     1262
    10041263          status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
    10051264          b[3] = b[2] = 0;
    10061265        }
    1007      
     1266
    10081267      if (status != 0)
    10091268        {
     
    10111270          return -1;
    10121271        }
    1013      
     1272
    10141273      given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
    10151274    }
     
    10231282          return -1;
    10241283        }
    1025      
     1284
    10261285      if (is_thumb)
    10271286        {
     
    10291288            {
    10301289              given = (b[2] << 8) | b[3];
    1031              
     1290
    10321291              status = info->read_memory_func
    10331292                ((pc + 4) & ~ 0x3, (bfd_byte *) b, 4, info);
     
    10371296                  return -1;
    10381297                }
    1039              
     1298
    10401299              given |= (b[0] << 24) | (b[1] << 16);
    10411300            }
     
    10461305        given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
    10471306    }
    1048  
     1307
    10491308  if (info->flags & INSN_HAS_RELOC)
    10501309    /* If the instruction has a reloc associated with it, then
     
    10541313       addresses, since the addend is not currently pc-relative.  */
    10551314    pc = 0;
    1056  
     1315
    10571316  if (is_thumb)
    10581317    status = print_insn_thumb (pc, info, given);
     
    10681327     struct disassemble_info * info;
    10691328{
    1070   return print_insn (pc, info, false);
     1329  return print_insn (pc, info, FALSE);
    10711330}
    10721331
     
    10761335     struct disassemble_info * info;
    10771336{
    1078   return print_insn (pc, info, true);
     1337  return print_insn (pc, info, TRUE);
    10791338}
    10801339
     
    10871346The following ARM specific disassembler options are supported for use with\n\
    10881347the -M switch:\n"));
    1089  
     1348
    10901349  for (i = NUM_ARM_REGNAMES; i--;)
    10911350    fprintf (stream, "  reg-names-%s %*c%s\n",
    10921351             regnames[i].name,
    1093              14 - strlen (regnames[i].name), ' ',
     1352             (int)(14 - strlen (regnames[i].name)), ' ',
    10941353             regnames[i].description);
    10951354
Note: See TracChangeset for help on using the changeset viewer.