i386 "andl $65535,%eax" problem

Alan Modra alan@linuxcare.com.au
Mon Apr 3 04:40:00 GMT 2000


The fix wasn't too bad after all.  BTW, this bug would only bite if
a) in .code16 (or .code16gcc) mode and 
b) assembling a 32-bit instruction with an inferred operand size prefix,
c) with an immediate in the range 0xff80 to 0xffff.

ie. You won't hit this one with normal gcc output.


gas/ChangeLog
	* config/tc-i386.c (i386_immediate): Don't assume a constant
	immediate is necessarily 16 bits when in 16 bit code mode.
	(md_assemble): Instead set guess_suffix here after we have checked
	registers.

Index: config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.41
diff -u -p -r1.41 tc-i386.c
--- tc-i386.c	2000/03/26 14:13:02	1.41
+++ tc-i386.c	2000/04/03 11:17:55
@@ -1331,6 +1331,9 @@ md_assemble (line)
 		  break;
 		}
 	  }
+	else if (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0))
+	  guess_suffix = WORD_MNEM_SUFFIX;
+
 	for (op = i.operands; --op >= 0; )
 	  if ((i.types[op] & Imm)
 	      && i.op[op].imms->X_op == O_constant)
@@ -2584,10 +2587,7 @@ i386_immediate (imm_start)
 
   if (exp->X_op == O_constant)
     {
-      int bigimm = Imm32;
-      if (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0))
-	bigimm = Imm16;
-      i.types[this_operand] |= bigimm;
+      i.types[this_operand] |= Imm32;	/* Size it properly later.  */
     }
 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
   else if (

-- 
Linuxcare.  Support for the Revolution.



More information about the Binutils mailing list