* config/tc-m68k.c (parse_mri_control_operand): Change leftstop
authorIan Lance Taylor <ian@airs.com>
Tue, 19 Sep 1995 15:36:38 +0000 (15:36 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 19 Sep 1995 15:36:38 +0000 (15:36 +0000)
and rightstop to not be const.
(parse_mri_control_expression): Likewise.
(build_mri_control_operand): Likewise.  Use m68k_ip_op to examine
the operand, not m68k_reg_parse.
(s_mri_if): In MRI mode, stop at the first '*'.
(s_mri_while): Likewise.
(s_mri_else): In MRI mode, ignore trailing characters.
(s_mri_endi, s_mri_break, s_mri_next, s_mri_for): Likewise.
(s_mri_endf, s_mri_repeat, s_mri_until, s_mri_endw): Likewise.
* config/m68k-parse.y: Revert yesterday's change.
* config/m68k-parse.h: Revert yesterday's change.

gas/ChangeLog
gas/config/tc-m68k.c

index 27d5e78574665be5b5a85c2a06b962e5b8ae931b..426e5d56da797e6fed1c4d5a5c9d25334218d6fa 100644 (file)
@@ -1,3 +1,18 @@
+Tue Sep 19 11:31:31 1995  Ian Lance Taylor  <ian@cygnus.com>
+
+       * config/tc-m68k.c (parse_mri_control_operand): Change leftstop
+       and rightstop to not be const.
+       (parse_mri_control_expression): Likewise.
+       (build_mri_control_operand): Likewise.  Use m68k_ip_op to examine
+       the operand, not m68k_reg_parse.
+       (s_mri_if): In MRI mode, stop at the first '*'.
+       (s_mri_while): Likewise.
+       (s_mri_else): In MRI mode, ignore trailing characters.
+       (s_mri_endi, s_mri_break, s_mri_next, s_mri_for): Likewise.
+       (s_mri_endf, s_mri_repeat, s_mri_until, s_mri_endw): Likewise.
+       * config/m68k-parse.y: Revert yesterday's change.
+       * config/m68k-parse.h: Revert yesterday's change.
+
 Mon Sep 18 15:22:28 1995  Ian Lance Taylor  <ian@cygnus.com>
 
        * config/tc-m68k.c (parse_mri_control_operand): Change leftstart
index 652b54af18a5cd5a9c22a5e8ed24b2749eb76d7f..01200f0243c828d80643fed49d31aa5b17c7b85c 100644 (file)
@@ -4708,12 +4708,12 @@ static struct mri_control_info *push_mri_control
 static void pop_mri_control PARAMS ((void));
 static int parse_mri_condition PARAMS ((int *));
 static int parse_mri_control_operand
-  PARAMS ((int *, char **, const char **, char **, const char **));
+  PARAMS ((int *, char **, char **, char **, char **));
 static int swap_mri_condition PARAMS ((int));
 static int reverse_mri_condition PARAMS ((int));
 static void build_mri_control_operand
-  PARAMS ((int, int, char *, const char *, char *, const char *,
-          const char *, const char *, int));
+  PARAMS ((int, int, char *, char *, char *, char *, const char *,
+          const char *, int));
 static void parse_mri_control_expression
   PARAMS ((char *, int, const char *, const char *, int));
 
@@ -4810,9 +4810,9 @@ static int
 parse_mri_control_operand (pcc, leftstart, leftstop, rightstart, rightstop)
      int *pcc;
      char **leftstart;
-     const char **leftstop;
+     char **leftstop;
      char **rightstart;
-     const char **rightstop;
+     char **rightstop;
 {
   char *s;
 
@@ -4937,52 +4937,52 @@ build_mri_control_operand (qual, cc, leftstart, leftstop, rightstart,
      int qual;
      int cc;
      char *leftstart;
-     const char *leftstop;
+     char *leftstop;
      char *rightstart;
-     const char *rightstop;
+     char *rightstop;
      const char *truelab;
      const char *falselab;
      int extent;
 {
-  int leftreg, rightreg;
   char *buf;
   char *s;
 
-  /* See which sides of the comparison are plain registers.  */
-  if (leftstart == NULL)
-    leftreg = 0;
-  else
-    {
-      char *l;
-
-      l = leftstart;
-      leftreg = m68k_reg_parse (&l) != 0;
-    }
-  if (rightstart == NULL)
-    rightreg = 0;
-  else
+  if (leftstart != NULL)
     {
-      char *l;
-
-      l = rightstart;
-      rightreg = m68k_reg_parse (&l) != 0;
-    }
+      struct m68k_op leftop, rightop;
+      char c;
 
-  /* Swap the compare operands, if necessary, to produce a legal m68k
-     compare instruction.  */
-  if ((leftreg && ! rightreg)
-      || (rightstart != NULL && *rightstart == '#'))
-    {
-      char *temp;
-      const char *tempc;
-
-      cc = swap_mri_condition (cc);
-      temp = leftstart;
-      leftstart = rightstart;
-      rightstart = temp;
-      tempc = leftstop;
-      leftstop = rightstop;
-      rightstop = tempc;
+      /* Swap the compare operands, if necessary, to produce a legal
+        m68k compare instruction.  Comparing a register operand with
+        a non-register operand requires the register to be on the
+        right (cmp, cmpa).  Comparing an immediate value with
+        anything requires the immediate value to be on the left
+        (cmpi).  */
+
+      c = *leftstop;
+      *leftstop = '\0';
+      (void) m68k_ip_op (leftstart, &leftop);
+      *leftstop = c;
+
+      c = *rightstop;
+      *rightstop = '\0';
+      (void) m68k_ip_op (rightstart, &rightop);
+      *rightstop = c;
+
+      if (rightop.mode == IMMED
+         || ((leftop.mode == DREG || leftop.mode == AREG)
+             && (rightop.mode != DREG && rightop.mode != AREG)))
+       {
+         char *temp;
+
+         cc = swap_mri_condition (cc);
+         temp = leftstart;
+         leftstart = rightstart;
+         rightstart = temp;
+         temp = leftstop;
+         leftstop = rightstop;
+         rightstop = temp;
+       }
     }
 
   if (truelab == NULL)
@@ -5044,9 +5044,9 @@ parse_mri_control_expression (stop, qual, truelab, falselab, extent)
   int c;
   int cc;
   char *leftstart;
-  const char *leftstop;
+  char *leftstop;
   char *rightstart;
-  const char *rightstop;
+  char *rightstop;
 
   c = *stop;
   *stop = '\0';
@@ -5154,7 +5154,8 @@ s_mri_if (qual)
   /* A structured control directive must end with THEN with an
      optional qualifier.  */
   s = input_line_pointer;
-  while (! is_end_of_line[(unsigned char) *s])
+  while (! is_end_of_line[(unsigned char) *s]
+        && (! flag_mri || *s != '*'))
     ++s;
   --s;
   while (s > input_line_pointer && (*s == ' ' || *s == '\t'))
@@ -5205,6 +5206,12 @@ s_mri_if (qual)
   else
     input_line_pointer = s + 1;
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5261,6 +5268,12 @@ s_mri_else (qual)
 
   colon (mri_control_stack->next);
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5287,6 +5300,12 @@ s_mri_endi (ignore)
 
   pop_mri_control ();
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5320,6 +5339,12 @@ s_mri_break (extent)
   md_assemble (buf);
   free (buf);
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5353,6 +5378,12 @@ s_mri_next (extent)
   md_assemble (buf);
   free (buf);
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5580,6 +5611,12 @@ s_mri_for (qual)
   *s = '\0';
   n->incr = buf;
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5610,6 +5647,12 @@ s_mri_endf (ignore)
 
   pop_mri_control ();
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5623,6 +5666,11 @@ s_mri_repeat (ignore)
 
   n = push_mri_control (mri_repeat);
   colon (n->top);
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
   demand_empty_rest_of_line ();
 }
 
@@ -5654,6 +5702,12 @@ s_mri_until (qual)
 
   input_line_pointer = s;
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5668,7 +5722,8 @@ s_mri_while (qual)
   struct mri_control_info *n;
 
   s = input_line_pointer;
-  while (! is_end_of_line[(unsigned char) *s])
+  while (! is_end_of_line[(unsigned char) *s]
+        && (! flag_mri || *s != '*'))
     s++;
   --s;
   while (*s == ' ' || *s == '\t')
@@ -5695,6 +5750,12 @@ s_mri_while (qual)
   if (*input_line_pointer == '.')
     input_line_pointer += 2;
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 
@@ -5723,6 +5784,12 @@ s_mri_endw (ignore)
 
   pop_mri_control ();
 
+  if (flag_mri)
+    {
+      while (! is_end_of_line[(unsigned char) *input_line_pointer])
+       ++input_line_pointer;
+    }
+
   demand_empty_rest_of_line ();
 }
 \f
This page took 0.035686 seconds and 4 git commands to generate.