]> Git Repo - binutils.git/blobdiff - gas/expr.c
* $literal support
[binutils.git] / gas / expr.c
index 97d5cd522d951eb1eb0e6722855c07b077d74f37..fe2aa6204e1f8bedd6cea489b551068bbf37ea8b 100644 (file)
@@ -1,5 +1,5 @@
 /* expr.c -operands, expressions-
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -541,8 +541,8 @@ integer_constant (radix, expressionP)
        }
     }
 
-  if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) 
-      && suffix != NULL 
+  if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
+      && suffix != NULL
       && input_line_pointer - 1 == suffix)
     c = *input_line_pointer++;
 
@@ -799,6 +799,9 @@ operand (expressionP)
   SKIP_WHITESPACE ();          /* leading whitespace is part of operand. */
   c = *input_line_pointer++;   /* input_line_pointer->past char in c. */
 
+  if (is_end_of_line[(unsigned char) c])
+    goto eol;
+
   switch (c)
     {
     case '1':
@@ -812,11 +815,17 @@ operand (expressionP)
     case '9':
       input_line_pointer--;
 
-      integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) 
+      integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
                         ? 0 : 10,
                         expressionP);
       break;
 
+#ifdef LITERAL_PREFIXDOLLAR_HEX
+    case '$':
+      integer_constant (16, expressionP);
+      break;
+#endif
+
     case '0':
       /* non-decimal radix */
 
@@ -923,7 +932,8 @@ operand (expressionP)
                 number, make it one.  Otherwise, make it a local label,
                 and try to deal with parsing the rest later.  */
              if (!input_line_pointer[1]
-                 || (is_end_of_line[0xff & input_line_pointer[1]]))
+                 || (is_end_of_line[0xff & input_line_pointer[1]])
+                 || strchr (FLT_CHARS, 'f') == NULL)
                goto is_0f_label;
              {
                char *cp = input_line_pointer + 1;
@@ -1000,16 +1010,21 @@ operand (expressionP)
       /* didn't begin with digit & not a name */
       segment = expression (expressionP);
       /* Expression() will pass trailing whitespace */
-      if ((c == '(' && *input_line_pointer++ != ')')
-         || (c == '[' && *input_line_pointer++ != ']'))
+      if ((c == '(' && *input_line_pointer != ')')
+         || (c == '[' && *input_line_pointer != ']'))
        {
-         as_bad (_("Missing ')' assumed"));
-         input_line_pointer--;
+#ifdef RELAX_PAREN_GROUPING
+         if (c != '(')
+#endif
+           as_bad (_("Missing '%c' assumed"), c == '(' ? ')' : ']');
        }
+      else
+        input_line_pointer++;
       SKIP_WHITESPACE ();
       /* here with input_line_pointer->char after "(...)" */
       return segment;
 
+#ifdef TC_M68K
     case 'E':
       if (! flag_m68k_mri || *input_line_pointer != '\'')
        goto de_fault;
@@ -1020,6 +1035,7 @@ operand (expressionP)
        goto de_fault;
       ++input_line_pointer;
       /* Fall through.  */
+#endif
     case '\'':
       if (! flag_m68k_mri)
        {
@@ -1039,11 +1055,13 @@ operand (expressionP)
       (void) operand (expressionP);
       break;
 
+#ifdef TC_M68K
     case '"':
       /* Double quote is the bitwise not operator in MRI mode.  */
       if (! flag_m68k_mri)
        goto de_fault;
       /* Fall through.  */
+#endif
     case '~':
       /* ~ is permitted to start a label on the Delta.  */
       if (is_name_beginner (c))
@@ -1085,6 +1103,7 @@ operand (expressionP)
       }
       break;
 
+#if defined (DOLLAR_DOT) || defined (TC_M68K)
     case '$':
       /* $ is the program counter when in MRI mode, or when DOLLAR_DOT
          is defined.  */
@@ -1105,6 +1124,7 @@ operand (expressionP)
 
       current_location (expressionP);
       break;
+#endif
 
     case '.':
       if (!is_part_of_name (*input_line_pointer))
@@ -1159,15 +1179,15 @@ operand (expressionP)
        {
          goto isname;
        }
+
     case ',':
-    case '\n':
-    case '\0':
     eol:
       /* can't imagine any other kind of operand */
       expressionP->X_op = O_absent;
       input_line_pointer--;
       break;
 
+#ifdef TC_M68K
     case '%':
       if (! flag_m68k_mri)
        goto de_fault;
@@ -1197,11 +1217,12 @@ operand (expressionP)
 
       current_location (expressionP);
       break;
+#endif
 
     default:
+#ifdef TC_M68K
     de_fault:
-      if (is_end_of_line[(unsigned char) c])
-       goto eol;
+#endif
       if (is_name_beginner (c))        /* here if did not begin with a digit */
        {
          /*
@@ -1560,6 +1581,9 @@ operator ()
 
   c = *input_line_pointer & 0xff;
 
+  if (is_end_of_line[c])
+    return O_illegal;
+
   switch (c)
     {
     default:
@@ -1733,6 +1757,13 @@ expr (rankarg, resultP)
        }
 
       /* Optimize common cases.  */
+#ifdef md_optimize_expr
+      if (md_optimize_expr (resultP, op_left, &right))
+       {
+         /* skip */;
+       }
+      else
+#endif
       if (op_left == O_add && right.X_op == O_constant)
        {
          /* X + constant.  */
This page took 0.027578 seconds and 4 git commands to generate.