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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Instruction printing code for the ARC.
    2    Copyright 1994, 1995, 1997, 1998, 2000, 2001
     2   Copyright 1994, 1995, 1997, 1998, 2000, 2001, 2002
    33   Free Software Foundation, Inc.
    44   Contributed by Doug Evans (dje@cygnus.com).
     
    1818   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    1919
    20 #include <ansidecl.h>
    21 #include <libiberty.h>
     20#include "ansidecl.h"
     21#include "libiberty.h"
    2222#include "dis-asm.h"
    2323#include "opcode/arc.h"
     
    2727#include "opintl.h"
    2828
    29 #include <ctype.h>
    3029#include <stdarg.h>
    3130#include "arc-dis.h"
     
    3635#endif
    3736
    38 #define BIT(word,n)     ((word) & (1 << n))
    39 #define BITS(word,s,e)  (((word) << (31 - e)) >> (s + (31 - e))) 
    40 #define OPCODE(word)    (BITS ((word), 27, 31))
    41 #define FIELDA(word)    (BITS ((word), 21, 26))
    42 #define FIELDB(word)    (BITS ((word), 15, 20))
    43 #define FIELDC(word)    (BITS ((word),  9, 14))
     37#define BIT(word,n)     ((word) & (1 << n))
     38#define BITS(word,s,e)  (((word) << (31 - e)) >> (s + (31 - e)))
     39#define OPCODE(word)    (BITS ((word), 27, 31))
     40#define FIELDA(word)    (BITS ((word), 21, 26))
     41#define FIELDB(word)    (BITS ((word), 15, 20))
     42#define FIELDC(word)    (BITS ((word),  9, 14))
    4443
    4544/* FIELD D is signed in all of its uses, so we make sure argument is
    4645   treated as signed for bit shifting purposes:  */
    47 #define FIELDD(word)    (BITS (((signed int)word), 0, 8))
    48 
    49 #define PUT_NEXT_WORD_IN(a)                                                     \
    50   do                                                                            \
    51     {                                                                           \
    52       if (is_limm == 1 && !NEXT_WORD (1))                                       \
    53         mwerror (state, _("Illegal limm reference in last instruction!\n"));    \
    54         a = state->words[1];                                                    \
    55     }                                                                           \
     46#define FIELDD(word)    (BITS (((signed int)word), 0, 8))
     47
     48#define PUT_NEXT_WORD_IN(a)                                             \
     49  do                                                                    \
     50    {                                                                   \
     51      if (is_limm == 1 && !NEXT_WORD (1))                               \
     52        mwerror (state, _("Illegal limm reference in last instruction!\n")); \
     53      a = state->words[1];                                              \
     54    }                                                                   \
    5655  while (0)
    5756
     
    9998  do                                            \
    10099    {                                           \
    101       fieldA = FIELDA(state->words[0]);         \
     100      fieldA = FIELDA (state->words[0]);        \
    102101      if (fieldA > 60)                          \
    103102        {                                       \
     
    137136                                      usesAuxReg ? cb"%a"ca :           \
    138137                                      IS_SMALL (x) ? cb"%d"ca : cb"%h"ca))
    139 #define WRITE_FORMAT_RB()       strcat (formatString, "]")
     138#define WRITE_FORMAT_RB()       strcat (formatString, "]")
    140139#define WRITE_COMMENT(str)      (state->comm[state->commNum++] = (str))
    141 #define WRITE_NOP_COMMENT()     if (!fieldAisReg && !flag) WRITE_COMMENT ("nop");
    142 
    143 #define NEXT_WORD(x)    (offset += 4, state->words[x])
    144 
    145 #define add_target(x)   (state->targets[state->tcnt++] = (x))
     140#define WRITE_NOP_COMMENT()     if (!fieldAisReg && !flag) WRITE_COMMENT ("nop");
     141
     142#define NEXT_WORD(x)    (offset += 4, state->words[x])
     143
     144#define add_target(x)   (state->targets[state->tcnt++] = (x))
    146145
    147146static char comment_prefix[] = "\t; ";
     147
     148static const char *core_reg_name PARAMS ((struct arcDisState *, int));
     149static const char *aux_reg_name PARAMS ((struct arcDisState *, int));
     150static const char *cond_code_name PARAMS ((struct arcDisState *, int));
     151static const char *instruction_name
     152  PARAMS ((struct arcDisState *, int, int, int *));
     153static void mwerror PARAMS ((struct arcDisState *, const char *));
     154static const char *post_address PARAMS ((struct arcDisState *, int));
     155static void write_comments_
     156  PARAMS ((struct arcDisState *, int, int, long int));
     157static void write_instr_name_
     158  PARAMS ((struct arcDisState *, const char *, int, int, int, int, int, int));
     159static int dsmOneArcInst PARAMS ((bfd_vma, struct arcDisState *));
     160static const char *_coreRegName PARAMS ((void *, int));
     161static int decodeInstr PARAMS ((bfd_vma, disassemble_info *));
    148162
    149163static const char *
    150164core_reg_name (state, val)
    151165     struct arcDisState * state;
    152      int                  val; 
     166     int                  val;
    153167{
    154168  if (state->coreRegName)
     
    160174aux_reg_name (state, val)
    161175     struct arcDisState * state;
    162      int                  val; 
     176     int                  val;
    163177{
    164178  if (state->auxRegName)
     
    170184cond_code_name (state, val)
    171185     struct arcDisState * state;
    172      int                  val; 
     186     int                  val;
    173187{
    174188  if (state->condCodeName)
     
    182196     int    op1;
    183197     int    op2;
    184      int *  flags; 
     198     int *  flags;
    185199{
    186200  if (state->instName)
     
    192206mwerror (state, msg)
    193207     struct arcDisState * state;
    194      const char * msg; 
     208     const char * msg;
    195209{
    196210  if (state->err != 0)
     
    201215post_address (state, addr)
    202216     struct arcDisState * state;
    203      int addr; 
     217     int addr;
    204218{
    205219  static char id[3 * ARRAY_SIZE (state->addresses)];
     
    214228      id[j+1] = '0'+i;
    215229      id[j+2] = 0;
    216      
     230
    217231      return id + j;
    218232    }
     
    220234}
    221235
    222 static void
    223 my_sprintf (
    224             struct arcDisState * state,
    225             char * buf,
    226             const char * format,
    227             ...)
    228 {
    229   char *bp; 
     236static void my_sprintf PARAMS ((struct arcDisState *, char *, const char *,
     237                                ...));
     238
     239static void
     240my_sprintf VPARAMS ((struct arcDisState *state, char *buf, const char *format,
     241                     ...))
     242{
     243  char *bp;
    230244  const char *p;
    231245  int size, leading_zero, regMap[2];
    232246  long auxNum;
    233   va_list ap;
    234  
    235   va_start (ap, format);
    236  
    237   bp = buf;
     247
     248  VA_OPEN (ap, format);
     249  VA_FIXEDARG (ap, struct arcDisState *, state);
     250  VA_FIXEDARG (ap, char *, buf);
     251  VA_FIXEDARG (ap, const char *, format);
     252
     253  bp = buf;
    238254  *bp = 0;
    239255  p = format;
     
    241257  regMap[0] = 0;
    242258  regMap[1] = 0;
    243  
    244   while (1) 
     259
     260  while (1)
    245261    switch (*p++)
    246262      {
    247     case 0:
    248       goto DOCOMM; /* (return)  */
    249       default: 
    250         *bp++ = p[-1]; 
     263      case 0:
     264        goto DOCOMM; /* (return)  */
     265      default:
     266        *bp++ = p[-1];
    251267        break;
    252268      case '%':
     
    254270        leading_zero = 0;
    255271      RETRY: ;
    256         switch (*p++) 
     272        switch (*p++)
    257273          {
    258274          case '0':
     
    280296#define inc_bp() bp = bp + strlen (bp)
    281297
    282           case 'h': 
     298          case 'h':
    283299            {
    284300              unsigned u = va_arg (ap, int);
     
    287303                 one place, here, if we wish.
    288304                 We add underscores for easy reading.  */
    289               if (u > 65536) 
     305              if (u > 65536)
    290306                sprintf (bp, "0x%x_%04x", u >> 16, u & 0xffff);
    291               else 
     307              else
    292308                sprintf (bp, "0x%x", u);
    293309              inc_bp ();
    294             } 
     310            }
    295311            break;
    296           case 'X': case 'x': 
     312          case 'X': case 'x':
    297313            {
    298314              int val = va_arg (ap, int);
    299315
    300               if (size != 0) 
     316              if (size != 0)
    301317                if (leading_zero)
    302318                  sprintf (bp, "%0*x", size, val);
     
    308324            }
    309325            break;
    310           case 'd': 
     326          case 'd':
    311327            {
    312328              int val = va_arg (ap, int);
    313            
     329
    314330              if (size != 0)
    315331                sprintf (bp, "%*d", size, val);
     
    319335            }
    320336            break;
    321           case 'r': 
     337          case 'r':
    322338            {
    323339              /* Register.  */
    324340              int val = va_arg (ap, int);
    325            
     341
    326342#define REG2NAME(num, name) case num: sprintf (bp, ""name); \
    327343  regMap[(num < 32) ? 0 : 1] |= 1 << (num - ((num < 32) ? 0 : 32)); break;
    328              
    329               switch (val) 
     344
     345              switch (val)
    330346                {
    331347                  REG2NAME (26, "gp");
     
    350366              inc_bp ();
    351367            } break;
    352          
    353           case 'a': 
     368
     369          case 'a':
    354370            {
    355371              /* Aux Register.  */
     
    358374#define AUXREG2NAME(num, name) case num: sprintf (bp,name); break;
    359375
    360               switch (val) 
     376              switch (val)
    361377                {
    362378                  AUXREG2NAME (0x0, "status");
     
    381397            }
    382398            break;
    383            
    384           case 's': 
     399
     400          case 's':
    385401            {
    386402              sprintf (bp, "%s", va_arg (ap, char *));
     
    388404            }
    389405            break;
    390            
     406
    391407          default:
    392408            fprintf (stderr, "?? format %c\n", p[-1]);
     
    396412
    397413 DOCOMM: *bp = 0;
    398 }
    399 
    400 static void
     414  VA_CLOSE (ap);
     415}
     416
     417static void
    401418write_comments_(state, shimm, is_limm, limm_value)
    402419     struct arcDisState * state;
     
    405422     long limm_value;
    406423{
    407   if (state->commentBuffer != 0) 
     424  if (state->commentBuffer != 0)
    408425    {
    409426      int i;
    410427
    411       if (is_limm) 
     428      if (is_limm)
    412429        {
    413430          const char *name = post_address (state, limm_value + shimm);
     
    416433            WRITE_COMMENT (name);
    417434        }
    418       for (i = 0; i < state->commNum; i++) 
     435      for (i = 0; i < state->commNum; i++)
    419436        {
    420437          if (i == 0)
    421438            strcpy (state->commentBuffer, comment_prefix);
    422439          else
    423             strcat (state->commentBuffer, ", ");       
    424           strncat (state->commentBuffer, state->comm[i], sizeof (state->commentBuffer));
     440            strcat (state->commentBuffer, ", ");
     441          strncat (state->commentBuffer, state->comm[i],
     442                   sizeof (state->commentBuffer));
    425443        }
    426444    }
     
    432450static const char *condName[] = {
    433451  /* 0..15.  */
    434   ""   , "z"  , "nz" , "p"  , "n"  , "c"  , "nc" , "v"  , 
     452  ""   , "z"  , "nz" , "p"  , "n"  , "c"  , "nc" , "v"  ,
    435453  "nv" , "gt" , "ge" , "lt" , "le" , "hi" , "ls" , "pnz"
    436454};
    437455
    438 static void 
     456static void
    439457write_instr_name_(state, instrName, cond, condCodeIsPartOfName, flag, signExtend, addrWriteBack, directMem)
    440458     struct arcDisState * state;
     
    449467  strcpy (state->instrBuffer, instrName);
    450468
    451   if (cond > 0) 
     469  if (cond > 0)
    452470    {
    453471      const char *cc = 0;
     
    470488    strcat (state->instrBuffer, ".f");
    471489
    472   switch (state->nullifyMode) 
     490  switch (state->nullifyMode)
    473491    {
    474492    case BR_exec_always:
     
    499517  while (0)
    500518
    501 enum { 
    502   op_LD0 = 0, op_LD1 = 1, op_ST  = 2, op_3   = 3, 
     519enum {
     520  op_LD0 = 0, op_LD1 = 1, op_ST  = 2, op_3   = 3,
    503521  op_BC  = 4, op_BLC = 5, op_LPC = 6, op_JC  = 7,
    504   op_ADD = 8, op_ADC = 9, op_SUB = 10, op_SBC = 11, 
     522  op_ADD = 8, op_ADC = 9, op_SUB = 10, op_SBC = 11,
    505523  op_AND = 12, op_OR  = 13, op_BIC = 14, op_XOR = 15
    506524};
     
    508526extern disassemble_info tm_print_insn_info;
    509527
    510 static int 
     528static int
    511529dsmOneArcInst (addr, state)
    512530     bfd_vma              addr;
     
    537555  int ignoreFirstOpd;
    538556  char formatString[60];
    539  
     557
    540558  state->instructionLen = 4;
    541559  state->nullifyMode = BR_exec_when_no_jump;
    542560  state->opWidth = 12;
    543561  state->isBranch = 0;
    544  
     562
    545563  state->_mem_load = 0;
    546564  state->_ea_present = 0;
     
    549567  state->ea_reg2 = no_reg;
    550568  state->_offset = 0;
    551  
     569
    552570  if (! NEXT_WORD (0))
    553571    return 0;
    554  
     572
    555573  state->_opcode = OPCODE (state->words[0]);
    556574  instrName = 0;
     
    567585    state->commentBuffer[0] = '\0';
    568586
    569   switch (state->_opcode) 
     587  switch (state->_opcode)
    570588    {
    571     case op_LD0: 
    572       switch (BITS (state->words[0],1,2)) 
     589    case op_LD0:
     590      switch (BITS (state->words[0],1,2))
    573591        {
    574592        case 0:
     
    585603          break;
    586604        default:
    587           instrName = "??? (0[3])"; 
     605          instrName = "??? (0[3])";
    588606          state->flow = invalid_instr;
    589607          break;
    590608        }
    591       decodingClass = 5; 
    592       break;
    593    
    594     case op_LD1: 
    595       if (BIT (state->words[0],13)) 
    596         {
    597           instrName = "lr"; 
     609      decodingClass = 5;
     610      break;
     611
     612    case op_LD1:
     613      if (BIT (state->words[0],13))
     614        {
     615          instrName = "lr";
    598616          decodingClass = 10;
    599617        }
    600       else 
    601         {
    602           switch (BITS (state->words[0],10,11)) 
     618      else
     619        {
     620          switch (BITS (state->words[0],10,11))
    603621            {
    604622            case 0:
     
    615633              break;
    616634            default:
    617               instrName = "??? (1[3])"; 
     635              instrName = "??? (1[3])";
    618636              state->flow = invalid_instr;
    619637              break;
     
    622640        }
    623641      break;
    624      
     642
    625643    case op_ST:
    626       if (BIT (state->words[0],25)) 
     644      if (BIT (state->words[0],25))
    627645        {
    628646          instrName = "sr";
    629647          decodingClass = 8;
    630648        }
    631       else 
    632         {
    633           switch (BITS (state->words[0],22,23)) 
     649      else
     650        {
     651          switch (BITS (state->words[0],22,23))
    634652            {
    635653            case 0:
     
    643661              break;
    644662            default:
    645               instrName = "??? (2[3])"; 
     663              instrName = "??? (2[3])";
    646664              state->flow = invalid_instr;
    647665              break;
     
    650668        }
    651669      break;
    652      
     670
    653671    case op_3:
    654672      decodingClass = 1;  /* default for opcode 3...  */
    655       switch (FIELDC (state->words[0])) 
     673      switch (FIELDC (state->words[0]))
    656674        {
    657675        case  0:
    658           instrName = "flag"; 
     676          instrName = "flag";
    659677          decodingClass = 2;
    660678          break;
     
    683701          instrName = "extw";
    684702          break;
    685         case  0x3f: 
     703        case  0x3f:
    686704          {
    687705            decodingClass = 9;
    688             switch( FIELDD (state->words[0]) ) 
     706            switch( FIELDD (state->words[0]) )
    689707              {
    690708              case 0:
     
    704722          }
    705723          break;
    706          
     724
    707725          /* ARC Extension Library Instructions
    708726             NOTE: We assume that extension codes are these instrs.  */
     
    711729                                        state->_opcode,
    712730                                        FIELDC (state->words[0]),
    713                                         & flags);
     731                                        &flags);
    714732          if (!instrName)
    715733            {
     
    724742
    725743    case op_BC:
    726       instrName = "b"; 
     744      instrName = "b";
    727745    case op_BLC:
    728746      if (!instrName)
    729         instrName = "bl"; 
     747        instrName = "bl";
    730748    case op_LPC:
    731749      if (!instrName)
    732         instrName = "lp"; 
     750        instrName = "lp";
    733751    case op_JC:
    734752      if (!instrName)
    735753        {
    736           if (BITS (state->words[0],9,9)) 
    737             {
    738               instrName = "jl"; 
     754          if (BITS (state->words[0],9,9))
     755            {
     756              instrName = "jl";
    739757              is_linked = 1;
    740758            }
    741           else 
    742             {
    743               instrName = "j"; 
     759          else
     760            {
     761              instrName = "j";
    744762              is_linked = 0;
    745763            }
     
    749767      state->isBranch = 1;
    750768      break;
    751    
     769
    752770    case op_ADD:
    753771    case op_ADC:
     
    756774      decodingClass = 0;
    757775
    758       switch (state->_opcode) 
     776      switch (state->_opcode)
    759777        {
    760778        case op_ADD:
     
    769787        }
    770788      break;
    771      
     789
    772790    case op_SUB: instrName = "sub";
    773791      break;
     
    786804          decodingClass = 9;
    787805        }
    788       else 
     806      else
    789807        instrName = "xor";
    790808      break;
    791      
     809
    792810    default:
    793811      instrName = instruction_name (state,state->_opcode,0,&flags);
     
    802820      break;
    803821    }
    804  
     822
    805823  fieldAisReg = fieldBisReg = fieldCisReg = 1; /* Assume regs for now.  */
    806824  flag = cond = is_shimm = is_limm = 0;
     
    808826  signExtend = addrWriteBack = directMem = 0;
    809827  usesAuxReg = 0;
    810  
    811   switch (decodingClass) 
     828
     829  switch (decodingClass)
    812830    {
    813831    case 0:
     
    817835        CHECK_FIELD_C ();
    818836      CHECK_FLAG_COND_NULLIFY ();
    819      
     837
    820838      write_instr_name ();
    821       if (!ignoreFirstOpd) 
     839      if (!ignoreFirstOpd)
    822840        {
    823841          WRITE_FORMAT_x (A);
     
    826844            WRITE_FORMAT_COMMA_x (C);
    827845          WRITE_NOP_COMMENT ();
    828           my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC);
    829         }
    830       else
     846          my_sprintf (state, state->operandBuffer, formatString,
     847                      fieldA, fieldB, fieldC);
     848        }
     849      else
    831850        {
    832851          WRITE_FORMAT_x (B);
    833852          if (!repeatsOp)
    834853            WRITE_FORMAT_COMMA_x (C);
    835           my_sprintf (state, state->operandBuffer, formatString, fieldB, fieldC);
     854          my_sprintf (state, state->operandBuffer, formatString,
     855                      fieldB, fieldC);
    836856        }
    837857      write_comments ();
    838858      break;
    839      
     859
    840860    case 1:
    841861      CHECK_FIELD_A ();
    842862      CHECK_FIELD_B ();
    843863      CHECK_FLAG_COND_NULLIFY ();
    844      
     864
    845865      write_instr_name ();
    846       if (!ignoreFirstOpd) 
     866      if (!ignoreFirstOpd)
    847867        {
    848868          WRITE_FORMAT_x (A);
    849869          WRITE_FORMAT_COMMA_x (B);
    850870          WRITE_NOP_COMMENT ();
    851           my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB);
    852         }
    853       else
     871          my_sprintf (state, state->operandBuffer, formatString,
     872                      fieldA, fieldB);
     873        }
     874      else
    854875        {
    855876          WRITE_FORMAT_x (B);
    856           my_sprintf (state, state->operandBuffer, formatString, fieldB); 
     877          my_sprintf (state, state->operandBuffer, formatString, fieldB);
    857878        }
    858879      write_comments ();
    859880      break;
    860      
     881
    861882    case 2:
    862883      CHECK_FIELD_B ();
    863884      CHECK_FLAG_COND_NULLIFY ();
    864885      flag = 0; /* this is the FLAG instruction -- it's redundant  */
    865      
     886
    866887      write_instr_name ();
    867888      WRITE_FORMAT_x (B);
     
    869890      write_comments ();
    870891      break;
    871      
     892
    872893    case 3:
    873894      fieldA = BITS (state->words[0],7,26) << 2;
     
    876897      CHECK_FLAG_COND_NULLIFY ();
    877898      flag = 0;
    878      
     899
    879900      write_instr_name ();
    880901      /* This address could be a label we know. Convert it.  */
    881       if (state->_opcode != op_LPC /* LP  */) 
    882         {
    883         add_target (fieldA); /* For debugger.  */
    884         state->flow = state->_opcode == op_BLC /* BL  */
    885           ? direct_call
    886           : direct_jump;
    887         /* indirect calls are achieved by "lr blink,[status];
    888            lr dest<- func addr; j [dest]"  */
    889         }                       
    890      
     902      if (state->_opcode != op_LPC /* LP  */)
     903        {
     904          add_target (fieldA); /* For debugger.  */
     905          state->flow = state->_opcode == op_BLC /* BL  */
     906            ? direct_call
     907            : direct_jump;
     908          /* indirect calls are achieved by "lr blink,[status];
     909             lr dest<- func addr; j [dest]"  */
     910        }
     911
    891912      strcat (formatString, "%s"); /* address/label name */
    892       my_sprintf (state, state->operandBuffer, formatString, post_address (state, fieldA));
     913      my_sprintf (state, state->operandBuffer, formatString,
     914                  post_address (state, fieldA));
    893915      write_comments ();
    894916      break;
    895      
     917
    896918    case 4:
    897919      /* For op_JC -- jump to address specified.
     
    901923      CHECK_FIELD_B ();
    902924      CHECK_FLAG_COND_NULLIFY ();
    903      
    904       if (!fieldBisReg) 
     925
     926      if (!fieldBisReg)
    905927        {
    906928          fieldAisReg = 0;
     
    914936            state->nullifyMode = BR_exec_when_no_jump;
    915937        }
    916       else 
     938      else
    917939        {
    918940          state->flow = is_linked ? indirect_call : indirect_jump;
     
    923945          state->register_for_indirect_jump = fieldB;
    924946        }
    925      
     947
    926948      write_instr_name ();
    927       strcat (formatString, 
     949      strcat (formatString,
    928950              IS_REG (B) ? "[%r]" : "%s"); /* address/label name  */
    929       if (fieldA != 0) 
     951      if (fieldA != 0)
    930952        {
    931953          fieldAisReg = 0;
     
    935957        my_sprintf (state, state->operandBuffer, formatString, fieldB, fieldA);
    936958      else
    937         my_sprintf (state, state->operandBuffer, formatString, 
     959        my_sprintf (state, state->operandBuffer, formatString,
    938960                    post_address (state, fieldB), fieldA);
    939961      write_comments ();
    940962      break;
    941      
     963
    942964    case 5:
    943965      /* LD instruction.
     
    960982        state->_offset += fieldC;
    961983      state->_mem_load = 1;
    962      
     984
    963985      directMem     = BIT (state->words[0],5);
    964986      addrWriteBack = BIT (state->words[0],3);
    965987      signExtend    = BIT (state->words[0],0);
    966      
     988
    967989      write_instr_name ();
    968990      WRITE_FORMAT_x_COMMA_LB(A);
     
    971993      else
    972994        fieldB = fieldC;
    973      
     995
    974996      WRITE_FORMAT_x_RB (C);
    975       my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC);
     997      my_sprintf (state, state->operandBuffer, formatString,
     998                  fieldA, fieldB, fieldC);
    976999      write_comments ();
    9771000      break;
    978      
     1001
    9791002    case 6:
    9801003      /* LD instruction.  */
     
    9821005      CHECK_FIELD_A ();
    9831006      fieldC = FIELDD (state->words[0]);
    984      
     1007
    9851008      if (dbg)
    9861009        printf ("6:b reg %d %d c 0x%x  \n",
     
    9951018      else
    9961019        state->_offset += fieldB, state->_ea_present = 0;
    997      
     1020
    9981021      directMem     = BIT (state->words[0],14);
    9991022      addrWriteBack = BIT (state->words[0],12);
    10001023      signExtend    = BIT (state->words[0],9);
    1001      
     1024
    10021025      write_instr_name ();
    10031026      WRITE_FORMAT_x_COMMA_LB (A);
    1004       if (!fieldBisReg) 
     1027      if (!fieldBisReg)
    10051028        {
    10061029          fieldB = state->_offset;
    10071030          WRITE_FORMAT_x_RB (B);
    10081031        }
    1009       else 
     1032      else
    10101033        {
    10111034          WRITE_FORMAT_x (B);
    1012           if (fieldC != 0 && !BIT (state->words[0],13)) 
     1035          if (fieldC != 0 && !BIT (state->words[0],13))
    10131036            {
    10141037              fieldCisReg = 0;
     
    10181041            WRITE_FORMAT_RB ();
    10191042        }
    1020       my_sprintf (state, state->operandBuffer, formatString, fieldA, fieldB, fieldC);
     1043      my_sprintf (state, state->operandBuffer, formatString,
     1044                  fieldA, fieldB, fieldC);
    10211045      write_comments ();
    10221046      break;
    1023      
     1047
    10241048    case 7:
    10251049      /* ST instruction.  */
     
    10271051      CHECK_FIELD_C();
    10281052      fieldA = FIELDD(state->words[0]); /* shimm  */
    1029      
     1053
    10301054      /* [B,A offset]  */
    10311055      if (dbg) printf("7:b reg %d %x off %x\n",
    1032                                 fieldBisReg,fieldB,fieldA);
     1056                      fieldBisReg,fieldB,fieldA);
    10331057      state->_ea_present = 1;
    10341058      state->_offset = fieldA;
    10351059      if (fieldBisReg)
    10361060        state->ea_reg1 = fieldB;
    1037       /* field B is either a shimm (same as fieldA) or limm (different!) 
     1061      /* field B is either a shimm (same as fieldA) or limm (different!)
    10381062         Say ea is not present, so only one of us will do the name lookup.
    10391063         (for is_limm we do the name translation here).  */
    1040       else 
     1064      else
    10411065        state->_offset += fieldB, state->_ea_present = 0;
    1042      
     1066
    10431067      directMem     = BIT(state->words[0],26);
    10441068      addrWriteBack = BIT(state->words[0],24);
    1045      
     1069
    10461070      write_instr_name();
    10471071      WRITE_FORMAT_x_COMMA_LB(C);
    1048            
    1049       if (!fieldBisReg) 
     1072
     1073      if (!fieldBisReg)
    10501074        {
    10511075          fieldB = state->_offset;
    10521076          WRITE_FORMAT_x_RB(B);
    10531077        }
    1054       else 
     1078      else
    10551079        {
    10561080          WRITE_FORMAT_x(B);
    1057           if (fieldBisReg && fieldA != 0) 
     1081          if (fieldBisReg && fieldA != 0)
    10581082            {
    10591083              fieldAisReg = 0;
     
    10631087            WRITE_FORMAT_RB();
    10641088        }
    1065       my_sprintf (state, state->operandBuffer, formatString, fieldC, fieldB, fieldA);
     1089      my_sprintf (state, state->operandBuffer, formatString,
     1090                  fieldC, fieldB, fieldA);
    10661091      write_comments2(fieldA);
    10671092      break;
     
    10701095      CHECK_FIELD_B();
    10711096      CHECK_FIELD_C();
    1072      
     1097
    10731098      write_instr_name();
    10741099      WRITE_FORMAT_x_COMMA_LB(C);
     
    10801105      write_comments();
    10811106      break;
    1082      
     1107
    10831108    case 9:
    10841109      write_instr_name();
    10851110      state->operandBuffer[0] = '\0';
    10861111      break;
    1087      
     1112
    10881113    case 10:
    10891114      /* LR instruction */
    10901115      CHECK_FIELD_A();
    10911116      CHECK_FIELD_B();
    1092      
     1117
    10931118      write_instr_name();
    10941119      WRITE_FORMAT_x_COMMA_LB(A);
     
    11001125      write_comments();
    11011126      break;
    1102      
     1127
    11031128    case 11:
    11041129      CHECK_COND();
     
    11061131      state->operandBuffer[0] = '\0';
    11071132      break;
    1108      
     1133
    11091134    default:
    11101135      mwerror (state, "Bad decoding class in ARC disassembler");
    11111136      break;
    11121137    }
    1113  
     1138
    11141139  state->_cond = cond;
    11151140  return state->instructionLen = offset;
     
    11301155_auxRegName(void *_this ATTRIBUTE_UNUSED, int regval)
    11311156{
    1132     return arcExtMap_auxRegName(regval);
     1157  return arcExtMap_auxRegName(regval);
    11331158}
    11341159
     
    11381163_condCodeName(void *_this ATTRIBUTE_UNUSED, int regval)
    11391164{
    1140     return arcExtMap_condCodeName(regval);
     1165  return arcExtMap_condCodeName(regval);
    11411166}
    11421167
     
    11451170_instName (void *_this ATTRIBUTE_UNUSED, int majop, int minop, int *flags)
    11461171{
    1147     return arcExtMap_instName(majop, minop, flags);
     1172  return arcExtMap_instName(majop, minop, flags);
    11481173}
    11491174
     
    11591184  struct arcDisState s; /* ARC Disassembler state  */
    11601185  void *stream = info->stream; /* output stream  */
    1161   fprintf_ftype func = info->fprintf_func; 
     1186  fprintf_ftype func = info->fprintf_func;
    11621187  int bytes;
    1163  
     1188
    11641189  memset (&s, 0, sizeof(struct arcDisState));
    1165  
     1190
    11661191  /* read first instruction  */
    11671192  status = (*info->read_memory_func) (address, buffer, 4, info);
     
    11961221  (*func) (stream, "%08x ", s.words[0]);
    11971222  (*func) (stream, "    ");
    1198  
     1223
    11991224  (*func) (stream, "%-10s ", s.instrBuffer);
    1200  
     1225
    12011226  if (__TRANSLATION_REQUIRED(s))
    12021227    {
Note: See TracChangeset for help on using the changeset viewer.