Back to index

cell-binutils  2.17cvs20070401
expr.c
Go to the documentation of this file.
00001 /* expr.c -operands, expressions-
00002    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
00003    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
00004    Free Software Foundation, Inc.
00005 
00006    This file is part of GAS, the GNU Assembler.
00007 
00008    GAS is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2, or (at your option)
00011    any later version.
00012 
00013    GAS is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with GAS; see the file COPYING.  If not, write to the Free
00020    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00021    02110-1301, USA.  */
00022 
00023 /* This is really a branch office of as-read.c. I split it out to clearly
00024    distinguish the world of expressions from the world of statements.
00025    (It also gives smaller files to re-compile.)
00026    Here, "operand"s are of expressions, not instructions.  */
00027 
00028 #define min(a, b)       ((a) < (b) ? (a) : (b))
00029 
00030 #include "as.h"
00031 #include "safe-ctype.h"
00032 #include "obstack.h"
00033 
00034 static void floating_constant (expressionS * expressionP);
00035 static valueT generic_bignum_to_int32 (void);
00036 #ifdef BFD64
00037 static valueT generic_bignum_to_int64 (void);
00038 #endif
00039 static void integer_constant (int radix, expressionS * expressionP);
00040 static void mri_char_constant (expressionS *);
00041 static void current_location (expressionS *);
00042 static void clean_up_expression (expressionS * expressionP);
00043 static segT operand (expressionS *, enum expr_mode);
00044 static operatorT operator (int *);
00045 
00046 extern const char EXP_CHARS[], FLT_CHARS[];
00047 
00048 /* We keep a mapping of expression symbols to file positions, so that
00049    we can provide better error messages.  */
00050 
00051 struct expr_symbol_line {
00052   struct expr_symbol_line *next;
00053   symbolS *sym;
00054   char *file;
00055   unsigned int line;
00056 };
00057 
00058 static struct expr_symbol_line *expr_symbol_lines;
00059 
00060 /* Build a dummy symbol to hold a complex expression.  This is how we
00061    build expressions up out of other expressions.  The symbol is put
00062    into the fake section expr_section.  */
00063 
00064 symbolS *
00065 make_expr_symbol (expressionS *expressionP)
00066 {
00067   expressionS zero;
00068   symbolS *symbolP;
00069   struct expr_symbol_line *n;
00070 
00071   if (expressionP->X_op == O_symbol
00072       && expressionP->X_add_number == 0)
00073     return expressionP->X_add_symbol;
00074 
00075   if (expressionP->X_op == O_big)
00076     {
00077       /* This won't work, because the actual value is stored in
00078         generic_floating_point_number or generic_bignum, and we are
00079         going to lose it if we haven't already.  */
00080       if (expressionP->X_add_number > 0)
00081        as_bad (_("bignum invalid"));
00082       else
00083        as_bad (_("floating point number invalid"));
00084       zero.X_op = O_constant;
00085       zero.X_add_number = 0;
00086       zero.X_unsigned = 0;
00087       clean_up_expression (&zero);
00088       expressionP = &zero;
00089     }
00090 
00091   /* Putting constant symbols in absolute_section rather than
00092      expr_section is convenient for the old a.out code, for which
00093      S_GET_SEGMENT does not always retrieve the value put in by
00094      S_SET_SEGMENT.  */
00095   symbolP = symbol_create (FAKE_LABEL_NAME,
00096                         (expressionP->X_op == O_constant
00097                          ? absolute_section
00098                          : expr_section),
00099                         0, &zero_address_frag);
00100   symbol_set_value_expression (symbolP, expressionP);
00101 
00102   if (expressionP->X_op == O_constant)
00103     resolve_symbol_value (symbolP);
00104 
00105   n = (struct expr_symbol_line *) xmalloc (sizeof *n);
00106   n->sym = symbolP;
00107   as_where (&n->file, &n->line);
00108   n->next = expr_symbol_lines;
00109   expr_symbol_lines = n;
00110 
00111   return symbolP;
00112 }
00113 
00114 /* Return the file and line number for an expr symbol.  Return
00115    non-zero if something was found, 0 if no information is known for
00116    the symbol.  */
00117 
00118 int
00119 expr_symbol_where (symbolS *sym, char **pfile, unsigned int *pline)
00120 {
00121   register struct expr_symbol_line *l;
00122 
00123   for (l = expr_symbol_lines; l != NULL; l = l->next)
00124     {
00125       if (l->sym == sym)
00126        {
00127          *pfile = l->file;
00128          *pline = l->line;
00129          return 1;
00130        }
00131     }
00132 
00133   return 0;
00134 }
00135 
00136 /* Utilities for building expressions.
00137    Since complex expressions are recorded as symbols for use in other
00138    expressions these return a symbolS * and not an expressionS *.
00139    These explicitly do not take an "add_number" argument.  */
00140 /* ??? For completeness' sake one might want expr_build_symbol.
00141    It would just return its argument.  */
00142 
00143 /* Build an expression for an unsigned constant.
00144    The corresponding one for signed constants is missing because
00145    there's currently no need for it.  One could add an unsigned_p flag
00146    but that seems more clumsy.  */
00147 
00148 symbolS *
00149 expr_build_uconstant (offsetT value)
00150 {
00151   expressionS e;
00152 
00153   e.X_op = O_constant;
00154   e.X_add_number = value;
00155   e.X_unsigned = 1;
00156   return make_expr_symbol (&e);
00157 }
00158 
00159 /* Build an expression for the current location ('.').  */
00160 
00161 symbolS *
00162 expr_build_dot (void)
00163 {
00164   expressionS e;
00165 
00166   current_location (&e);
00167   return make_expr_symbol (&e);
00168 }
00169 
00170 /* Build any floating-point literal here.
00171    Also build any bignum literal here.  */
00172 
00173 /* Seems atof_machine can backscan through generic_bignum and hit whatever
00174    happens to be loaded before it in memory.  And its way too complicated
00175    for me to fix right.  Thus a hack.  JF:  Just make generic_bignum bigger,
00176    and never write into the early words, thus they'll always be zero.
00177    I hate Dean's floating-point code.  Bleh.  */
00178 LITTLENUM_TYPE generic_bignum[SIZE_OF_LARGE_NUMBER + 6];
00179 
00180 FLONUM_TYPE generic_floating_point_number = {
00181   &generic_bignum[6],              /* low.  (JF: Was 0)  */
00182   &generic_bignum[SIZE_OF_LARGE_NUMBER + 6 - 1], /* high.  JF: (added +6)  */
00183   0,                        /* leader.  */
00184   0,                        /* exponent.  */
00185   0                         /* sign.  */
00186 };
00187 
00188 
00189 static void
00190 floating_constant (expressionS *expressionP)
00191 {
00192   /* input_line_pointer -> floating-point constant.  */
00193   int error_code;
00194 
00195   error_code = atof_generic (&input_line_pointer, ".", EXP_CHARS,
00196                           &generic_floating_point_number);
00197 
00198   if (error_code)
00199     {
00200       if (error_code == ERROR_EXPONENT_OVERFLOW)
00201        {
00202          as_bad (_("bad floating-point constant: exponent overflow"));
00203        }
00204       else
00205        {
00206          as_bad (_("bad floating-point constant: unknown error code=%d"),
00207                 error_code);
00208        }
00209     }
00210   expressionP->X_op = O_big;
00211   /* input_line_pointer -> just after constant, which may point to
00212      whitespace.  */
00213   expressionP->X_add_number = -1;
00214 }
00215 
00216 static valueT
00217 generic_bignum_to_int32 (void)
00218 {
00219   valueT number =
00220           ((generic_bignum[1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
00221           | (generic_bignum[0] & LITTLENUM_MASK);
00222   number &= 0xffffffff;
00223   return number;
00224 }
00225 
00226 #ifdef BFD64
00227 static valueT
00228 generic_bignum_to_int64 (void)
00229 {
00230   valueT number =
00231     ((((((((valueT) generic_bignum[3] & LITTLENUM_MASK)
00232          << LITTLENUM_NUMBER_OF_BITS)
00233         | ((valueT) generic_bignum[2] & LITTLENUM_MASK))
00234        << LITTLENUM_NUMBER_OF_BITS)
00235        | ((valueT) generic_bignum[1] & LITTLENUM_MASK))
00236       << LITTLENUM_NUMBER_OF_BITS)
00237      | ((valueT) generic_bignum[0] & LITTLENUM_MASK));
00238   return number;
00239 }
00240 #endif
00241 
00242 static void
00243 integer_constant (int radix, expressionS *expressionP)
00244 {
00245   char *start;              /* Start of number.  */
00246   char *suffix = NULL;
00247   char c;
00248   valueT number;     /* Offset or (absolute) value.  */
00249   short int digit;   /* Value of next digit in current radix.  */
00250   short int maxdig = 0;     /* Highest permitted digit value.  */
00251   int too_many_digits = 0;  /* If we see >= this number of.  */
00252   char *name;        /* Points to name of symbol.  */
00253   symbolS *symbolP;  /* Points to symbol.  */
00254 
00255   int small;                /* True if fits in 32 bits.  */
00256 
00257   /* May be bignum, or may fit in 32 bits.  */
00258   /* Most numbers fit into 32 bits, and we want this case to be fast.
00259      so we pretend it will fit into 32 bits.  If, after making up a 32
00260      bit number, we realise that we have scanned more digits than
00261      comfortably fit into 32 bits, we re-scan the digits coding them
00262      into a bignum.  For decimal and octal numbers we are
00263      conservative: Some numbers may be assumed bignums when in fact
00264      they do fit into 32 bits.  Numbers of any radix can have excess
00265      leading zeros: We strive to recognise this and cast them back
00266      into 32 bits.  We must check that the bignum really is more than
00267      32 bits, and change it back to a 32-bit number if it fits.  The
00268      number we are looking for is expected to be positive, but if it
00269      fits into 32 bits as an unsigned number, we let it be a 32-bit
00270      number.  The cavalier approach is for speed in ordinary cases.  */
00271   /* This has been extended for 64 bits.  We blindly assume that if
00272      you're compiling in 64-bit mode, the target is a 64-bit machine.
00273      This should be cleaned up.  */
00274 
00275 #ifdef BFD64
00276 #define valuesize 64
00277 #else /* includes non-bfd case, mostly */
00278 #define valuesize 32
00279 #endif
00280 
00281   if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) && radix == 0)
00282     {
00283       int flt = 0;
00284 
00285       /* In MRI mode, the number may have a suffix indicating the
00286         radix.  For that matter, it might actually be a floating
00287         point constant.  */
00288       for (suffix = input_line_pointer; ISALNUM (*suffix); suffix++)
00289        {
00290          if (*suffix == 'e' || *suffix == 'E')
00291            flt = 1;
00292        }
00293 
00294       if (suffix == input_line_pointer)
00295        {
00296          radix = 10;
00297          suffix = NULL;
00298        }
00299       else
00300        {
00301          c = *--suffix;
00302          c = TOUPPER (c);
00303          /* If we have both NUMBERS_WITH_SUFFIX and LOCAL_LABELS_FB,
00304             we distinguish between 'B' and 'b'.  This is the case for
00305             Z80.  */
00306          if ((NUMBERS_WITH_SUFFIX && LOCAL_LABELS_FB ? *suffix : c) == 'B')
00307            radix = 2;
00308          else if (c == 'D')
00309            radix = 10;
00310          else if (c == 'O' || c == 'Q')
00311            radix = 8;
00312          else if (c == 'H')
00313            radix = 16;
00314          else if (suffix[1] == '.' || c == 'E' || flt)
00315            {
00316              floating_constant (expressionP);
00317              return;
00318            }
00319          else
00320            {
00321              radix = 10;
00322              suffix = NULL;
00323            }
00324        }
00325     }
00326 
00327   switch (radix)
00328     {
00329     case 2:
00330       maxdig = 2;
00331       too_many_digits = valuesize + 1;
00332       break;
00333     case 8:
00334       maxdig = radix = 8;
00335       too_many_digits = (valuesize + 2) / 3 + 1;
00336       break;
00337     case 16:
00338       maxdig = radix = 16;
00339       too_many_digits = (valuesize + 3) / 4 + 1;
00340       break;
00341     case 10:
00342       maxdig = radix = 10;
00343       too_many_digits = (valuesize + 11) / 4; /* Very rough.  */
00344     }
00345 #undef valuesize
00346   start = input_line_pointer;
00347   c = *input_line_pointer++;
00348   for (number = 0;
00349        (digit = hex_value (c)) < maxdig;
00350        c = *input_line_pointer++)
00351     {
00352       number = number * radix + digit;
00353     }
00354   /* c contains character after number.  */
00355   /* input_line_pointer->char after c.  */
00356   small = (input_line_pointer - start - 1) < too_many_digits;
00357 
00358   if (radix == 16 && c == '_')
00359     {
00360       /* This is literal of the form 0x333_0_12345678_1.
00361         This example is equivalent to 0x00000333000000001234567800000001.  */
00362 
00363       int num_little_digits = 0;
00364       int i;
00365       input_line_pointer = start;  /* -> 1st digit.  */
00366 
00367       know (LITTLENUM_NUMBER_OF_BITS == 16);
00368 
00369       for (c = '_'; c == '_'; num_little_digits += 2)
00370        {
00371 
00372          /* Convert one 64-bit word.  */
00373          int ndigit = 0;
00374          number = 0;
00375          for (c = *input_line_pointer++;
00376               (digit = hex_value (c)) < maxdig;
00377               c = *(input_line_pointer++))
00378            {
00379              number = number * radix + digit;
00380              ndigit++;
00381            }
00382 
00383          /* Check for 8 digit per word max.  */
00384          if (ndigit > 8)
00385            as_bad (_("a bignum with underscores may not have more than 8 hex digits in any word"));
00386 
00387          /* Add this chunk to the bignum.
00388             Shift things down 2 little digits.  */
00389          know (LITTLENUM_NUMBER_OF_BITS == 16);
00390          for (i = min (num_little_digits + 1, SIZE_OF_LARGE_NUMBER - 1);
00391               i >= 2;
00392               i--)
00393            generic_bignum[i] = generic_bignum[i - 2];
00394 
00395          /* Add the new digits as the least significant new ones.  */
00396          generic_bignum[0] = number & 0xffffffff;
00397          generic_bignum[1] = number >> 16;
00398        }
00399 
00400       /* Again, c is char after number, input_line_pointer->after c.  */
00401 
00402       if (num_little_digits > SIZE_OF_LARGE_NUMBER - 1)
00403        num_little_digits = SIZE_OF_LARGE_NUMBER - 1;
00404 
00405       assert (num_little_digits >= 4);
00406 
00407       if (num_little_digits != 8)
00408        as_bad (_("a bignum with underscores must have exactly 4 words"));
00409 
00410       /* We might have some leading zeros.  These can be trimmed to give
00411         us a change to fit this constant into a small number.  */
00412       while (generic_bignum[num_little_digits - 1] == 0
00413             && num_little_digits > 1)
00414        num_little_digits--;
00415 
00416       if (num_little_digits <= 2)
00417        {
00418          /* will fit into 32 bits.  */
00419          number = generic_bignum_to_int32 ();
00420          small = 1;
00421        }
00422 #ifdef BFD64
00423       else if (num_little_digits <= 4)
00424        {
00425          /* Will fit into 64 bits.  */
00426          number = generic_bignum_to_int64 ();
00427          small = 1;
00428        }
00429 #endif
00430       else
00431        {
00432          small = 0;
00433 
00434          /* Number of littlenums in the bignum.  */
00435          number = num_little_digits;
00436        }
00437     }
00438   else if (!small)
00439     {
00440       /* We saw a lot of digits. manufacture a bignum the hard way.  */
00441       LITTLENUM_TYPE *leader;      /* -> high order littlenum of the bignum.  */
00442       LITTLENUM_TYPE *pointer;     /* -> littlenum we are frobbing now.  */
00443       long carry;
00444 
00445       leader = generic_bignum;
00446       generic_bignum[0] = 0;
00447       generic_bignum[1] = 0;
00448       generic_bignum[2] = 0;
00449       generic_bignum[3] = 0;
00450       input_line_pointer = start;  /* -> 1st digit.  */
00451       c = *input_line_pointer++;
00452       for (; (carry = hex_value (c)) < maxdig; c = *input_line_pointer++)
00453        {
00454          for (pointer = generic_bignum; pointer <= leader; pointer++)
00455            {
00456              long work;
00457 
00458              work = carry + radix * *pointer;
00459              *pointer = work & LITTLENUM_MASK;
00460              carry = work >> LITTLENUM_NUMBER_OF_BITS;
00461            }
00462          if (carry)
00463            {
00464              if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1)
00465               {
00466                 /* Room to grow a longer bignum.  */
00467                 *++leader = carry;
00468               }
00469            }
00470        }
00471       /* Again, c is char after number.  */
00472       /* input_line_pointer -> after c.  */
00473       know (LITTLENUM_NUMBER_OF_BITS == 16);
00474       if (leader < generic_bignum + 2)
00475        {
00476          /* Will fit into 32 bits.  */
00477          number = generic_bignum_to_int32 ();
00478          small = 1;
00479        }
00480 #ifdef BFD64
00481       else if (leader < generic_bignum + 4)
00482        {
00483          /* Will fit into 64 bits.  */
00484          number = generic_bignum_to_int64 ();
00485          small = 1;
00486        }
00487 #endif
00488       else
00489        {
00490          /* Number of littlenums in the bignum.  */
00491          number = leader - generic_bignum + 1;
00492        }
00493     }
00494 
00495   if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
00496       && suffix != NULL
00497       && input_line_pointer - 1 == suffix)
00498     c = *input_line_pointer++;
00499 
00500   if (small)
00501     {
00502       /* Here with number, in correct radix. c is the next char.
00503         Note that unlike un*x, we allow "011f" "0x9f" to both mean
00504         the same as the (conventional) "9f".
00505         This is simply easier than checking for strict canonical
00506         form.  Syntax sux!  */
00507 
00508       if (LOCAL_LABELS_FB && c == 'b')
00509        {
00510          /* Backward ref to local label.
00511             Because it is backward, expect it to be defined.  */
00512          /* Construct a local label.  */
00513          name = fb_label_name ((int) number, 0);
00514 
00515          /* Seen before, or symbol is defined: OK.  */
00516          symbolP = symbol_find (name);
00517          if ((symbolP != NULL) && (S_IS_DEFINED (symbolP)))
00518            {
00519              /* Local labels are never absolute.  Don't waste time
00520                checking absoluteness.  */
00521              know (SEG_NORMAL (S_GET_SEGMENT (symbolP)));
00522 
00523              expressionP->X_op = O_symbol;
00524              expressionP->X_add_symbol = symbolP;
00525            }
00526          else
00527            {
00528              /* Either not seen or not defined.  */
00529              /* @@ Should print out the original string instead of
00530                the parsed number.  */
00531              as_bad (_("backward ref to unknown label \"%d:\""),
00532                     (int) number);
00533              expressionP->X_op = O_constant;
00534            }
00535 
00536          expressionP->X_add_number = 0;
00537        }                    /* case 'b' */
00538       else if (LOCAL_LABELS_FB && c == 'f')
00539        {
00540          /* Forward reference.  Expect symbol to be undefined or
00541             unknown.  undefined: seen it before.  unknown: never seen
00542             it before.
00543 
00544             Construct a local label name, then an undefined symbol.
00545             Don't create a xseg frag for it: caller may do that.
00546             Just return it as never seen before.  */
00547          name = fb_label_name ((int) number, 1);
00548          symbolP = symbol_find_or_make (name);
00549          /* We have no need to check symbol properties.  */
00550 #ifndef many_segments
00551          /* Since "know" puts its arg into a "string", we
00552             can't have newlines in the argument.  */
00553          know (S_GET_SEGMENT (symbolP) == undefined_section || S_GET_SEGMENT (symbolP) == text_section || S_GET_SEGMENT (symbolP) == data_section);
00554 #endif
00555          expressionP->X_op = O_symbol;
00556          expressionP->X_add_symbol = symbolP;
00557          expressionP->X_add_number = 0;
00558        }                    /* case 'f' */
00559       else if (LOCAL_LABELS_DOLLAR && c == '$')
00560        {
00561          /* If the dollar label is *currently* defined, then this is just
00562             another reference to it.  If it is not *currently* defined,
00563             then this is a fresh instantiation of that number, so create
00564             it.  */
00565 
00566          if (dollar_label_defined ((long) number))
00567            {
00568              name = dollar_label_name ((long) number, 0);
00569              symbolP = symbol_find (name);
00570              know (symbolP != NULL);
00571            }
00572          else
00573            {
00574              name = dollar_label_name ((long) number, 1);
00575              symbolP = symbol_find_or_make (name);
00576            }
00577 
00578          expressionP->X_op = O_symbol;
00579          expressionP->X_add_symbol = symbolP;
00580          expressionP->X_add_number = 0;
00581        }                    /* case '$' */
00582       else
00583        {
00584          expressionP->X_op = O_constant;
00585          expressionP->X_add_number = number;
00586          input_line_pointer--;     /* Restore following character.  */
00587        }                    /* Really just a number.  */
00588     }
00589   else
00590     {
00591       /* Not a small number.  */
00592       expressionP->X_op = O_big;
00593       expressionP->X_add_number = number; /* Number of littlenums.  */
00594       input_line_pointer--; /* -> char following number.  */
00595     }
00596 }
00597 
00598 /* Parse an MRI multi character constant.  */
00599 
00600 static void
00601 mri_char_constant (expressionS *expressionP)
00602 {
00603   int i;
00604 
00605   if (*input_line_pointer == '\''
00606       && input_line_pointer[1] != '\'')
00607     {
00608       expressionP->X_op = O_constant;
00609       expressionP->X_add_number = 0;
00610       return;
00611     }
00612 
00613   /* In order to get the correct byte ordering, we must build the
00614      number in reverse.  */
00615   for (i = SIZE_OF_LARGE_NUMBER - 1; i >= 0; i--)
00616     {
00617       int j;
00618 
00619       generic_bignum[i] = 0;
00620       for (j = 0; j < CHARS_PER_LITTLENUM; j++)
00621        {
00622          if (*input_line_pointer == '\'')
00623            {
00624              if (input_line_pointer[1] != '\'')
00625               break;
00626              ++input_line_pointer;
00627            }
00628          generic_bignum[i] <<= 8;
00629          generic_bignum[i] += *input_line_pointer;
00630          ++input_line_pointer;
00631        }
00632 
00633       if (i < SIZE_OF_LARGE_NUMBER - 1)
00634        {
00635          /* If there is more than one littlenum, left justify the
00636             last one to make it match the earlier ones.  If there is
00637             only one, we can just use the value directly.  */
00638          for (; j < CHARS_PER_LITTLENUM; j++)
00639            generic_bignum[i] <<= 8;
00640        }
00641 
00642       if (*input_line_pointer == '\''
00643          && input_line_pointer[1] != '\'')
00644        break;
00645     }
00646 
00647   if (i < 0)
00648     {
00649       as_bad (_("character constant too large"));
00650       i = 0;
00651     }
00652 
00653   if (i > 0)
00654     {
00655       int c;
00656       int j;
00657 
00658       c = SIZE_OF_LARGE_NUMBER - i;
00659       for (j = 0; j < c; j++)
00660        generic_bignum[j] = generic_bignum[i + j];
00661       i = c;
00662     }
00663 
00664   know (LITTLENUM_NUMBER_OF_BITS == 16);
00665   if (i > 2)
00666     {
00667       expressionP->X_op = O_big;
00668       expressionP->X_add_number = i;
00669     }
00670   else
00671     {
00672       expressionP->X_op = O_constant;
00673       if (i < 2)
00674        expressionP->X_add_number = generic_bignum[0] & LITTLENUM_MASK;
00675       else
00676        expressionP->X_add_number =
00677          (((generic_bignum[1] & LITTLENUM_MASK)
00678            << LITTLENUM_NUMBER_OF_BITS)
00679           | (generic_bignum[0] & LITTLENUM_MASK));
00680     }
00681 
00682   /* Skip the final closing quote.  */
00683   ++input_line_pointer;
00684 }
00685 
00686 /* Return an expression representing the current location.  This
00687    handles the magic symbol `.'.  */
00688 
00689 static void
00690 current_location (expressionS *expressionp)
00691 {
00692   if (now_seg == absolute_section)
00693     {
00694       expressionp->X_op = O_constant;
00695       expressionp->X_add_number = abs_section_offset;
00696     }
00697   else
00698     {
00699       expressionp->X_op = O_symbol;
00700       expressionp->X_add_symbol = symbol_temp_new_now ();
00701       expressionp->X_add_number = 0;
00702     }
00703 }
00704 
00705 /* In: Input_line_pointer points to 1st char of operand, which may
00706        be a space.
00707 
00708    Out:       An expressionS.
00709        The operand may have been empty: in this case X_op == O_absent.
00710        Input_line_pointer->(next non-blank) char after operand.  */
00711 
00712 static segT
00713 operand (expressionS *expressionP, enum expr_mode mode)
00714 {
00715   char c;
00716   symbolS *symbolP;  /* Points to symbol.  */
00717   char *name;        /* Points to name of symbol.  */
00718   segT segment;
00719 
00720   /* All integers are regarded as unsigned unless they are negated.
00721      This is because the only thing which cares whether a number is
00722      unsigned is the code in emit_expr which extends constants into
00723      bignums.  It should only sign extend negative numbers, so that
00724      something like ``.quad 0x80000000'' is not sign extended even
00725      though it appears negative if valueT is 32 bits.  */
00726   expressionP->X_unsigned = 1;
00727 
00728   /* Digits, assume it is a bignum.  */
00729 
00730   SKIP_WHITESPACE ();              /* Leading whitespace is part of operand.  */
00731   c = *input_line_pointer++;       /* input_line_pointer -> past char in c.  */
00732 
00733   if (is_end_of_line[(unsigned char) c])
00734     goto eol;
00735 
00736   switch (c)
00737     {
00738     case '1':
00739     case '2':
00740     case '3':
00741     case '4':
00742     case '5':
00743     case '6':
00744     case '7':
00745     case '8':
00746     case '9':
00747       input_line_pointer--;
00748 
00749       integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
00750                      ? 0 : 10,
00751                      expressionP);
00752       break;
00753 
00754 #ifdef LITERAL_PREFIXDOLLAR_HEX
00755     case '$':
00756       /* $L is the start of a local label, not a hex constant.  */
00757       if (* input_line_pointer == 'L')
00758       goto isname;
00759       integer_constant (16, expressionP);
00760       break;
00761 #endif
00762 
00763 #ifdef LITERAL_PREFIXPERCENT_BIN
00764     case '%':
00765       integer_constant (2, expressionP);
00766       break;
00767 #endif
00768 
00769     case '0':
00770       /* Non-decimal radix.  */
00771 
00772       if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
00773        {
00774          char *s;
00775 
00776          /* Check for a hex or float constant.  */
00777          for (s = input_line_pointer; hex_p (*s); s++)
00778            ;
00779          if (*s == 'h' || *s == 'H' || *input_line_pointer == '.')
00780            {
00781              --input_line_pointer;
00782              integer_constant (0, expressionP);
00783              break;
00784            }
00785        }
00786       c = *input_line_pointer;
00787       switch (c)
00788        {
00789        case 'o':
00790        case 'O':
00791        case 'q':
00792        case 'Q':
00793        case '8':
00794        case '9':
00795          if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
00796            {
00797              integer_constant (0, expressionP);
00798              break;
00799            }
00800          /* Fall through.  */
00801        default:
00802        default_case:
00803          if (c && strchr (FLT_CHARS, c))
00804            {
00805              input_line_pointer++;
00806              floating_constant (expressionP);
00807              expressionP->X_add_number = - TOLOWER (c);
00808            }
00809          else
00810            {
00811              /* The string was only zero.  */
00812              expressionP->X_op = O_constant;
00813              expressionP->X_add_number = 0;
00814            }
00815 
00816          break;
00817 
00818        case 'x':
00819        case 'X':
00820          if (flag_m68k_mri)
00821            goto default_case;
00822          input_line_pointer++;
00823          integer_constant (16, expressionP);
00824          break;
00825 
00826        case 'b':
00827          if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX))
00828            {
00829              /* This code used to check for '+' and '-' here, and, in
00830                some conditions, fall through to call
00831                integer_constant.  However, that didn't make sense,
00832                as integer_constant only accepts digits.  */
00833              /* Some of our code elsewhere does permit digits greater
00834                than the expected base; for consistency, do the same
00835                here.  */
00836              if (input_line_pointer[1] < '0'
00837                 || input_line_pointer[1] > '9')
00838               {
00839                 /* Parse this as a back reference to label 0.  */
00840                 input_line_pointer--;
00841                 integer_constant (10, expressionP);
00842                 break;
00843               }
00844              /* Otherwise, parse this as a binary number.  */
00845            }
00846          /* Fall through.  */
00847        case 'B':
00848          input_line_pointer++;
00849          if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
00850            goto default_case;
00851          integer_constant (2, expressionP);
00852          break;
00853 
00854        case '0':
00855        case '1':
00856        case '2':
00857        case '3':
00858        case '4':
00859        case '5':
00860        case '6':
00861        case '7':
00862          integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX)
00863                          ? 0 : 8,
00864                          expressionP);
00865          break;
00866 
00867        case 'f':
00868          if (LOCAL_LABELS_FB)
00869            {
00870              /* If it says "0f" and it could possibly be a floating point
00871                number, make it one.  Otherwise, make it a local label,
00872                and try to deal with parsing the rest later.  */
00873              if (!input_line_pointer[1]
00874                 || (is_end_of_line[0xff & input_line_pointer[1]])
00875                 || strchr (FLT_CHARS, 'f') == NULL)
00876               goto is_0f_label;
00877              {
00878               char *cp = input_line_pointer + 1;
00879               int r = atof_generic (&cp, ".", EXP_CHARS,
00880                                   &generic_floating_point_number);
00881               switch (r)
00882                 {
00883                 case 0:
00884                 case ERROR_EXPONENT_OVERFLOW:
00885                   if (*cp == 'f' || *cp == 'b')
00886                     /* Looks like a difference expression.  */
00887                     goto is_0f_label;
00888                   else if (cp == input_line_pointer + 1)
00889                     /* No characters has been accepted -- looks like
00890                       end of operand.  */
00891                     goto is_0f_label;
00892                   else
00893                     goto is_0f_float;
00894                 default:
00895                   as_fatal (_("expr.c(operand): bad atof_generic return val %d"),
00896                            r);
00897                 }
00898              }
00899 
00900              /* Okay, now we've sorted it out.  We resume at one of these
00901                two labels, depending on what we've decided we're probably
00902                looking at.  */
00903            is_0f_label:
00904              input_line_pointer--;
00905              integer_constant (10, expressionP);
00906              break;
00907 
00908            is_0f_float:
00909              /* Fall through.  */
00910              ;
00911            }
00912 
00913        case 'd':
00914        case 'D':
00915          if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
00916            {
00917              integer_constant (0, expressionP);
00918              break;
00919            }
00920          /* Fall through.  */
00921        case 'F':
00922        case 'r':
00923        case 'e':
00924        case 'E':
00925        case 'g':
00926        case 'G':
00927          input_line_pointer++;
00928          floating_constant (expressionP);
00929          expressionP->X_add_number = - TOLOWER (c);
00930          break;
00931 
00932        case '$':
00933          if (LOCAL_LABELS_DOLLAR)
00934            {
00935              integer_constant (10, expressionP);
00936              break;
00937            }
00938          else
00939            goto default_case;
00940        }
00941 
00942       break;
00943 
00944     case '(':
00945 #ifndef NEED_INDEX_OPERATOR
00946     case '[':
00947 #endif
00948       /* Didn't begin with digit & not a name.  */
00949       if (mode != expr_defer)
00950        segment = expression (expressionP);
00951       else
00952        segment = deferred_expression (expressionP);
00953       /* expression () will pass trailing whitespace.  */
00954       if ((c == '(' && *input_line_pointer != ')')
00955          || (c == '[' && *input_line_pointer != ']'))
00956        as_bad (_("missing '%c'"), c == '(' ? ')' : ']');
00957       else
00958        input_line_pointer++;
00959       SKIP_WHITESPACE ();
00960       /* Here with input_line_pointer -> char after "(...)".  */
00961       return segment;
00962 
00963 #ifdef TC_M68K
00964     case 'E':
00965       if (! flag_m68k_mri || *input_line_pointer != '\'')
00966        goto de_fault;
00967       as_bad (_("EBCDIC constants are not supported"));
00968       /* Fall through.  */
00969     case 'A':
00970       if (! flag_m68k_mri || *input_line_pointer != '\'')
00971        goto de_fault;
00972       ++input_line_pointer;
00973       /* Fall through.  */
00974 #endif
00975     case '\'':
00976       if (! flag_m68k_mri)
00977        {
00978          /* Warning: to conform to other people's assemblers NO
00979             ESCAPEMENT is permitted for a single quote.  The next
00980             character, parity errors and all, is taken as the value
00981             of the operand.  VERY KINKY.  */
00982          expressionP->X_op = O_constant;
00983          expressionP->X_add_number = *input_line_pointer++;
00984          break;
00985        }
00986 
00987       mri_char_constant (expressionP);
00988       break;
00989 
00990 #ifdef TC_M68K
00991     case '"':
00992       /* Double quote is the bitwise not operator in MRI mode.  */
00993       if (! flag_m68k_mri)
00994        goto de_fault;
00995       /* Fall through.  */
00996 #endif
00997     case '~':
00998       /* '~' is permitted to start a label on the Delta.  */
00999       if (is_name_beginner (c))
01000        goto isname;
01001     case '!':
01002     case '-':
01003     case '+':
01004       {
01005        operand (expressionP, mode);
01006        if (expressionP->X_op == O_constant)
01007          {
01008            /* input_line_pointer -> char after operand.  */
01009            if (c == '-')
01010              {
01011               expressionP->X_add_number = - expressionP->X_add_number;
01012               /* Notice: '-' may overflow: no warning is given.
01013                  This is compatible with other people's
01014                  assemblers.  Sigh.  */
01015               expressionP->X_unsigned = 0;
01016              }
01017            else if (c == '~' || c == '"')
01018              expressionP->X_add_number = ~ expressionP->X_add_number;
01019            else if (c == '!')
01020              expressionP->X_add_number = ! expressionP->X_add_number;
01021          }
01022        else if (expressionP->X_op == O_big
01023                && expressionP->X_add_number <= 0
01024                && c == '-'
01025                && (generic_floating_point_number.sign == '+'
01026                    || generic_floating_point_number.sign == 'P'))
01027          {
01028            /* Negative flonum (eg, -1.000e0).  */
01029            if (generic_floating_point_number.sign == '+')
01030              generic_floating_point_number.sign = '-';
01031            else
01032              generic_floating_point_number.sign = 'N';
01033          }
01034        else if (expressionP->X_op == O_big
01035                && expressionP->X_add_number > 0)
01036          {
01037            int i;
01038 
01039            if (c == '~' || c == '-')
01040              {
01041               for (i = 0; i < expressionP->X_add_number; ++i)
01042                 generic_bignum[i] = ~generic_bignum[i];
01043               if (c == '-')
01044                 for (i = 0; i < expressionP->X_add_number; ++i)
01045                   {
01046                     generic_bignum[i] += 1;
01047                     if (generic_bignum[i])
01048                      break;
01049                   }
01050              }
01051            else if (c == '!')
01052              {
01053               int nonzero = 0;
01054               for (i = 0; i < expressionP->X_add_number; ++i)
01055                 {
01056                   if (generic_bignum[i])
01057                     nonzero = 1;
01058                   generic_bignum[i] = 0;
01059                 }
01060               generic_bignum[0] = nonzero;
01061              }
01062          }
01063        else if (expressionP->X_op != O_illegal
01064                && expressionP->X_op != O_absent)
01065          {
01066            if (c != '+')
01067              {
01068               expressionP->X_add_symbol = make_expr_symbol (expressionP);
01069               if (c == '-')
01070                 expressionP->X_op = O_uminus;
01071               else if (c == '~' || c == '"')
01072                 expressionP->X_op = O_bit_not;
01073               else
01074                 expressionP->X_op = O_logical_not;
01075               expressionP->X_add_number = 0;
01076              }
01077          }
01078        else
01079          as_warn (_("Unary operator %c ignored because bad operand follows"),
01080                  c);
01081       }
01082       break;
01083 
01084 #if defined (DOLLAR_DOT) || defined (TC_M68K)
01085     case '$':
01086       /* '$' is the program counter when in MRI mode, or when
01087         DOLLAR_DOT is defined.  */
01088 #ifndef DOLLAR_DOT
01089       if (! flag_m68k_mri)
01090        goto de_fault;
01091 #endif
01092       if (DOLLAR_AMBIGU && hex_p (*input_line_pointer))
01093        {
01094          /* In MRI mode and on Z80, '$' is also used as the prefix
01095             for a hexadecimal constant.  */
01096          integer_constant (16, expressionP);
01097          break;
01098        }
01099 
01100       if (is_part_of_name (*input_line_pointer))
01101        goto isname;
01102 
01103       current_location (expressionP);
01104       break;
01105 #endif
01106 
01107     case '.':
01108       if (!is_part_of_name (*input_line_pointer))
01109        {
01110          current_location (expressionP);
01111          break;
01112        }
01113       else if ((strncasecmp (input_line_pointer, "startof.", 8) == 0
01114               && ! is_part_of_name (input_line_pointer[8]))
01115               || (strncasecmp (input_line_pointer, "sizeof.", 7) == 0
01116                  && ! is_part_of_name (input_line_pointer[7])))
01117        {
01118          int start;
01119 
01120          start = (input_line_pointer[1] == 't'
01121                  || input_line_pointer[1] == 'T');
01122          input_line_pointer += start ? 8 : 7;
01123          SKIP_WHITESPACE ();
01124          if (*input_line_pointer != '(')
01125            as_bad (_("syntax error in .startof. or .sizeof."));
01126          else
01127            {
01128              char *buf;
01129 
01130              ++input_line_pointer;
01131              SKIP_WHITESPACE ();
01132              name = input_line_pointer;
01133              c = get_symbol_end ();
01134 
01135              buf = (char *) xmalloc (strlen (name) + 10);
01136              if (start)
01137               sprintf (buf, ".startof.%s", name);
01138              else
01139               sprintf (buf, ".sizeof.%s", name);
01140              symbolP = symbol_make (buf);
01141              free (buf);
01142 
01143              expressionP->X_op = O_symbol;
01144              expressionP->X_add_symbol = symbolP;
01145              expressionP->X_add_number = 0;
01146 
01147              *input_line_pointer = c;
01148              SKIP_WHITESPACE ();
01149              if (*input_line_pointer != ')')
01150               as_bad (_("syntax error in .startof. or .sizeof."));
01151              else
01152               ++input_line_pointer;
01153            }
01154          break;
01155        }
01156       else
01157        {
01158          goto isname;
01159        }
01160 
01161     case ',':
01162     eol:
01163       /* Can't imagine any other kind of operand.  */
01164       expressionP->X_op = O_absent;
01165       input_line_pointer--;
01166       break;
01167 
01168 #ifdef TC_M68K
01169     case '%':
01170       if (! flag_m68k_mri)
01171        goto de_fault;
01172       integer_constant (2, expressionP);
01173       break;
01174 
01175     case '@':
01176       if (! flag_m68k_mri)
01177        goto de_fault;
01178       integer_constant (8, expressionP);
01179       break;
01180 
01181     case ':':
01182       if (! flag_m68k_mri)
01183        goto de_fault;
01184 
01185       /* In MRI mode, this is a floating point constant represented
01186         using hexadecimal digits.  */
01187 
01188       ++input_line_pointer;
01189       integer_constant (16, expressionP);
01190       break;
01191 
01192     case '*':
01193       if (! flag_m68k_mri || is_part_of_name (*input_line_pointer))
01194        goto de_fault;
01195 
01196       current_location (expressionP);
01197       break;
01198 #endif
01199 
01200     default:
01201 #ifdef TC_M68K
01202     de_fault:
01203 #endif
01204       if (is_name_beginner (c))    /* Here if did not begin with a digit.  */
01205        {
01206          /* Identifier begins here.
01207             This is kludged for speed, so code is repeated.  */
01208        isname:
01209          name = --input_line_pointer;
01210          c = get_symbol_end ();
01211 
01212 #ifdef md_parse_name
01213          /* This is a hook for the backend to parse certain names
01214             specially in certain contexts.  If a name always has a
01215             specific value, it can often be handled by simply
01216             entering it in the symbol table.  */
01217          if (md_parse_name (name, expressionP, mode, &c))
01218            {
01219              *input_line_pointer = c;
01220              break;
01221            }
01222 #endif
01223 
01224 #ifdef TC_I960
01225          /* The MRI i960 assembler permits
01226                 lda sizeof code,g13
01227             FIXME: This should use md_parse_name.  */
01228          if (flag_mri
01229              && (strcasecmp (name, "sizeof") == 0
01230                 || strcasecmp (name, "startof") == 0))
01231            {
01232              int start;
01233              char *buf;
01234 
01235              start = (name[1] == 't'
01236                      || name[1] == 'T');
01237 
01238              *input_line_pointer = c;
01239              SKIP_WHITESPACE ();
01240 
01241              name = input_line_pointer;
01242              c = get_symbol_end ();
01243 
01244              buf = (char *) xmalloc (strlen (name) + 10);
01245              if (start)
01246               sprintf (buf, ".startof.%s", name);
01247              else
01248               sprintf (buf, ".sizeof.%s", name);
01249              symbolP = symbol_make (buf);
01250              free (buf);
01251 
01252              expressionP->X_op = O_symbol;
01253              expressionP->X_add_symbol = symbolP;
01254              expressionP->X_add_number = 0;
01255 
01256              *input_line_pointer = c;
01257              SKIP_WHITESPACE ();
01258 
01259              break;
01260            }
01261 #endif
01262 
01263          symbolP = symbol_find_or_make (name);
01264 
01265          /* If we have an absolute symbol or a reg, then we know its
01266             value now.  */
01267          segment = S_GET_SEGMENT (symbolP);
01268          if (mode != expr_defer && segment == absolute_section)
01269            {
01270              expressionP->X_op = O_constant;
01271              expressionP->X_add_number = S_GET_VALUE (symbolP);
01272            }
01273          else if (mode != expr_defer && segment == reg_section)
01274            {
01275              expressionP->X_op = O_register;
01276              expressionP->X_add_number = S_GET_VALUE (symbolP);
01277            }
01278          else
01279            {
01280              expressionP->X_op = O_symbol;
01281              expressionP->X_add_symbol = symbolP;
01282              expressionP->X_add_number = 0;
01283            }
01284          *input_line_pointer = c;
01285        }
01286       else
01287        {
01288          /* Let the target try to parse it.  Success is indicated by changing
01289             the X_op field to something other than O_absent and pointing
01290             input_line_pointer past the expression.  If it can't parse the
01291             expression, X_op and input_line_pointer should be unchanged.  */
01292          expressionP->X_op = O_absent;
01293          --input_line_pointer;
01294          md_operand (expressionP);
01295          if (expressionP->X_op == O_absent)
01296            {
01297              ++input_line_pointer;
01298              as_bad (_("bad expression"));
01299              expressionP->X_op = O_constant;
01300              expressionP->X_add_number = 0;
01301            }
01302        }
01303       break;
01304     }
01305 
01306   /* It is more 'efficient' to clean up the expressionS when they are
01307      created.  Doing it here saves lines of code.  */
01308   clean_up_expression (expressionP);
01309   SKIP_WHITESPACE ();              /* -> 1st char after operand.  */
01310   know (*input_line_pointer != ' ');
01311 
01312   /* The PA port needs this information.  */
01313   if (expressionP->X_add_symbol)
01314     symbol_mark_used (expressionP->X_add_symbol);
01315 
01316   expressionP->X_add_symbol = symbol_clone_if_forward_ref (expressionP->X_add_symbol);
01317   expressionP->X_op_symbol = symbol_clone_if_forward_ref (expressionP->X_op_symbol);
01318 
01319   switch (expressionP->X_op)
01320     {
01321     default:
01322       return absolute_section;
01323     case O_symbol:
01324       return S_GET_SEGMENT (expressionP->X_add_symbol);
01325     case O_register:
01326       return reg_section;
01327     }
01328 }
01329 
01330 /* Internal.  Simplify a struct expression for use by expr ().  */
01331 
01332 /* In: address of an expressionS.
01333        The X_op field of the expressionS may only take certain values.
01334        Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT.
01335 
01336    Out:       expressionS may have been modified:
01337        Unused fields zeroed to help expr ().  */
01338 
01339 static void
01340 clean_up_expression (expressionS *expressionP)
01341 {
01342   switch (expressionP->X_op)
01343     {
01344     case O_illegal:
01345     case O_absent:
01346       expressionP->X_add_number = 0;
01347       /* Fall through.  */
01348     case O_big:
01349     case O_constant:
01350     case O_register:
01351       expressionP->X_add_symbol = NULL;
01352       /* Fall through.  */
01353     case O_symbol:
01354     case O_uminus:
01355     case O_bit_not:
01356       expressionP->X_op_symbol = NULL;
01357       break;
01358     default:
01359       break;
01360     }
01361 }
01362 
01363 /* Expression parser.  */
01364 
01365 /* We allow an empty expression, and just assume (absolute,0) silently.
01366    Unary operators and parenthetical expressions are treated as operands.
01367    As usual, Q==quantity==operand, O==operator, X==expression mnemonics.
01368 
01369    We used to do an aho/ullman shift-reduce parser, but the logic got so
01370    warped that I flushed it and wrote a recursive-descent parser instead.
01371    Now things are stable, would anybody like to write a fast parser?
01372    Most expressions are either register (which does not even reach here)
01373    or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common.
01374    So I guess it doesn't really matter how inefficient more complex expressions
01375    are parsed.
01376 
01377    After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK.
01378    Also, we have consumed any leading or trailing spaces (operand does that)
01379    and done all intervening operators.
01380 
01381    This returns the segment of the result, which will be
01382    absolute_section or the segment of a symbol.  */
01383 
01384 #undef __
01385 #define __ O_illegal
01386 #ifndef O_SINGLE_EQ
01387 #define O_SINGLE_EQ O_illegal
01388 #endif
01389 
01390 /* Maps ASCII -> operators.  */
01391 static const operatorT op_encoding[256] = {
01392   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01393   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01394 
01395   __, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __,
01396   __, __, O_multiply, O_add, __, O_subtract, __, O_divide,
01397   __, __, __, __, __, __, __, __,
01398   __, __, __, __, O_lt, O_SINGLE_EQ, O_gt, __,
01399   __, __, __, __, __, __, __, __,
01400   __, __, __, __, __, __, __, __,
01401   __, __, __, __, __, __, __, __,
01402   __, __, __,
01403 #ifdef NEED_INDEX_OPERATOR
01404   O_index,
01405 #else
01406   __,
01407 #endif
01408   __, __, O_bit_exclusive_or, __,
01409   __, __, __, __, __, __, __, __,
01410   __, __, __, __, __, __, __, __,
01411   __, __, __, __, __, __, __, __,
01412   __, __, __, __, O_bit_inclusive_or, __, __, __,
01413 
01414   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01415   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01416   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01417   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01418   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01419   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01420   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
01421   __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __
01422 };
01423 
01424 /* Rank       Examples
01425    0   operand, (expression)
01426    1   ||
01427    2   &&
01428    3   == <> < <= >= >
01429    4   + -
01430    5   used for * / % in MRI mode
01431    6   & ^ ! |
01432    7   * / % << >>
01433    8   unary - unary ~
01434 */
01435 static operator_rankT op_rank[] = {
01436   0,   /* O_illegal */
01437   0,   /* O_absent */
01438   0,   /* O_constant */
01439   0,   /* O_symbol */
01440   0,   /* O_symbol_rva */
01441   0,   /* O_register */
01442   0,   /* O_big */
01443   9,   /* O_uminus */
01444   9,   /* O_bit_not */
01445   9,   /* O_logical_not */
01446   8,   /* O_multiply */
01447   8,   /* O_divide */
01448   8,   /* O_modulus */
01449   8,   /* O_left_shift */
01450   8,   /* O_right_shift */
01451   7,   /* O_bit_inclusive_or */
01452   7,   /* O_bit_or_not */
01453   7,   /* O_bit_exclusive_or */
01454   7,   /* O_bit_and */
01455   5,   /* O_add */
01456   5,   /* O_subtract */
01457   4,   /* O_eq */
01458   4,   /* O_ne */
01459   4,   /* O_lt */
01460   4,   /* O_le */
01461   4,   /* O_ge */
01462   4,   /* O_gt */
01463   3,   /* O_logical_and */
01464   2,   /* O_logical_or */
01465   1,   /* O_index */
01466   0,   /* O_md1 */
01467   0,   /* O_md2 */
01468   0,   /* O_md3 */
01469   0,   /* O_md4 */
01470   0,   /* O_md5 */
01471   0,   /* O_md6 */
01472   0,   /* O_md7 */
01473   0,   /* O_md8 */
01474   0,   /* O_md9 */
01475   0,   /* O_md10 */
01476   0,   /* O_md11 */
01477   0,   /* O_md12 */
01478   0,   /* O_md13 */
01479   0,   /* O_md14 */
01480   0,   /* O_md15 */
01481   0,   /* O_md16 */
01482 };
01483 
01484 /* Unfortunately, in MRI mode for the m68k, multiplication and
01485    division have lower precedence than the bit wise operators.  This
01486    function sets the operator precedences correctly for the current
01487    mode.  Also, MRI uses a different bit_not operator, and this fixes
01488    that as well.  */
01489 
01490 #define STANDARD_MUL_PRECEDENCE 8
01491 #define MRI_MUL_PRECEDENCE 6
01492 
01493 void
01494 expr_set_precedence (void)
01495 {
01496   if (flag_m68k_mri)
01497     {
01498       op_rank[O_multiply] = MRI_MUL_PRECEDENCE;
01499       op_rank[O_divide] = MRI_MUL_PRECEDENCE;
01500       op_rank[O_modulus] = MRI_MUL_PRECEDENCE;
01501     }
01502   else
01503     {
01504       op_rank[O_multiply] = STANDARD_MUL_PRECEDENCE;
01505       op_rank[O_divide] = STANDARD_MUL_PRECEDENCE;
01506       op_rank[O_modulus] = STANDARD_MUL_PRECEDENCE;
01507     }
01508 }
01509 
01510 /* Initialize the expression parser.  */
01511 
01512 void
01513 expr_begin (void)
01514 {
01515   expr_set_precedence ();
01516 
01517   /* Verify that X_op field is wide enough.  */
01518   {
01519     expressionS e;
01520     e.X_op = O_max;
01521     assert (e.X_op == O_max);
01522   }
01523 }
01524 
01525 /* Return the encoding for the operator at INPUT_LINE_POINTER, and
01526    sets NUM_CHARS to the number of characters in the operator.
01527    Does not advance INPUT_LINE_POINTER.  */
01528 
01529 static inline operatorT
01530 operator (int *num_chars)
01531 {
01532   int c;
01533   operatorT ret;
01534 
01535   c = *input_line_pointer & 0xff;
01536   *num_chars = 1;
01537 
01538   if (is_end_of_line[c])
01539     return O_illegal;
01540 
01541   switch (c)
01542     {
01543     default:
01544       return op_encoding[c];
01545 
01546     case '+':
01547     case '-':
01548       return op_encoding[c];
01549 
01550     case '<':
01551       switch (input_line_pointer[1])
01552        {
01553        default:
01554          return op_encoding[c];
01555        case '<':
01556          ret = O_left_shift;
01557          break;
01558        case '>':
01559          ret = O_ne;
01560          break;
01561        case '=':
01562          ret = O_le;
01563          break;
01564        }
01565       *num_chars = 2;
01566       return ret;
01567 
01568     case '=':
01569       if (input_line_pointer[1] != '=')
01570        return op_encoding[c];
01571 
01572       *num_chars = 2;
01573       return O_eq;
01574 
01575     case '>':
01576       switch (input_line_pointer[1])
01577        {
01578        default:
01579          return op_encoding[c];
01580        case '>':
01581          ret = O_right_shift;
01582          break;
01583        case '=':
01584          ret = O_ge;
01585          break;
01586        }
01587       *num_chars = 2;
01588       return ret;
01589 
01590     case '!':
01591       switch (input_line_pointer[1])
01592        {
01593        case '!':
01594          /* We accept !! as equivalent to ^ for MRI compatibility. */
01595          *num_chars = 2;
01596          return O_bit_exclusive_or;
01597        case '=':
01598          /* We accept != as equivalent to <>.  */
01599          *num_chars = 2;
01600          return O_ne;
01601        default:
01602          if (flag_m68k_mri)
01603            return O_bit_inclusive_or;
01604          return op_encoding[c];
01605        }
01606 
01607     case '|':
01608       if (input_line_pointer[1] != '|')
01609        return op_encoding[c];
01610 
01611       *num_chars = 2;
01612       return O_logical_or;
01613 
01614     case '&':
01615       if (input_line_pointer[1] != '&')
01616        return op_encoding[c];
01617 
01618       *num_chars = 2;
01619       return O_logical_and;
01620     }
01621 
01622   /* NOTREACHED  */
01623 }
01624 
01625 /* Parse an expression.  */
01626 
01627 segT
01628 expr (int rankarg,          /* Larger # is higher rank.  */
01629       expressionS *resultP, /* Deliver result here.  */
01630       enum expr_mode mode   /* Controls behavior.  */)
01631 {
01632   operator_rankT rank = (operator_rankT) rankarg;
01633   segT retval;
01634   expressionS right;
01635   operatorT op_left;
01636   operatorT op_right;
01637   int op_chars;
01638 
01639   know (rank >= 0);
01640 
01641   /* Save the value of dot for the fixup code.  */
01642   if (rank == 0)
01643     dot_value = frag_now_fix ();
01644 
01645   retval = operand (resultP, mode);
01646 
01647   /* operand () gobbles spaces.  */
01648   know (*input_line_pointer != ' ');
01649 
01650   op_left = operator (&op_chars);
01651   while (op_left != O_illegal && op_rank[(int) op_left] > rank)
01652     {
01653       segT rightseg;
01654       bfd_vma frag_off;
01655 
01656       input_line_pointer += op_chars;     /* -> after operator.  */
01657 
01658       rightseg = expr (op_rank[(int) op_left], &right, mode);
01659       if (right.X_op == O_absent)
01660        {
01661          as_warn (_("missing operand; zero assumed"));
01662          right.X_op = O_constant;
01663          right.X_add_number = 0;
01664          right.X_add_symbol = NULL;
01665          right.X_op_symbol = NULL;
01666        }
01667 
01668       know (*input_line_pointer != ' ');
01669 
01670       if (op_left == O_index)
01671        {
01672          if (*input_line_pointer != ']')
01673            as_bad ("missing right bracket");
01674          else
01675            {
01676              ++input_line_pointer;
01677              SKIP_WHITESPACE ();
01678            }
01679        }
01680 
01681       op_right = operator (&op_chars);
01682 
01683       know (op_right == O_illegal
01684            || op_rank[(int) op_right] <= op_rank[(int) op_left]);
01685       know ((int) op_left >= (int) O_multiply
01686            && (int) op_left <= (int) O_index);
01687 
01688       /* input_line_pointer->after right-hand quantity.  */
01689       /* left-hand quantity in resultP.  */
01690       /* right-hand quantity in right.  */
01691       /* operator in op_left.  */
01692 
01693       if (resultP->X_op == O_big)
01694        {
01695          if (resultP->X_add_number > 0)
01696            as_warn (_("left operand is a bignum; integer 0 assumed"));
01697          else
01698            as_warn (_("left operand is a float; integer 0 assumed"));
01699          resultP->X_op = O_constant;
01700          resultP->X_add_number = 0;
01701          resultP->X_add_symbol = NULL;
01702          resultP->X_op_symbol = NULL;
01703        }
01704       if (right.X_op == O_big)
01705        {
01706          if (right.X_add_number > 0)
01707            as_warn (_("right operand is a bignum; integer 0 assumed"));
01708          else
01709            as_warn (_("right operand is a float; integer 0 assumed"));
01710          right.X_op = O_constant;
01711          right.X_add_number = 0;
01712          right.X_add_symbol = NULL;
01713          right.X_op_symbol = NULL;
01714        }
01715 
01716       /* Optimize common cases.  */
01717 #ifdef md_optimize_expr
01718       if (md_optimize_expr (resultP, op_left, &right))
01719        {
01720          /* Skip.  */
01721          ;
01722        }
01723       else
01724 #endif
01725       if (op_left == O_add && right.X_op == O_constant)
01726        {
01727          /* X + constant.  */
01728          resultP->X_add_number += right.X_add_number;
01729        }
01730       /* This case comes up in PIC code.  */
01731       else if (op_left == O_subtract
01732               && right.X_op == O_symbol
01733               && resultP->X_op == O_symbol
01734               && retval == rightseg
01735               && (SEG_NORMAL (rightseg)
01736                  || right.X_add_symbol == resultP->X_add_symbol)
01737               && frag_offset_fixed_p (symbol_get_frag (resultP->X_add_symbol),
01738                                    symbol_get_frag (right.X_add_symbol),
01739                                    &frag_off))
01740        {
01741          resultP->X_add_number -= right.X_add_number;
01742          resultP->X_add_number -= frag_off / OCTETS_PER_BYTE;
01743          resultP->X_add_number += (S_GET_VALUE (resultP->X_add_symbol)
01744                                 - S_GET_VALUE (right.X_add_symbol));
01745          resultP->X_op = O_constant;
01746          resultP->X_add_symbol = 0;
01747        }
01748       else if (op_left == O_subtract && right.X_op == O_constant)
01749        {
01750          /* X - constant.  */
01751          resultP->X_add_number -= right.X_add_number;
01752        }
01753       else if (op_left == O_add && resultP->X_op == O_constant)
01754        {
01755          /* Constant + X.  */
01756          resultP->X_op = right.X_op;
01757          resultP->X_add_symbol = right.X_add_symbol;
01758          resultP->X_op_symbol = right.X_op_symbol;
01759          resultP->X_add_number += right.X_add_number;
01760          retval = rightseg;
01761        }
01762       else if (resultP->X_op == O_constant && right.X_op == O_constant)
01763        {
01764          /* Constant OP constant.  */
01765          offsetT v = right.X_add_number;
01766          if (v == 0 && (op_left == O_divide || op_left == O_modulus))
01767            {
01768              as_warn (_("division by zero"));
01769              v = 1;
01770            }
01771          switch (op_left)
01772            {
01773            default:                abort ();
01774            case O_multiply:        resultP->X_add_number *= v; break;
01775            case O_divide:          resultP->X_add_number /= v; break;
01776            case O_modulus:         resultP->X_add_number %= v; break;
01777            case O_left_shift:             resultP->X_add_number <<= v; break;
01778            case O_right_shift:
01779              /* We always use unsigned shifts, to avoid relying on
01780                characteristics of the compiler used to compile gas.  */
01781              resultP->X_add_number =
01782               (offsetT) ((valueT) resultP->X_add_number >> (valueT) v);
01783              break;
01784            case O_bit_inclusive_or:       resultP->X_add_number |= v; break;
01785            case O_bit_or_not:             resultP->X_add_number |= ~v; break;
01786            case O_bit_exclusive_or:       resultP->X_add_number ^= v; break;
01787            case O_bit_and:         resultP->X_add_number &= v; break;
01788              /* Constant + constant (O_add) is handled by the
01789                previous if statement for constant + X, so is omitted
01790                here.  */
01791            case O_subtract:        resultP->X_add_number -= v; break;
01792            case O_eq:
01793              resultP->X_add_number =
01794               resultP->X_add_number == v ? ~ (offsetT) 0 : 0;
01795              break;
01796            case O_ne:
01797              resultP->X_add_number =
01798               resultP->X_add_number != v ? ~ (offsetT) 0 : 0;
01799              break;
01800            case O_lt:
01801              resultP->X_add_number =
01802               resultP->X_add_number <  v ? ~ (offsetT) 0 : 0;
01803              break;
01804            case O_le:
01805              resultP->X_add_number =
01806               resultP->X_add_number <= v ? ~ (offsetT) 0 : 0;
01807              break;
01808            case O_ge:
01809              resultP->X_add_number =
01810               resultP->X_add_number >= v ? ~ (offsetT) 0 : 0;
01811              break;
01812            case O_gt:
01813              resultP->X_add_number =
01814               resultP->X_add_number >  v ? ~ (offsetT) 0 : 0;
01815              break;
01816            case O_logical_and:
01817              resultP->X_add_number = resultP->X_add_number && v;
01818              break;
01819            case O_logical_or:
01820              resultP->X_add_number = resultP->X_add_number || v;
01821              break;
01822            }
01823        }
01824       else if (resultP->X_op == O_symbol
01825               && right.X_op == O_symbol
01826               && (op_left == O_add
01827                  || op_left == O_subtract
01828                  || (resultP->X_add_number == 0
01829                      && right.X_add_number == 0)))
01830        {
01831          /* Symbol OP symbol.  */
01832          resultP->X_op = op_left;
01833          resultP->X_op_symbol = right.X_add_symbol;
01834          if (op_left == O_add)
01835            resultP->X_add_number += right.X_add_number;
01836          else if (op_left == O_subtract)
01837            {
01838              resultP->X_add_number -= right.X_add_number;
01839              if (retval == rightseg && SEG_NORMAL (retval))
01840               {
01841                 retval = absolute_section;
01842                 rightseg = absolute_section;
01843               }
01844            }
01845        }
01846       else
01847        {
01848          /* The general case.  */
01849          resultP->X_add_symbol = make_expr_symbol (resultP);
01850          resultP->X_op_symbol = make_expr_symbol (&right);
01851          resultP->X_op = op_left;
01852          resultP->X_add_number = 0;
01853          resultP->X_unsigned = 1;
01854        }
01855 
01856       if (retval != rightseg)
01857        {
01858          if (! SEG_NORMAL (retval))
01859            {
01860              if (retval != undefined_section || SEG_NORMAL (rightseg))
01861               retval = rightseg;
01862            }
01863          else if (SEG_NORMAL (rightseg)
01864 #ifdef DIFF_EXPR_OK
01865                  && op_left != O_subtract
01866 #endif
01867                  )
01868            as_bad (_("operation combines symbols in different segments"));
01869        }
01870 
01871       op_left = op_right;
01872     }                       /* While next operator is >= this rank.  */
01873 
01874   /* The PA port needs this information.  */
01875   if (resultP->X_add_symbol)
01876     symbol_mark_used (resultP->X_add_symbol);
01877 
01878   if (rank == 0 && mode == expr_evaluate)
01879     resolve_expression (resultP);
01880 
01881   return resultP->X_op == O_constant ? absolute_section : retval;
01882 }
01883 
01884 /* Resolve an expression without changing any symbols/sub-expressions
01885    used.  */
01886 
01887 int
01888 resolve_expression (expressionS *expressionP)
01889 {
01890   /* Help out with CSE.  */
01891   valueT final_val = expressionP->X_add_number;
01892   symbolS *add_symbol = expressionP->X_add_symbol;
01893   symbolS *op_symbol = expressionP->X_op_symbol;
01894   operatorT op = expressionP->X_op;
01895   valueT left, right;
01896   segT seg_left, seg_right;
01897   fragS *frag_left, *frag_right;
01898   bfd_vma frag_off;
01899 
01900   switch (op)
01901     {
01902     default:
01903       return 0;
01904 
01905     case O_constant:
01906     case O_register:
01907       left = 0;
01908       break;
01909 
01910     case O_symbol:
01911     case O_symbol_rva:
01912       if (!snapshot_symbol (&add_symbol, &left, &seg_left, &frag_left))
01913        return 0;
01914 
01915       break;
01916 
01917     case O_uminus:
01918     case O_bit_not:
01919     case O_logical_not:
01920       if (!snapshot_symbol (&add_symbol, &left, &seg_left, &frag_left))
01921        return 0;
01922 
01923       if (seg_left != absolute_section)
01924        return 0;
01925 
01926       if (op == O_logical_not)
01927        left = !left;
01928       else if (op == O_uminus)
01929        left = -left;
01930       else
01931        left = ~left;
01932       op = O_constant;
01933       break;
01934 
01935     case O_multiply:
01936     case O_divide:
01937     case O_modulus:
01938     case O_left_shift:
01939     case O_right_shift:
01940     case O_bit_inclusive_or:
01941     case O_bit_or_not:
01942     case O_bit_exclusive_or:
01943     case O_bit_and:
01944     case O_add:
01945     case O_subtract:
01946     case O_eq:
01947     case O_ne:
01948     case O_lt:
01949     case O_le:
01950     case O_ge:
01951     case O_gt:
01952     case O_logical_and:
01953     case O_logical_or:
01954       if (!snapshot_symbol (&add_symbol, &left, &seg_left, &frag_left)
01955          || !snapshot_symbol (&op_symbol, &right, &seg_right, &frag_right))
01956        return 0;
01957 
01958       /* Simplify addition or subtraction of a constant by folding the
01959         constant into X_add_number.  */
01960       if (op == O_add)
01961        {
01962          if (seg_right == absolute_section)
01963            {
01964              final_val += right;
01965              op = O_symbol;
01966              break;
01967            }
01968          else if (seg_left == absolute_section)
01969            {
01970              final_val += left;
01971              left = right;
01972              seg_left = seg_right;
01973              add_symbol = op_symbol;
01974              op = O_symbol;
01975              break;
01976            }
01977        }
01978       else if (op == O_subtract)
01979        {
01980          if (seg_right == absolute_section)
01981            {
01982              final_val -= right;
01983              op = O_symbol;
01984              break;
01985            }
01986        }
01987 
01988       /* Equality and non-equality tests are permitted on anything.
01989         Subtraction, and other comparison operators are permitted if
01990         both operands are in the same section.
01991         Shifts by constant zero are permitted on anything.
01992         Multiplies, bit-ors, and bit-ands with constant zero are
01993         permitted on anything.
01994         Multiplies and divides by constant one are permitted on
01995         anything.
01996         Binary operations with both operands being the same register
01997         or undefined symbol are permitted if the result doesn't depend
01998         on the input value.
01999         Otherwise, both operands must be absolute.  We already handled
02000         the case of addition or subtraction of a constant above.  */
02001       frag_off = 0;
02002       if (!(seg_left == absolute_section
02003               && seg_right == absolute_section)
02004          && !(op == O_eq || op == O_ne)
02005          && !((op == O_subtract
02006               || op == O_lt || op == O_le || op == O_ge || op == O_gt)
02007               && seg_left == seg_right
02008               && (finalize_syms
02009                  || frag_offset_fixed_p (frag_left, frag_right, &frag_off))
02010               && (seg_left != reg_section || left == right)
02011               && (seg_left != undefined_section || add_symbol == op_symbol)))
02012        {
02013          if ((seg_left == absolute_section && left == 0)
02014              || (seg_right == absolute_section && right == 0))
02015            {
02016              if (op == O_bit_exclusive_or || op == O_bit_inclusive_or)
02017               {
02018                 if (seg_right != absolute_section || right != 0)
02019                   {
02020                     seg_left = seg_right;
02021                     left = right;
02022                     add_symbol = op_symbol;
02023                   }
02024                 op = O_symbol;
02025                 break;
02026               }
02027              else if (op == O_left_shift || op == O_right_shift)
02028               {
02029                 if (seg_left != absolute_section || left != 0)
02030                   {
02031                     op = O_symbol;
02032                     break;
02033                   }
02034               }
02035              else if (op != O_multiply
02036                      && op != O_bit_or_not && op != O_bit_and)
02037                return 0;
02038            }
02039          else if (op == O_multiply
02040                  && seg_left == absolute_section && left == 1)
02041            {
02042              seg_left = seg_right;
02043              left = right;
02044              add_symbol = op_symbol;
02045              op = O_symbol;
02046              break;
02047            }
02048          else if ((op == O_multiply || op == O_divide)
02049                  && seg_right == absolute_section && right == 1)
02050            {
02051              op = O_symbol;
02052              break;
02053            }
02054          else if (left != right
02055                  || ((seg_left != reg_section || seg_right != reg_section)
02056                      && (seg_left != undefined_section
02057                         || seg_right != undefined_section
02058                         || add_symbol != op_symbol)))
02059            return 0;
02060          else if (op == O_bit_and || op == O_bit_inclusive_or)
02061            {
02062              op = O_symbol;
02063              break;
02064            }
02065          else if (op != O_bit_exclusive_or && op != O_bit_or_not)
02066            return 0;
02067        }
02068 
02069       right += frag_off / OCTETS_PER_BYTE;
02070       switch (op)
02071        {
02072        case O_add:                 left += right; break;
02073        case O_subtract:            left -= right; break;
02074        case O_multiply:            left *= right; break;
02075        case O_divide:
02076          if (right == 0)
02077            return 0;
02078          left = (offsetT) left / (offsetT) right;
02079          break;
02080        case O_modulus:
02081          if (right == 0)
02082            return 0;
02083          left = (offsetT) left % (offsetT) right;
02084          break;
02085        case O_left_shift:          left <<= right; break;
02086        case O_right_shift:         left >>= right; break;
02087        case O_bit_inclusive_or:    left |= right; break;
02088        case O_bit_or_not:          left |= ~right; break;
02089        case O_bit_exclusive_or:    left ^= right; break;
02090        case O_bit_and:                    left &= right; break;
02091        case O_eq:
02092        case O_ne:
02093          left = (left == right
02094                 && seg_left == seg_right
02095                 && (finalize_syms || frag_left == frag_right)
02096                 && (seg_left != undefined_section
02097                     || add_symbol == op_symbol)
02098                 ? ~ (valueT) 0 : 0);
02099          if (op == O_ne)
02100            left = ~left;
02101          break;
02102        case O_lt:
02103          left = (offsetT) left <  (offsetT) right ? ~ (valueT) 0 : 0;
02104          break;
02105        case O_le:
02106          left = (offsetT) left <= (offsetT) right ? ~ (valueT) 0 : 0;
02107          break;
02108        case O_ge:
02109          left = (offsetT) left >= (offsetT) right ? ~ (valueT) 0 : 0;
02110          break;
02111        case O_gt:
02112          left = (offsetT) left >  (offsetT) right ? ~ (valueT) 0 : 0;
02113          break;
02114        case O_logical_and:  left = left && right; break;
02115        case O_logical_or:   left = left || right; break;
02116        default:             abort ();
02117        }
02118 
02119       op = O_constant;
02120       break;
02121     }
02122 
02123   if (op == O_symbol)
02124     {
02125       if (seg_left == absolute_section)
02126        op = O_constant;
02127       else if (seg_left == reg_section && final_val == 0)
02128        op = O_register;
02129       else if (add_symbol != expressionP->X_add_symbol)
02130        final_val += left;
02131       expressionP->X_add_symbol = add_symbol;
02132     }
02133   expressionP->X_op = op;
02134 
02135   if (op == O_constant || op == O_register)
02136     final_val += left;
02137   expressionP->X_add_number = final_val;
02138 
02139   return 1;
02140 }
02141 
02142 /* This lives here because it belongs equally in expr.c & read.c.
02143    expr.c is just a branch office read.c anyway, and putting it
02144    here lessens the crowd at read.c.
02145 
02146    Assume input_line_pointer is at start of symbol name.
02147    Advance input_line_pointer past symbol name.
02148    Turn that character into a '\0', returning its former value.
02149    This allows a string compare (RMS wants symbol names to be strings)
02150    of the symbol name.
02151    There will always be a char following symbol name, because all good
02152    lines end in end-of-line.  */
02153 
02154 char
02155 get_symbol_end (void)
02156 {
02157   char c;
02158 
02159   /* We accept \001 in a name in case this is being called with a
02160      constructed string.  */
02161   if (is_name_beginner (c = *input_line_pointer++) || c == '\001')
02162     {
02163       while (is_part_of_name (c = *input_line_pointer++)
02164             || c == '\001')
02165        ;
02166       if (is_name_ender (c))
02167        c = *input_line_pointer++;
02168     }
02169   *--input_line_pointer = 0;
02170   return (c);
02171 }
02172 
02173 unsigned int
02174 get_single_number (void)
02175 {
02176   expressionS exp;
02177   operand (&exp, expr_normal);
02178   return exp.X_add_number;
02179 }