public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: hjl@varesearch.com (H.J. Lu)
To: binutils@sourceware.cygnus.com
Subject: An i386 fp register name patch
Date: Fri, 27 Aug 1999 12:18:00 -0000	[thread overview]
Message-ID: <19990827191842.315213FC1@varesearch.com> (raw)

Here is a patch to handle spaces ina i386 FP register names. I am
enclosing a testcase here.

----
	fxch   %st( 1)
	fxch   %st( 1 )
	fxch   %st ( 1 )
	fxch   %st (1)
	fxch   %st(1)
	fxch   % st(1)
	fxch   %           st(1)
----

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
--
Fri Aug 27 11:31:30 1999  H.J. Lu  (hjl@gnu.org)

	* config/tc-i386.c (i386_extract_reg): New function. Handle
	spaces in FP register names.
	(i386_is_reg): Use it.
	(parse_register): Likewise.

Index: config/tc-i386.c
===================================================================
RCS file: /work/cvs/gnu/binutils/gas/config/tc-i386.c,v
retrieving revision 1.5
diff -u -p -r1.5 tc-i386.c
--- config/tc-i386.c	1999/08/21 18:02:59	1.5
+++ config/tc-i386.c	1999/08/27 18:24:16
@@ -2507,25 +2507,57 @@ md_assemble (line)
   }
 }
 \f
+static char * i386_extract_reg PARAMS ((char *, char *, int));
+
+static char *
+i386_extract_reg (s, reg, len)
+     char *s;
+     char *reg;
+     int len;
+{
+  register char *p;
+
+  while (is_space_char (*s))
+    ++s;
+
+  p = reg;
+  while (register_chars[(unsigned char) *s] != '\0'
+	  || is_space_char (*s))
+    {
+      if (p >= &reg [2] && tolower (reg [0]) == 's'
+	  && tolower (reg [1]) == 't'
+	  && (p == &reg [2]
+	      || (reg [2] == '('
+		  && (p == &reg [3]
+		      || (*(p - 1) >= '0' && *(p - 1) <= '9')))))
+	/*
+	  1. %st (1).
+	  2. %st ( 1).
+	  3. %st ( 1 ).
+	*/
+      while (is_space_char (*s))
+	++s;
+
+      if ((*p++ = register_chars[(unsigned char) *s++]) == '\0')
+        break;
+      if (p >= reg + len)
+        return NULL;
+    }
+
+  *p++ = register_chars[(unsigned char) *s++];
+  return (p >= reg + len) ? NULL: s;
+}
+
 static int i386_is_reg PARAMS ((char *));
 
 static int
 i386_is_reg (reg_string)
      char *reg_string;
 {
-  register char *s = reg_string;
-  register char *p;
   char reg_name_given[MAX_REG_NAME_SIZE + 1];
-
-  if (is_space_char (*s))
-    ++s;
 
-  p = reg_name_given;
-  while ((*p++ = register_chars[(unsigned char) *s++]) != '\0')
-    if (p >= reg_name_given + MAX_REG_NAME_SIZE)
-      return 0;
-
-  if (!hash_find (reg_hash, reg_name_given))
+  if (!i386_extract_reg (reg_string, reg_name_given, MAX_REG_NAME_SIZE)
+      || !hash_find (reg_hash, reg_name_given))
     return 0;
   else
     return 1;
@@ -4137,7 +4169,6 @@ parse_register (reg_string, end_op)
      char **end_op;
 {
   register char *s = reg_string;
-  register char *p;
   char reg_name_given[MAX_REG_NAME_SIZE + 1];
   const reg_entry *r;
 
@@ -4145,23 +4176,16 @@ parse_register (reg_string, end_op)
   if (*s == REGISTER_PREFIX)
     ++s;
 
-  if (is_space_char (*s))
-    ++s;
-
-  p = reg_name_given;
-  while ((*p++ = register_chars[(unsigned char) *s++]) != '\0')
+  s = i386_extract_reg (s, reg_name_given, MAX_REG_NAME_SIZE);
+  if (s == NULL)
     {
-      if (p >= reg_name_given + MAX_REG_NAME_SIZE)
+      if (!allow_naked_reg)
 	{
-	  if (!allow_naked_reg)
-	    {
-	      *p = '\0';
-	      as_bad (_("bad register name `%s'"), reg_name_given);
-	    }
-	  return (const reg_entry *) NULL;
+	  reg_name_given [MAX_REG_NAME_SIZE] = '\0';
+	  as_bad (_("bad register name `%s'"), reg_name_given);
 	}
+      return (const reg_entry *) NULL;
     }
-
   *end_op = s - 1;
 
   r = (const reg_entry *) hash_find (reg_hash, reg_name_given);

             reply	other threads:[~1999-08-27 12:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-27 12:18 H.J. Lu [this message]
1999-08-28  6:05 ` Alan Modra
1999-08-28  8:38   ` H.J. Lu
1999-08-29 14:05   ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990827191842.315213FC1@varesearch.com \
    --to=hjl@varesearch.com \
    --cc=binutils@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).