MASM accepts ESP/RSP being specified second in a memory address
authorJan Beulich <jbeulich@novell.com>
Wed, 25 Jul 2012 11:34:49 +0000 (11:34 +0000)
committerJan Beulich <jbeulich@novell.com>
Wed, 25 Jul 2012 11:34:49 +0000 (11:34 +0000)
operand, by silently making it the base register despite not being
specified first.

Consequently, we also permit an xmm/ymm index to be specified first
(possibly alone), nevertheless putting it in as index register.

2012-07-24  Jan Beulich <jbeulich@suse.com>

* config/tc-i386-intel.c (i386_intel_simplify_register): Handle
xmm/ymm index register being specified first as well as esp/rsp
base register being specified last in a memory operand.

gas/ChangeLog
gas/config/tc-i386-intel.c

index 445e36d3dafb52ba99e655e2646b8fdb8e21fd3d..2d62c413410ff9e3c86ce47d03cb991637573ccd 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-24  Jan Beulich <jbeulich@suse.com>
+
+       * config/tc-i386-intel.c (i386_intel_simplify_register): Handle
+       xmm/ymm index register being specified first as well as esp/rsp
+       base register being specified last in a memory operand.
+
 2012-07-24  Jan Beulich <jbeulich@suse.com>
 
        * config/tc-i386-intel.c (i386_intel_simplify_register):
index 919f27ca300783b33189c57fdd1929f770ad3c9b..099cbfcd9479af615c9d1eee4cee59444f9338ce 100644 (file)
@@ -278,10 +278,24 @@ i386_intel_simplify_register (expressionS *e)
        }
       i.op[this_operand].regs = i386_regtab + reg_num;
     }
+  else if (!intel_state.index
+          && (i386_regtab[reg_num].reg_type.bitfield.regxmm
+              || i386_regtab[reg_num].reg_type.bitfield.regymm))
+    intel_state.index = i386_regtab + reg_num;
   else if (!intel_state.base && !intel_state.in_scale)
     intel_state.base = i386_regtab + reg_num;
   else if (!intel_state.index)
-    intel_state.index = i386_regtab + reg_num;
+    {
+      if (intel_state.in_scale
+         || i386_regtab[reg_num].reg_type.bitfield.baseindex)
+       intel_state.index = i386_regtab + reg_num;
+      else
+       {
+         /* Convert base to index and make ESP/RSP the base.  */
+         intel_state.index = intel_state.base;
+         intel_state.base = i386_regtab + reg_num;
+       }
+    }
   else
     {
       /* esp is invalid as index */