/* tc-i386.c -- Assemble Intel syntax code for ix86/x86-64
- Copyright 2009, 2010
- Free Software Foundation, Inc.
+ Copyright (C) 2009-2015 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#define O_xmmword_ptr O_md21
/* ymmword ptr X_add_symbol */
#define O_ymmword_ptr O_md20
+/* zmmword ptr X_add_symbol */
+#define O_zmmword_ptr O_md19
static struct
{
I386_TYPE(oword, 16),
I386_TYPE(xmmword, 16),
I386_TYPE(ymmword, 32),
+ I386_TYPE(zmmword, 64),
#undef I386_TYPE
{ "near", O_near_ptr, { 0xff04, 0xff02, 0xff08 } },
{ "far", O_far_ptr, { 0xff06, 0xff05, 0xff06 } },
static INLINE void i386_intel_fold (expressionS *e, symbolS *sym)
{
+ expressionS *exp = symbol_get_value_expression (sym);
if (S_GET_SEGMENT (sym) == absolute_section)
{
offsetT val = e->X_add_number;
- *e = *symbol_get_value_expression (sym);
+ *e = *exp;
e->X_add_number += val;
}
else
{
+ if (exp->X_op == O_symbol
+ && strcmp (S_GET_NAME (exp->X_add_symbol),
+ GLOBAL_OFFSET_TABLE_NAME) == 0)
+ sym = exp->X_add_symbol;
e->X_add_symbol = sym;
e->X_op_symbol = NULL;
e->X_op = O_symbol;
}
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
+ || i386_regtab[reg_num].reg_type.bitfield.regzmm))
+ 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
+ || current_templates->start->base_opcode == 0xf30f1b /* bndmk */
+ || (current_templates->start->base_opcode & ~1) == 0x0f1a /* bnd{ld,st}x */
+ || 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 */
- intel_state.index = i386_regtab + REGNAM_EAX + 4;
+ intel_state.index = i386_regtab + REGNAM_EAX + ESP_REG_NUM;
}
return 2;
}
if (!i386_intel_simplify_symbol (e->X_add_symbol)
|| !i386_intel_check(the_reg, intel_state.base,
intel_state.index))
- return 0;;
+ return 0;
}
if (!intel_state.in_offset)
++intel_state.in_bracket;
case O_oword_ptr:
case O_xmmword_ptr:
case O_ymmword_ptr:
+ case O_zmmword_ptr:
case O_near_ptr:
case O_far_ptr:
if (intel_state.op_modifier == O_absent)
if (this_operand >= 0 && intel_state.in_bracket)
{
expressionS *scale = NULL;
-
- if (intel_state.index)
- --scale;
+ int has_index = (intel_state.index != NULL);
if (!intel_state.in_scale++)
intel_state.scale_factor = 1;
ret = i386_intel_simplify_symbol (e->X_add_symbol);
- if (ret && !scale && intel_state.index)
+ if (ret && !has_index && intel_state.index)
scale = symbol_get_value_expression (e->X_op_symbol);
if (ret)
ret = i386_intel_simplify_symbol (e->X_op_symbol);
- if (ret && !scale && intel_state.index)
+ if (ret && !scale && !has_index && intel_state.index)
scale = symbol_get_value_expression (e->X_add_symbol);
- if (ret && scale && (scale + 1))
+ if (ret && scale)
{
resolve_expression (scale);
if (scale->X_op != O_constant
break;
default:
/* esp is invalid as index */
- intel_state.index = i386_regtab + REGNAM_EAX + 4;
+ intel_state.index = i386_regtab + REGNAM_EAX + ESP_REG_NUM;
break;
}
char suffix = 0;
int ret;
+ /* Handle vector immediates. */
+ if (RC_SAE_immediate (operand_string))
+ return 1;
+
/* Initialize state structure. */
intel_state.op_modifier = O_absent;
intel_state.is_mem = 0;
intel_syntax = 1;
SKIP_WHITESPACE ();
+
+ /* Handle vector operations. */
+ if (*input_line_pointer == '{')
+ {
+ char *end = check_VecOperations (input_line_pointer, NULL);
+ if (end)
+ input_line_pointer = end;
+ else
+ ret = 0;
+ }
+
if (!is_end_of_line[(unsigned char) *input_line_pointer])
{
as_bad (_("junk `%s' after expression"), input_line_pointer);
suffix = YMMWORD_MNEM_SUFFIX;
break;
+ case O_zmmword_ptr:
+ i.types[this_operand].bitfield.zmmword = 1;
+ suffix = ZMMWORD_MNEM_SUFFIX;
+ break;
+
case O_far_ptr:
suffix = LONG_DOUBLE_MNEM_SUFFIX;
/* FALLTHROUGH */
|| intel_state.is_mem)
{
/* Memory operand. */
- if (i.mem_operands
+ if ((int) i.mem_operands
>= 2 - !current_templates->start->opcode_modifier.isstring)
{
/* Handle