MASM doesn't support the separate operand form; the modifier belongs after the instruction instead. Accept this form alongside the original (now legacy) one. Short of having access to a MASM version to actually check in how far "after the instruction" is a precise statement in their documentation, allow both that and the SDM mandated form where the modifier is on the last register operand (with a possible immediate operand following). Sadly the split out function, at least for the time being, needs to cast away constness at some point, as the two callers disagree in this regard. Adjust some, but not all of the testcases. --- Presenting only the non-testsuite changes inline. See attachment for the full patch. --- a/gas/config/tc-i386-intel.c +++ b/gas/config/tc-i386-intel.c @@ -600,6 +600,7 @@ i386_intel_operand (char *operand_string segT exp_seg; expressionS exp, *expP; char suffix = 0; + bool rc_sae_modifier = i.rounding.type != rc_none && i.rounding.modifier; int ret; /* Handle vector immediates. */ @@ -898,7 +899,9 @@ i386_intel_operand (char *operand_string i.types[this_operand].bitfield.unspecified = 0; ++i.reg_operands; - if (i.rounding.type != rc_none && temp.bitfield.class != Reg) + if ((i.rounding.type != rc_none && !i.rounding.modifier + && temp.bitfield.class != Reg) + || rc_sae_modifier) { unsigned int j; --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -371,6 +371,9 @@ struct _i386_insn rz, saeonly } type; + /* In Intel syntax the operand modifier form is supposed to be used, but + we continue to accept the immediate forms as well. */ + bool modifier; } rounding; /* Broadcasting attributes. @@ -10624,6 +10627,32 @@ pe_directive_secidx (int dummy ATTRIBUTE } #endif +/* Handle Rounding Control / SAE specifiers. */ + +static char * +RC_SAE_specifier (const char *pstr) +{ + unsigned int j; + + for (j = 0; j < ARRAY_SIZE (RC_NamesTable); j++) + { + if (!strncmp (pstr, RC_NamesTable[j].name, RC_NamesTable[j].len)) + { + if (i.rounding.type != rc_none) + { + as_bad (_("duplicated `{%s}'"), RC_NamesTable[j].name); + return NULL; + } + + i.rounding.type = RC_NamesTable[j].type; + + return (char *)(pstr + RC_NamesTable[j].len); + } + } + + return NULL; +} + /* Handle Vector operations. */ static char * @@ -10745,6 +10774,9 @@ check_VecOperations (char *op_string) op_string++; } + else if (intel_syntax + && (op_string = RC_SAE_specifier (op_string)) != NULL) + i.rounding.modifier = true; else goto unknown_vec_op; @@ -11408,32 +11440,13 @@ i386_index_check (const char *operand_st static int RC_SAE_immediate (const char *imm_start) { - unsigned int match_found, j; const char *pstr = imm_start; if (*pstr != '{') return 0; - pstr++; - match_found = 0; - for (j = 0; j < ARRAY_SIZE (RC_NamesTable); j++) - { - if (!strncmp (pstr, RC_NamesTable[j].name, RC_NamesTable[j].len)) - { - if (i.rounding.type != rc_none) - { - as_bad (_("duplicated `%s'"), imm_start); - return 0; - } - - i.rounding.type = RC_NamesTable[j].type; - - pstr += RC_NamesTable[j].len; - match_found = 1; - break; - } - } - if (!match_found) + pstr = RC_SAE_specifier (pstr + 1); + if (pstr == NULL) return 0; if (*pstr++ != '}')