This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Thumb32 assembler (12/69)


Introduce a generic facility for skipping single characters, which
is primarily useful for square brackets.

zw

	* config/tc-arm.c (skip_past_comma): Rename skip_past_char.
	Take second argument which is character to skip.  Simplify
	relying on input scrubber.
	(char_or_fail): New macro.
	(comma_or_fail, skip_past_comma): Redefine in terms of
	char_or_fail and skip_past_char.
	(do_ldrex, do_strex, do_swap, do_fpa_ldmstm, do_mav_ldst):
	Use char_or_fail.

===================================================================
Index: gas/config/tc-arm.c
--- gas/config/tc-arm.c	(revision 13)
+++ gas/config/tc-arm.c	(revision 14)
@@ -839,6 +839,8 @@
    value.  */
 #define is_immediate_prefix(C) ((C) == '#' || (C) == '$')
 
+/* Separator character handling.  */
+
 #define skip_whitespace(str)  do { if (*(str) == ' ') ++(str); } while (0)
 
 static void
@@ -848,35 +850,30 @@
     inst.error = _("garbage following instruction");
 }
 
-static int
-skip_past_comma (char ** str)
+static inline int
+skip_past_char (char ** str, char c)
 {
-  char * p = * str, c;
-  int comma = 0;
-
-  while ((c = *p) == ' ' || c == ',')
+  if (**str == c)
     {
-      p++;
-      if (c == ',' && comma++)
-	return FAIL;
+      (*str)++;
+      return SUCCESS;
     }
-
-  if (c == '\0')
+  else
     return FAIL;
-
-  *str = p;
-  return comma ? SUCCESS : FAIL;
 }
 
-#define comma_or_fail(str)			\
+#define char_or_fail(str, c)			\
 do {						\
-  if (skip_past_comma (str) == FAIL)		\
+  if (skip_past_char (str, c) == FAIL)		\
     {						\
       inst.error = BAD_ARGS;			\
       return;					\
     }						\
  } while (0)
 
+#define skip_past_comma(str) skip_past_char (str, ',')
+#define comma_or_fail(str) char_or_fail(str, ',')
+
 /* Arithmetic expressions (possibly involving symbols).  */
 
 /* Return TRUE if anything in the expression is a bignum.  */
@@ -5175,23 +5172,10 @@
   reg_nonpc_or_fail (&str, 12);
   comma_or_fail (&str);
 
-  /* Skip past '['.  */
-  if (*str != '[')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
-  str++;
-
+  char_or_fail (&str, '[');
   reg_nonpc_or_fail (&str, 16);
+  char_or_fail (&str, ']');
 
-  /* Skip past ']'.  */
-  if (*str != ']')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
-  str++;
   end_of_line (str);
 }
 
@@ -6311,44 +6295,20 @@
 {
   int rd, rm, rn;
 
-  /* Parse Rd, Rm,.  */
   note_reg_nonpc_or_fail (rd, &str, 12);
   comma_or_fail (&str);
 
   note_reg_nonpc_or_fail (rm, &str, 0);
   comma_or_fail (&str);
-    
-  if (rd == rm)
-    {
-      inst.error = _("Rd equal to Rm or Rn yields unpredictable results");
-      return;
-    }
 
-  /* Skip past '['.  */
-  if (*str != '[')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
-  str++;
-
-  /* Parse Rn.  */
+  char_or_fail (&str, '[');
   note_reg_nonpc_or_fail (rn, &str, 16);
-  if (rd == rn)
-    {
-      inst.error = _("Rd equal to Rm or Rn yields unpredictable results");
-      return;
-    }
+  char_or_fail (&str, ']');
 
-  /* Skip past ']'.  */
-  if (*str != ']')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
-  str++;
-
   end_of_line (str);
+  
+  if (rd == rm || rd == rn)
+    inst.error = _("Rd equal to Rm or Rn yields unpredictable results");
 }
 
 static void
@@ -6362,20 +6322,10 @@
   reg_nonpc_or_fail (&str, 0);
   comma_or_fail (&str);
 
-  if (*str++ != '[')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
-
+  char_or_fail (&str, '[');
   note_reg_nonpc_or_fail (reg, &str, 16);
+  char_or_fail (&str, ']');
 
-  if (*str++ != ']')
-    {
-      inst.error = _("missing ]");
-      return;
-    }
-
   end_of_line (str);
 }
 
@@ -7947,21 +7897,11 @@
 	 [Rn]{!}.  The instruction does not really support stacking or
 	 unstacking, so we have to emulate these by setting appropriate
 	 bits and offsets.  */
-      if (*str != '[')
-	{
-	  inst.error = BAD_ARGS;
-	  return;
-	}
 
-      str++;
+      char_or_fail (&str, '[');
       note_reg_or_fail (reg, &str, 16, REG_TYPE_RN);
-      if (*str != ']')
-	{
-	  inst.error = BAD_ARGS;
-	  return;
-	}
+      char_or_fail (&str, ']');
 
-      str++;
       if (*str == '!')
 	{
 	  write_back = 1;
@@ -8775,11 +8715,8 @@
 
   reg_or_fail (&str, 12, reg0);
   comma_or_fail (&str);
-  if (*str++ != '[')
-    {
-      inst.error = BAD_ARGS;
-      return;
-    }
+
+  char_or_fail (&str, '[');
   reg_or_fail (&str, 16, REG_TYPE_RN);
 
   if (skip_past_comma (&str) == SUCCESS)
@@ -8792,11 +8729,7 @@
       if (inst.error)
 	return;
 
-      if (*str++ != ']')
-	{
-	  inst.error = _("missing ]");
-	  return;
-	}
+      char_or_fail (&str, ']');
 
       if (*str == '!')
 	{
@@ -8807,12 +8740,7 @@
   else
     {
       /* You are here: "], <offset>".  */
-      if (*str++ != ']')
-	{
-	  inst.error = _("missing ]");
-	  return;
-	}
-
+      char_or_fail (&str, ']');
       comma_or_fail (&str);
 
       offset = mav_parse_offset (&str, &negative);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]