public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* A gas patch
@ 1998-03-16  8:08 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 1998-03-16  8:08 UTC (permalink / raw)
  To: H.J. Lu

Here is a patch you might like to include in your next release of
binutils for linux.  I've sent it off to Ian Taylor, but he's on
vacation for another week, so it may not get into the official sources
for a while.

1998-03-15  Alan Modra  <alan@SPRI.Levels.UniSA.Edu.Au>

	* config/tc-i386.c (md_assemble):   Add no_word_prefix_needed
	variable and don't emit a data-size prefix byte for segment
	register or control/debug register moves.  Check for incorrect
	suffix on these instructions too.

diff -ur gas-980310/gas/config/tc-i386.c gas/gas/config/tc-i386.c
--- gas-980310/gas/config/tc-i386.c	Tue Mar  3 19:40:21 1998
+++ gas/gas/config/tc-i386.c	Sun Mar 15 15:47:46 1998
@@ -1093,6 +1093,7 @@
     expressionS *exp;
     unsigned int overlap2;
     unsigned int found_reverse_match;
+    int no_word_prefix_needed = 0;
 
     overlap0 = overlap1 = overlap2 = found_reverse_match = 0;
     for (t = current_templates->start;
@@ -1276,6 +1277,22 @@
     if (overlap0 & Imm1)
       i.imm_operands = 0;	/* kludge for shift insns */
 
+    if (t->operand_types[0] & (SReg3|SReg2|Control|Debug|Test))
+      {
+	no_word_prefix_needed = 1;
+	if (i.suffix)
+	  {
+	    if ((i.suffix != WORD_OPCODE_SUFFIX
+		 && (t->operand_types[0] & (SReg3|SReg2)))
+		|| (i.suffix != DWORD_OPCODE_SUFFIX
+		    && (t->operand_types[0] & (Control|Debug|Test))))
+	      {
+		as_bad ("register does not match opcode suffix");
+		return;
+	      }
+	  }
+      }
+
     if (found_reverse_match)
       {
 	unsigned int save;
@@ -1301,7 +1318,8 @@
 	  t->base_opcode |= W;
 	/* Now select between word & dword operations via the
 				   operand size prefix. */
-	if ((i.suffix == WORD_OPCODE_SUFFIX) ^ flag_16bit_code)
+	if ((i.suffix == WORD_OPCODE_SUFFIX) != flag_16bit_code
+	    && !no_word_prefix_needed)
 	  {
 	    if (i.prefixes == MAX_PREFIXES)
 	      {


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-03-16  8:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-16  8:08 A gas patch Alan Modra

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).