New elseif directive has been added.
authorTimothy Wall <twall@alum.mit.edu>
Tue, 8 Feb 2000 14:13:57 +0000 (14:13 +0000)
committerTimothy Wall <twall@alum.mit.edu>
Tue, 8 Feb 2000 14:13:57 +0000 (14:13 +0000)
gas/NEWS
gas/cond.c
gas/doc/as.texinfo
gas/read.c
gas/read.h

index 411734aede9f364da09c3596a8c267d08430f9df..2c861b03203da1cfd10db95a958566827b21f85a 100644 (file)
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -2,6 +2,10 @@
 
 Changes in 2.10:
 
+Support for numbers with suffixes.
+
+New .elseif pseudo-op added.
+
 New --fatal-warnings option.
 
 picoJava architecture support added.
index 943c9f6bf8295b30a61465edcd6a1d91a8717518..a0e6e41a1b88c2e14807b06425a4dea29e23aa08 100644 (file)
@@ -246,6 +246,86 @@ s_ifc (arg)
   demand_empty_rest_of_line ();
 }
 
+void 
+s_elseif (arg)
+     int arg;
+{
+  expressionS operand;
+  int t;
+
+  if (current_cframe == NULL)
+    {
+      as_bad (_("\".elseif\" without matching \".if\" - ignored"));
+
+    }
+  else if (current_cframe->else_seen)
+    {
+      as_bad (_("\".elseif\" after \".else\" - ignored"));
+      as_bad_where (current_cframe->else_file_line.file,
+                   current_cframe->else_file_line.line,
+                   _("here is the previous \"else\""));
+      as_bad_where (current_cframe->if_file_line.file,
+                   current_cframe->if_file_line.line,
+                   _("here is the previous \"if\""));
+    }
+  else
+    {
+      as_where (&current_cframe->else_file_line.file,
+               &current_cframe->else_file_line.line);
+
+      if (!current_cframe->dead_tree)
+       {
+         current_cframe->ignoring = !current_cframe->ignoring;
+         if (LISTING_SKIP_COND ())
+           {
+             if (! current_cframe->ignoring)
+               listing_list (1);
+             else
+               listing_list (2);
+           }
+       }                       /* if not a dead tree */
+    }                          /* if error else do it */
+
+
+  SKIP_WHITESPACE ();          /* Leading whitespace is part of operand. */
+
+  if (current_cframe != NULL && current_cframe->ignoring)
+    {
+      operand.X_add_number = 0;
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+  else
+    {
+      expression (&operand);
+      if (operand.X_op != O_constant)
+       as_bad (_("non-constant expression in \".elseif\" statement"));
+    }
+  
+  switch ((operatorT) arg)
+    {
+    case O_eq: t = operand.X_add_number == 0; break;
+    case O_ne: t = operand.X_add_number != 0; break;
+    case O_lt: t = operand.X_add_number < 0; break;
+    case O_le: t = operand.X_add_number <= 0; break;
+    case O_ge: t = operand.X_add_number >= 0; break;
+    case O_gt: t = operand.X_add_number > 0; break;
+    default:
+      abort ();
+      return;
+    }
+
+  current_cframe->ignoring = current_cframe->dead_tree || ! t;
+
+  if (LISTING_SKIP_COND ()
+      && current_cframe->ignoring
+      && (current_cframe->previous_cframe == NULL
+         || ! current_cframe->previous_cframe->ignoring))
+    listing_list (2);
+
+  demand_empty_rest_of_line ();
+}
+
 void 
 s_endif (arg)
      int arg ATTRIBUTE_UNUSED;
index 0f342fe7293e94ff379ee18b28de66f5f70e8372..9e89cee3d3c316531e106be4068669a2ef70d442 100644 (file)
@@ -3109,6 +3109,7 @@ Some machine configurations provide additional directives.
 * Double::                      @code{.double @var{flonums}}
 * Eject::                       @code{.eject}
 * Else::                        @code{.else}
+* Elseif::                      @code{.elseif}
 * End::                                @code{.end}
 @ifset COFF
 * Endef::                       @code{.endef}
@@ -3466,6 +3467,14 @@ assembly; @pxref{If,,@code{.if}}.  It marks the beginning of a section
 of code to be assembled if the condition for the preceding @code{.if}
 was false.
 
+@node Elseif
+@section @code{.elseif}
+
+@cindex @code{elseif} directive
+@code{.elseif} is part of the @code{@value{AS}} support for conditional
+assembly; @pxref{If,,@code{.if}}.  It is shorthand for beginning a new
+@code{.if} block that would otherwise fill the entire @code{.else} section.
+
 @node End
 @section @code{.end}
 
@@ -3694,6 +3703,8 @@ considered part of the source program being assembled if the argument
 the conditional section of code must be marked by @code{.endif}
 (@pxref{Endif,,@code{.endif}}); optionally, you may include code for the
 alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}).
+If you have several conditions to check, @code{.elseif} may be used to avoid
+nesting blocks if/else within each subsequent @code{.else} block.
 
 The following variants of @code{.if} are also supported:
 @table @code
index 821c074837bc6fb3538f5d35ec5fd96142ee9461..e8711663f6238b51604d95043cf77618677cbf60 100644 (file)
@@ -306,6 +306,7 @@ static const pseudo_typeS potable[] =
   {"eject", listing_eject, 0}, /* Formfeed listing */
   {"else", s_else, 0},
   {"elsec", s_else, 0},
+  {"elseif", s_elseif, (int) O_ne},
   {"end", s_end, 0},
   {"endc", s_endif, 0},
   {"endfunc", s_func, 1},
index ae3b103686ba8eb91f00bc7756cba3d15b79db32..9d080bfb23c90875bc509b2d936c5b4cc4f24218 100644 (file)
@@ -128,6 +128,7 @@ extern void s_comm PARAMS ((int));
 extern void s_data PARAMS ((int));
 extern void s_desc PARAMS ((int));
 extern void s_else PARAMS ((int arg));
+extern void s_elseif PARAMS ((int arg));
 extern void s_end PARAMS ((int arg));
 extern void s_endif PARAMS ((int arg));
 extern void s_err PARAMS ((int));