]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-i386.c
x86: correct MPX insn w/o base or index encoding in 16-bit mode
[thirdparty/binutils-gdb.git] / gas / config / tc-i386.c
index e36afa8024dcfd704b95d23927438cfca65daf4a..1c9388b1bdcb3e69185bbd9c16d1216b7f44866e 100644 (file)
@@ -10359,6 +10359,21 @@ i386_addressing_mode (void)
 
   if (i.prefix[ADDR_PREFIX])
     addr_mode = flag_code == CODE_32BIT ? CODE_16BIT : CODE_32BIT;
+  else if (flag_code == CODE_16BIT
+          && current_templates->start->cpu_flags.bitfield.cpumpx
+          /* Avoid replacing the "16-bit addressing not allowed" diagnostic
+             from md_assemble() by "is not a valid base/index expression"
+             when there is a base and/or index.  */
+          && !i.types[this_operand].bitfield.baseindex)
+    {
+      /* MPX insn memory operands with neither base nor index must be forced
+        to use 32-bit addressing in 16-bit mode.  */
+      addr_mode = CODE_32BIT;
+      i.prefix[ADDR_PREFIX] = ADDR_PREFIX_OPCODE;
+      ++i.prefixes;
+      gas_assert (!i.types[this_operand].bitfield.disp16);
+      gas_assert (!i.types[this_operand].bitfield.disp32);
+    }
   else
     {
       addr_mode = flag_code;