home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / opcodes / sparc-dis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-06  |  17.4 KB  |  684 lines

  1. /* Print SPARC instructions.
  2.    Copyright 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #include "ansidecl.h"
  19. #include "opcode/sparc.h"
  20. #include "dis-asm.h"
  21. #include <string.h>
  22.  
  23. /* Sign-extend a value which is N bits long.  */
  24. #define    SEX(value, bits) \
  25.     ((((int)(value)) << ((8 * sizeof (int)) - bits))    \
  26.              >> ((8 * sizeof (int)) - bits) )
  27.  
  28. static  char *reg_names[] =
  29. { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",    
  30.   "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",    
  31.   "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",    
  32.   "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",    
  33.   "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",    
  34.   "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",    
  35.   "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
  36.   "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
  37. #ifndef NO_V9
  38.   "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",    
  39.   "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47",    
  40.   "f48", "f49", "f50", "f51", "f52", "f53", "f54", "f55",
  41.   "f56", "f57", "f58", "f59", "f60", "f61", "f62", "f63",
  42. /* psr, wim, tbr, fpsr, cpsr are v8 only.  */
  43. #endif
  44.   "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr"
  45. };
  46.  
  47. #define    freg_names    (®_names[4 * 8])
  48.  
  49. #ifndef NO_V9
  50. /* These are ordered according to there register number in
  51.    rdpr and wrpr insns.  */
  52. static char *v9_priv_reg_names[] =
  53. {
  54.   "tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",
  55.   "pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",
  56.   "wstate", "fq"
  57.   /* "ver" - special cased */
  58. };
  59. #endif
  60.  
  61. /* FIXME--need to deal with byte order (probably using masking and
  62.    shifting rather than bitfields is easiest).  */
  63.  
  64. union sparc_insn
  65.   {
  66.     unsigned long int code;
  67.     struct
  68.       {
  69.     unsigned int anop:2;
  70. #define    op    ldst.anop
  71.     unsigned int anrd:5;
  72. #define    rd    ldst.anrd
  73.     unsigned int op3:6;
  74.     unsigned int anrs1:5;
  75. #define    rs1    ldst.anrs1
  76.     unsigned int i:1;
  77.     unsigned int anasi:8;
  78. #define    asi    ldst.anasi
  79.     unsigned int anrs2:5;
  80. #define    rs2    ldst.anrs2
  81. #define    shcnt    rs2
  82.       } ldst;
  83.     struct
  84.       {
  85.     unsigned int anop:2, anrd:5, op3:6, anrs1:5, i:1;
  86.     unsigned int IMM13:13;
  87. #define    imm13    IMM13.IMM13
  88.       } IMM13;
  89.     struct
  90.       {
  91.     unsigned int anop:2;
  92.     unsigned int a:1;
  93.     unsigned int cond:4;
  94.     unsigned int op2:3;
  95.     unsigned int DISP22:22;
  96. #define    disp22    branch.DISP22
  97. #define    imm22    disp22
  98.       } branch;
  99. #ifndef NO_V9
  100.     struct
  101.       {
  102.     unsigned int anop:2;
  103.     unsigned int a:1;
  104.     unsigned int z:1;
  105.     unsigned int rcond:3;
  106.     unsigned int op2:3;
  107.     unsigned int DISP16HI:2;
  108.     unsigned int p:1;
  109.     unsigned int _rs1:5;
  110.     unsigned int DISP16LO:14;
  111. #define    disp16(x) (((x).branch16.DISP16HI << 14) | (x).branch16.DISP16LO)
  112.       } branch16;
  113. #endif /* NO_V9 */
  114.     struct
  115.       {
  116.     unsigned int anop:2;
  117.     unsigned int adisp30:30;
  118. #define    disp30    call.adisp30
  119.       } call;
  120.   };
  121.  
  122. /* Nonzero if INSN is the opcode for a delayed branch.  */
  123. static int
  124. is_delayed_branch (insn)
  125.      union sparc_insn insn;
  126. {
  127.   unsigned int i;
  128.  
  129.   for (i = 0; i < NUMOPCODES; ++i)
  130.     {
  131.       CONST struct sparc_opcode *opcode = &sparc_opcodes[i];
  132.       if ((opcode->match & insn.code) == opcode->match
  133.       && (opcode->lose & insn.code) == 0)
  134.     return (opcode->flags & F_DELAYED);
  135.     }
  136.   return 0;
  137. }
  138.  
  139. static int opcodes_sorted = 0;
  140. /* extern void qsort (); */
  141. static int compare_opcodes ();
  142.  
  143. /* Print one instruction from MEMADDR on INFO->STREAM.
  144.  
  145.    We suffix the instruction with a comment that gives the absolute
  146.    address involved, as well as its symbolic form, if the instruction
  147.    is preceded by a findable `sethi' and it either adds an immediate
  148.    displacement to that register, or it is an `add' or `or' instruction
  149.    on that register.  */
  150. int
  151. print_insn_sparc (memaddr, info)
  152.      bfd_vma memaddr;
  153.      disassemble_info *info;
  154. {
  155.   FILE *stream = info->stream;
  156.   union sparc_insn insn;
  157.  
  158.   register unsigned int i;
  159.  
  160.   if (!opcodes_sorted)
  161.     {
  162.       qsort ((char *) sparc_opcodes, NUMOPCODES,
  163.          sizeof (sparc_opcodes[0]), compare_opcodes);
  164.       opcodes_sorted = 1;
  165.     }
  166.  
  167.   {
  168.     int status =
  169.       (*info->read_memory_func) (memaddr, (bfd_byte *) &insn, sizeof (insn), info);
  170.     if (status != 0)
  171.       {
  172.     (*info->memory_error_func) (status, memaddr, info);
  173.     return -1;
  174.       }
  175.   }
  176.  
  177.   info->insn_info_valid = 1;            /* We do return this info */
  178.   info->insn_type = dis_nonbranch;        /* Assume non branch insn */
  179.   info->branch_delay_insns = 0;            /* Assume no delay */
  180.   info->target = 0;                /* Assume no target known */
  181.  
  182.   for (i = 0; i < NUMOPCODES; ++i)
  183.     {
  184.       CONST struct sparc_opcode *opcode = &sparc_opcodes[i];
  185.       if ((opcode->match & insn.code) == opcode->match
  186.       && (opcode->lose & insn.code) == 0)
  187.     {
  188.       /* Nonzero means that we have found an instruction which has
  189.          the effect of adding or or'ing the imm13 field to rs1.  */
  190.       int imm_added_to_rs1 = 0;
  191.  
  192.       /* Nonzero means that we have found a plus sign in the args
  193.          field of the opcode table.  */
  194.       int found_plus = 0;
  195.       
  196.       /* Nonzero means we have an annulled branch.  */
  197.       int is_annulled = 0;
  198.  
  199.       /* Do we have an `add' or `or' instruction where rs1 is the same
  200.          as rsd, and which has the i bit set?  */
  201.       if ((opcode->match == 0x80102000 || opcode->match == 0x80002000)
  202.       /*              (or)                 (add)  */
  203.           && insn.rs1 == insn.rd)
  204.         imm_added_to_rs1 = 1;
  205.  
  206.       if (insn.rs1 != insn.rd
  207.           && strchr (opcode->args, 'r') != 0)
  208.           /* Can't do simple format if source and dest are different.  */
  209.           continue;
  210.  
  211.       (*info->fprintf_func) (stream, opcode->name);
  212.  
  213.       {
  214.         register CONST char *s;
  215.  
  216.         if (opcode->args[0] != ',')
  217.           (*info->fprintf_func) (stream, " ");
  218.         for (s = opcode->args; *s != '\0'; ++s)
  219.           {
  220.         while (*s == ',')
  221.           {
  222.             (*info->fprintf_func) (stream, ",");
  223.             ++s;
  224.             switch (*s) {
  225.             case 'a':
  226.               (*info->fprintf_func) (stream, "a");
  227.               is_annulled = 1;
  228.               ++s;
  229.               continue;
  230. #ifndef NO_V9
  231.             case 'N':
  232.               (*info->fprintf_func) (stream, "pn");
  233.               ++s;
  234.               continue;
  235.  
  236.             case 'T':
  237.               (*info->fprintf_func) (stream, "pt");
  238.               ++s;
  239.               continue;
  240. #endif    /* NO_V9 */
  241.  
  242.             default:
  243.               break;
  244.             }        /* switch on arg */
  245.           }        /* while there are comma started args */
  246.  
  247.         (*info->fprintf_func) (stream, " ");
  248.             
  249.         switch (*s)
  250.           {
  251.           case '+':
  252.             found_plus = 1;
  253.  
  254.             /* note fall-through */
  255.           default:
  256.             (*info->fprintf_func) (stream, "%c", *s);
  257.             break;
  258.  
  259.           case '#':
  260.             (*info->fprintf_func) (stream, "0");
  261.             break;
  262.  
  263. #define    reg(n)    (*info->fprintf_func) (stream, "%%%s", reg_names[n])
  264.           case '1':
  265.           case 'r':
  266.             reg (insn.rs1);
  267.             break;
  268.  
  269.           case '2':
  270.             reg (insn.rs2);
  271.             break;
  272.  
  273.           case 'd':
  274.             reg (insn.rd);
  275.             break;
  276. #undef    reg
  277.  
  278. #define    freg(n)        (*info->fprintf_func) (stream, "%%%s", freg_names[n])
  279. #define    fregx(n)    (*info->fprintf_func) (stream, "%%%s", freg_names[((n) & ~1) | (((n) & 1) << 5)])
  280.           case 'e':
  281.             freg (insn.rs1);
  282.             break;
  283.           case 'v':    /* double/even */
  284.           case 'V':    /* quad/multiple of 4 */
  285.             fregx (insn.rs1);
  286.             break;
  287.  
  288.           case 'f':
  289.             freg (insn.rs2);
  290.             break;
  291.           case 'B':    /* double/even */
  292.           case 'R':    /* quad/multiple of 4 */
  293.             fregx (insn.rs2);
  294.             break;
  295.  
  296.           case 'g':
  297.             freg (insn.rd);
  298.             break;
  299.           case 'H':    /* double/even */
  300.           case 'J':    /* quad/multiple of 4 */
  301.             fregx (insn.rd);
  302.             break;
  303. #undef    freg
  304. #undef    fregx
  305.  
  306. #define    creg(n)    (*info->fprintf_func) (stream, "%%c%u", (unsigned int) (n))
  307.           case 'b':
  308.             creg (insn.rs1);
  309.             break;
  310.  
  311.           case 'c':
  312.             creg (insn.rs2);
  313.             break;
  314.  
  315.           case 'D':
  316.             creg (insn.rd);
  317.             break;
  318. #undef    creg
  319.  
  320.           case 'h':
  321.             (*info->fprintf_func) (stream, "%%hi(%#x)",
  322.                        0xFFFFFFFF & (int) insn.imm22 << 10);
  323.             break;
  324.  
  325.           case 'i':
  326.             {
  327.               /* We cannot trust the compiler to sign-extend
  328.              when extracting the bitfield, hence the shifts.  */
  329.               int imm = SEX (insn.imm13, 13);
  330.  
  331.               /* Check to see whether we have a 1+i, and take
  332.              note of that fact.
  333.  
  334.              Note: because of the way we sort the table,
  335.              we will be matching 1+i rather than i+1,
  336.              so it is OK to assume that i is after +,
  337.              not before it.  */
  338.               if (found_plus)
  339.             imm_added_to_rs1 = 1;
  340.               
  341.               if (imm <= 9)
  342.             (*info->fprintf_func) (stream, "%d", imm);
  343.               else
  344.             (*info->fprintf_func) (stream, "%#x", imm);
  345.             }
  346.             break;
  347.  
  348. #ifndef NO_V9
  349.           case 'I':    /* 11 bit immediate.  */
  350.           case 'j':    /* 10 bit immediate.  */
  351.             {
  352.               /* We cannot trust the compiler to sign-extend
  353.              when extracting the bitfield, hence the shifts.  */
  354.               int imm;
  355.  
  356.               if (*s == 'I')
  357.             imm = SEX (insn.imm13, 11);
  358.               else
  359.             imm = SEX (insn.imm13, 10);
  360.  
  361.               /* Check to see whether we have a 1+i, and take
  362.              note of that fact.
  363.              
  364.              Note: because of the way we sort the table,
  365.              we will be matching 1+i rather than i+1,
  366.              so it is OK to assume that i is after +,
  367.              not before it.  */
  368.               if (found_plus)
  369.             imm_added_to_rs1 = 1;
  370.               
  371.               if (imm <= 9)
  372.             (info->fprintf_func) (stream, "%d", imm);
  373.               else
  374.             (info->fprintf_func) (stream, "%#x", (unsigned) imm);
  375.             }
  376.             break;
  377.  
  378.           case 'k':
  379.             info->target = memaddr + (SEX (disp16 (insn), 16)) * 4;
  380.             (*info->print_address_func) (info->target, info);
  381.             break;
  382.  
  383.           case 'G':
  384.             info->target = memaddr + (SEX (insn.disp22, 19)) * 4;
  385.             (*info->print_address_func) (info->target, info);
  386.             break;
  387.  
  388.           case '6':
  389.           case '7':
  390.           case '8':
  391.           case '9':
  392.             (*info->fprintf_func) (stream, "%%fcc%c", *s - '6' + '0');
  393.             break;
  394.  
  395.           case 'z':
  396.             (*info->fprintf_func) (stream, "%%icc");
  397.             break;
  398.  
  399.           case 'Z':
  400.             (*info->fprintf_func) (stream, "%%xcc");
  401.             break;
  402.  
  403.           case 'E':
  404.             (*info->fprintf_func) (stream, "%%ccr");
  405.             break;
  406.  
  407.           case 's':
  408.             (*info->fprintf_func) (stream, "%%fprs");
  409.             break;
  410.  
  411.           case 'o':
  412.             (*info->fprintf_func) (stream, "%%asi");
  413.             break;
  414.  
  415.           case 'W':
  416.             (*info->fprintf_func) (stream, "%%tick");
  417.             break;
  418.  
  419.           case 'P':
  420.             (*info->fprintf_func) (stream, "%%pc");
  421.             break;
  422.  
  423.           case '?':
  424.             if (insn.rs1 == 31)
  425.               (*info->fprintf_func) (stream, "%%ver");
  426.             else if ((unsigned) insn.rs1 < 16)
  427.               (*info->fprintf_func) (stream, "%%%s", v9_priv_reg_names[insn.rs1]);
  428.             else
  429.               (*info->fprintf_func) (stream, "%%reserved");
  430.             break;
  431.  
  432.           case '!':
  433.             if ((unsigned) insn.rd < 15)
  434.               (*info->fprintf_func) (stream, "%%%s", v9_priv_reg_names[insn.rd]);
  435.             else
  436.               (*info->fprintf_func) (stream, "%%reserved");
  437.             break;
  438.             break;
  439. #endif    /* NO_V9 */
  440.  
  441.           case 'M':
  442.             (*info->fprintf_func) (stream, "%%asr%d", insn.rs1);
  443.             break;
  444.             
  445.           case 'm':
  446.             (*info->fprintf_func) (stream, "%%asr%d", insn.rd);
  447.             break;
  448.             
  449.           case 'L':
  450.             info->target = memaddr + insn.disp30 * 4;
  451.             (*info->print_address_func) (info->target, info);
  452.             break;
  453.  
  454.           case 'n':
  455.             (*info->fprintf_func)
  456.               (stream, "%#x", (SEX (insn.disp22, 22)));
  457.             break;
  458.  
  459.           case 'l':
  460.             info->target = memaddr + (SEX (insn.disp22, 22)) * 4;
  461.             (*info->print_address_func) (info->target, info);
  462.             break;
  463.  
  464.           case 'A':
  465.             (*info->fprintf_func) (stream, "(%d)", (int) insn.asi);
  466.             break;
  467.  
  468.           case 'C':
  469.             (*info->fprintf_func) (stream, "%%csr");
  470.             break;
  471.  
  472.           case 'F':
  473.             (*info->fprintf_func) (stream, "%%fsr");
  474.             break;
  475.  
  476.           case 'p':
  477.             (*info->fprintf_func) (stream, "%%psr");
  478.             break;
  479.  
  480.           case 'q':
  481.             (*info->fprintf_func) (stream, "%%fq");
  482.             break;
  483.  
  484.           case 'Q':
  485.             (*info->fprintf_func) (stream, "%%cq");
  486.             break;
  487.  
  488.           case 't':
  489.             (*info->fprintf_func) (stream, "%%tbr");
  490.             break;
  491.  
  492.           case 'w':
  493.             (*info->fprintf_func) (stream, "%%wim");
  494.             break;
  495.  
  496.           case 'y':
  497.             (*info->fprintf_func) (stream, "%%y");
  498.             break;
  499.           }
  500.           }
  501.       }
  502.  
  503.       /* If we are adding or or'ing something to rs1, then
  504.          check to see whether the previous instruction was
  505.          a sethi to the same register as in the sethi.
  506.          If so, attempt to print the result of the add or
  507.          or (in this context add and or do the same thing)
  508.          and its symbolic value.  */
  509.       if (imm_added_to_rs1)
  510.         {
  511.           union sparc_insn prev_insn;
  512.           int errcode;
  513.  
  514.           errcode =
  515.         (*info->read_memory_func)
  516.           (memaddr - 4,
  517.            (bfd_byte *)&prev_insn, sizeof (prev_insn), info);
  518.  
  519.           if (errcode == 0)
  520.         {
  521.           /* If it is a delayed branch, we need to look at the
  522.              instruction before the delayed branch.  This handles
  523.              sequences such as
  524.  
  525.              sethi %o1, %hi(_foo), %o1
  526.              call _printf
  527.              or %o1, %lo(_foo), %o1
  528.              */
  529.  
  530.           if (is_delayed_branch (prev_insn))
  531.             errcode = (*info->read_memory_func)
  532.               (memaddr - 8, (bfd_byte *)&prev_insn, sizeof (prev_insn),
  533.                info);
  534.         }
  535.  
  536.           /* If there was a problem reading memory, then assume
  537.          the previous instruction was not sethi.  */
  538.           if (errcode == 0)
  539.         {
  540.           /* Is it sethi to the same register?  */
  541.           if ((prev_insn.code & 0xc1c00000) == 0x01000000
  542.               && prev_insn.rd == insn.rs1)
  543.             {
  544.               (*info->fprintf_func) (stream, "\t! ");
  545.               info->target = 
  546.             (0xFFFFFFFF & (int) prev_insn.imm22 << 10)
  547.             | SEX (insn.imm13, 13);
  548.               (*info->print_address_func) (info->target, info);
  549.               info->insn_type = dis_dref;
  550.               info->data_size = 4;  /* FIXME!!! */
  551.             }
  552.         }
  553.         }
  554.  
  555.       if (opcode->flags & (F_UNBR|F_CONDBR|F_JSR))
  556.         {
  557.         /* FIXME -- check is_annulled flag */
  558.           if (opcode->flags & F_UNBR)
  559.         info->insn_type = dis_branch;
  560.           if (opcode->flags & F_CONDBR)
  561.         info->insn_type = dis_condbranch;
  562.           if (opcode->flags & F_JSR)
  563.         info->insn_type = dis_jsr;
  564.           if (opcode->flags & F_DELAYED)
  565.         info->branch_delay_insns = 1;
  566.         }
  567.  
  568.       return sizeof (insn);
  569.     }
  570.     }
  571.  
  572.   info->insn_type = dis_noninsn;    /* Mark as non-valid instruction */
  573.   (*info->fprintf_func) (stream, "%#8x", insn.code);
  574.   return sizeof (insn);
  575. }
  576.  
  577. /* Compare opcodes A and B.  */
  578.  
  579. static int
  580. compare_opcodes (a, b)
  581.      char *a, *b;
  582. {
  583.   struct sparc_opcode *op0 = (struct sparc_opcode *) a;
  584.   struct sparc_opcode *op1 = (struct sparc_opcode *) b;
  585.   unsigned long int match0 = op0->match, match1 = op1->match;
  586.   unsigned long int lose0 = op0->lose, lose1 = op1->lose;
  587.   register unsigned int i;
  588.  
  589.   /* If a bit is set in both match and lose, there is something
  590.      wrong with the opcode table.  */
  591.   if (match0 & lose0)
  592.     {
  593.       fprintf (stderr, "Internal error:  bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n",
  594.            op0->name, match0, lose0);
  595.       op0->lose &= ~op0->match;
  596.       lose0 = op0->lose;
  597.     }
  598.  
  599.   if (match1 & lose1)
  600.     {
  601.       fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n",
  602.            op1->name, match1, lose1);
  603.       op1->lose &= ~op1->match;
  604.       lose1 = op1->lose;
  605.     }
  606.  
  607.   /* Because the bits that are variable in one opcode are constant in
  608.      another, it is important to order the opcodes in the right order.  */
  609.   for (i = 0; i < 32; ++i)
  610.     {
  611.       unsigned long int x = 1 << i;
  612.       int x0 = (match0 & x) != 0;
  613.       int x1 = (match1 & x) != 0;
  614.  
  615.       if (x0 != x1)
  616.     return x1 - x0;
  617.     }
  618.  
  619.   for (i = 0; i < 32; ++i)
  620.     {
  621.       unsigned long int x = 1 << i;
  622.       int x0 = (lose0 & x) != 0;
  623.       int x1 = (lose1 & x) != 0;
  624.  
  625.       if (x0 != x1)
  626.     return x1 - x0;
  627.     }
  628.  
  629.   /* They are functionally equal.  So as long as the opcode table is
  630.      valid, we can put whichever one first we want, on aesthetic grounds.  */
  631.  
  632.   /* Our first aesthetic ground is that aliases defer to real insns.  */
  633.   {
  634.     int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS);
  635.     if (alias_diff != 0)
  636.       /* Put the one that isn't an alias first.  */
  637.       return alias_diff;
  638.   }
  639.  
  640.   /* Except for aliases, two "identical" instructions had
  641.      better have the same opcode.  This is a sanity check on the table.  */
  642.   i = strcmp (op0->name, op1->name);
  643.   if (i)
  644.       if (op0->flags & F_ALIAS) /* If they're both aliases, be arbitrary. */
  645.       return i;
  646.       else
  647.       fprintf (stderr,
  648.            "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n",
  649.            op0->name, op1->name);
  650.  
  651.   /* Fewer arguments are preferred.  */
  652.   {
  653.     int length_diff = strlen (op0->args) - strlen (op1->args);
  654.     if (length_diff != 0)
  655.       /* Put the one with fewer arguments first.  */
  656.       return length_diff;
  657.   }
  658.  
  659.   /* Put 1+i before i+1.  */
  660.   {
  661.     char *p0 = (char *) strchr(op0->args, '+');
  662.     char *p1 = (char *) strchr(op1->args, '+');
  663.  
  664.     if (p0 && p1)
  665.       {
  666.     /* There is a plus in both operands.  Note that a plus
  667.        sign cannot be the first character in args,
  668.        so the following [-1]'s are valid.  */
  669.     if (p0[-1] == 'i' && p1[1] == 'i')
  670.       /* op0 is i+1 and op1 is 1+i, so op1 goes first.  */
  671.       return 1;
  672.     if (p0[1] == 'i' && p1[-1] == 'i')
  673.       /* op0 is 1+i and op1 is i+1, so op0 goes first.  */
  674.       return -1;
  675.       }
  676.   }
  677.  
  678.   /* They are, as far as we can tell, identical.
  679.      Since qsort may have rearranged the table partially, there is
  680.      no way to tell which one was first in the opcode table as
  681.      written, so just say there are equal.  */
  682.   return 0;
  683. }
  684.