1 /* tc-i386.c -- Assemble Intel syntax code for ix86/x86-64
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
24 operatorT op_modifier
; /* Operand modifier. */
25 int is_mem
; /* 1 if operand is memory reference. */
26 int is_indirect
; /* 1 if operand is indirect reference. */
27 int has_offset
; /* 1 if operand has offset. */
28 unsigned int in_offset
; /* >=1 if processing operand of offset. */
29 unsigned int in_bracket
; /* >=1 if processing operand in brackets. */
30 unsigned int in_scale
; /* >=1 if processing multipication operand
32 i386_operand_type reloc_types
; /* Value obtained from lex_got(). */
33 const reg_entry
*base
; /* Base register (if any). */
34 const reg_entry
*index
; /* Index register (if any). */
35 offsetT scale_factor
; /* Accumulated scale factor. */
40 /* offset X_add_symbol */
41 #define O_offset O_md32
42 /* offset X_add_symbol */
43 #define O_short O_md31
44 /* near ptr X_add_symbol */
45 #define O_near_ptr O_md30
46 /* far ptr X_add_symbol */
47 #define O_far_ptr O_md29
48 /* byte ptr X_add_symbol */
49 #define O_byte_ptr O_md28
50 /* word ptr X_add_symbol */
51 #define O_word_ptr O_md27
52 /* dword ptr X_add_symbol */
53 #define O_dword_ptr O_md26
54 /* qword ptr X_add_symbol */
55 #define O_qword_ptr O_md25
56 /* oword ptr X_add_symbol */
57 #define O_oword_ptr O_md24
58 /* fword ptr X_add_symbol */
59 #define O_fword_ptr O_md23
60 /* tbyte ptr X_add_symbol */
61 #define O_tbyte_ptr O_md22
62 /* xmmword ptr X_add_symbol */
63 #define O_xmmword_ptr O_md21
64 /* ymmword ptr X_add_symbol */
65 #define O_ymmword_ptr O_md20
71 unsigned int operands
;
73 const i386_operators
[] =
75 { "and", O_bit_and
, 2 },
81 { "mod", O_modulus
, 2 },
83 { "not", O_bit_not
, 1 },
84 { "offset", O_offset
, 1 },
85 { "or", O_bit_inclusive_or
, 2 },
86 { "shl", O_left_shift
, 2 },
87 { "short", O_short
, 1 },
88 { "shr", O_right_shift
, 2 },
89 { "xor", O_bit_exclusive_or
, 2 },
90 { NULL
, O_illegal
, 0 }
101 #define I386_TYPE(t, n) { #t, O_##t##_ptr, { n, n, n } }
107 I386_TYPE(tbyte
, 10),
108 I386_TYPE(oword
, 16),
109 I386_TYPE(xmmword
, 16),
110 I386_TYPE(ymmword
, 32),
112 { "near", O_near_ptr
, { 0xff04, 0xff02, 0xff08 } },
113 { "far", O_far_ptr
, { 0xff06, 0xff05, 0xff06 } },
114 { NULL
, O_illegal
, { 0, 0, 0 } }
117 operatorT
i386_operator (const char *name
, unsigned int operands
, char *pc
)
128 switch (*input_line_pointer
)
131 ++input_line_pointer
;
134 ++input_line_pointer
;
137 if (this_operand
>= 0 && i
.reloc
[this_operand
] == NO_RELOC
)
140 char *gotfree_input_line
= lex_got (&i
.reloc
[this_operand
],
142 &intel_state
.reloc_types
);
144 if (!gotfree_input_line
)
146 free (gotfree_input_line
);
147 *input_line_pointer
++ = '+';
148 memset (input_line_pointer
, '0', adjust
- 1);
149 input_line_pointer
[adjust
- 1] = ' ';
157 for (j
= 0; i386_operators
[j
].name
; ++j
)
158 if (strcasecmp (i386_operators
[j
].name
, name
) == 0)
160 if (i386_operators
[j
].operands
161 && i386_operators
[j
].operands
!= operands
)
163 return i386_operators
[j
].op
;
166 for (j
= 0; i386_types
[j
].name
; ++j
)
167 if (strcasecmp (i386_types
[j
].name
, name
) == 0)
169 if (i386_types
[j
].name
&& *pc
== ' ')
171 char *pname
= ++input_line_pointer
;
172 char c
= get_symbol_end ();
174 if (strcasecmp (pname
, "ptr") == 0)
178 if (intel_syntax
> 0 || operands
!= 1)
180 return i386_types
[j
].op
;
183 *input_line_pointer
= c
;
184 input_line_pointer
= pname
- 1;
190 static int i386_intel_parse_name (const char *name
, expressionS
*e
)
194 if (! strcmp (name
, "$"))
196 current_location (e
);
200 for (j
= 0; i386_types
[j
].name
; ++j
)
201 if (strcasecmp(i386_types
[j
].name
, name
) == 0)
203 e
->X_op
= O_constant
;
204 e
->X_add_number
= i386_types
[j
].sz
[flag_code
];
205 e
->X_add_symbol
= NULL
;
206 e
->X_op_symbol
= NULL
;
213 static INLINE
int i386_intel_check (const reg_entry
*rreg
,
214 const reg_entry
*base
,
215 const reg_entry
*iindex
)
217 if ((this_operand
>= 0 && rreg
!= i
.op
[this_operand
].regs
)
218 || base
!= intel_state
.base
|| iindex
!= intel_state
.index
)
220 as_bad (_("invalid use of register"));
226 static INLINE
void i386_intel_fold (expressionS
*e
, symbolS
*sym
)
228 if (S_GET_SEGMENT (sym
) == absolute_section
)
230 offsetT val
= e
->X_add_number
;
232 *e
= *symbol_get_value_expression (sym
);
233 e
->X_add_number
+= val
;
237 e
->X_add_symbol
= sym
;
238 e
->X_op_symbol
= NULL
;
244 i386_intel_simplify_register (expressionS
*e
)
248 if (this_operand
< 0 || intel_state
.in_offset
)
250 as_bad (_("invalid use of register"));
254 if (e
->X_op
== O_register
)
255 reg_num
= e
->X_add_number
;
257 reg_num
= e
->X_md
- 1;
259 if (!intel_state
.in_bracket
)
261 if (i
.op
[this_operand
].regs
)
263 as_bad (_("invalid use of register"));
266 if (i386_regtab
[reg_num
].reg_type
.bitfield
.sreg3
267 && i386_regtab
[reg_num
].reg_num
== RegFlat
)
269 as_bad (_("invalid use of pseudo-register"));
272 i
.op
[this_operand
].regs
= i386_regtab
+ reg_num
;
274 else if (!intel_state
.base
&& !intel_state
.in_scale
)
275 intel_state
.base
= i386_regtab
+ reg_num
;
276 else if (!intel_state
.index
)
277 intel_state
.index
= i386_regtab
+ reg_num
;
280 /* esp is invalid as index */
281 intel_state
.index
= i386_regtab
+ REGNAM_EAX
+ 4;
286 static int i386_intel_simplify (expressionS
*);
288 static INLINE
int i386_intel_simplify_symbol(symbolS
*sym
)
290 int ret
= i386_intel_simplify (symbol_get_value_expression (sym
));
294 S_SET_SEGMENT(sym
, absolute_section
);
300 static int i386_intel_simplify (expressionS
*e
)
302 const reg_entry
*the_reg
= this_operand
>= 0 ? i
.op
[this_operand
].regs
: NULL
;
303 const reg_entry
*base
= intel_state
.base
;
304 const reg_entry
*state_index
= intel_state
.index
;
315 if (!i386_intel_simplify_symbol (e
->X_add_symbol
)
316 || !i386_intel_check(the_reg
, intel_state
.base
, intel_state
.index
))
319 if (!intel_state
.in_offset
)
320 ++intel_state
.in_bracket
;
321 ret
= i386_intel_simplify_symbol (e
->X_op_symbol
);
322 if (!intel_state
.in_offset
)
323 --intel_state
.in_bracket
;
329 i386_intel_fold (e
, e
->X_op_symbol
);
333 intel_state
.has_offset
= 1;
334 ++intel_state
.in_offset
;
335 ret
= i386_intel_simplify_symbol (e
->X_add_symbol
);
336 --intel_state
.in_offset
;
337 if (!ret
|| !i386_intel_check(the_reg
, base
, state_index
))
339 i386_intel_fold (e
, e
->X_add_symbol
);
353 if (intel_state
.op_modifier
== O_absent
)
354 intel_state
.op_modifier
= e
->X_op
;
357 if (symbol_get_value_expression (e
->X_add_symbol
)->X_op
== O_register
)
359 as_bad (_("invalid use of register"));
362 if (!i386_intel_simplify_symbol (e
->X_add_symbol
))
364 i386_intel_fold (e
, e
->X_add_symbol
);
368 if (symbol_get_value_expression (e
->X_op_symbol
)->X_op
== O_register
)
370 as_bad (_("invalid use of register"));
373 if (!i386_intel_simplify_symbol (e
->X_op_symbol
)
374 || !i386_intel_check(the_reg
, intel_state
.base
, intel_state
.index
))
376 if (!intel_state
.in_offset
)
377 intel_state
.seg
= e
->X_add_symbol
;
378 i386_intel_fold (e
, e
->X_op_symbol
);
382 if (this_operand
>= 0 && intel_state
.in_bracket
)
384 expressionS
*scale
= NULL
;
386 if (intel_state
.index
)
389 if (!intel_state
.in_scale
++)
390 intel_state
.scale_factor
= 1;
392 ret
= i386_intel_simplify_symbol (e
->X_add_symbol
);
393 if (ret
&& !scale
&& intel_state
.index
)
394 scale
= symbol_get_value_expression (e
->X_op_symbol
);
397 ret
= i386_intel_simplify_symbol (e
->X_op_symbol
);
398 if (ret
&& !scale
&& intel_state
.index
)
399 scale
= symbol_get_value_expression (e
->X_add_symbol
);
401 if (ret
&& scale
&& (scale
+ 1))
403 resolve_expression (scale
);
404 if (scale
->X_op
!= O_constant
405 || intel_state
.index
->reg_type
.bitfield
.reg16
)
406 scale
->X_add_number
= 0;
407 intel_state
.scale_factor
*= scale
->X_add_number
;
410 --intel_state
.in_scale
;
414 if (!intel_state
.in_scale
)
415 switch (intel_state
.scale_factor
)
418 i
.log2_scale_factor
= 0;
421 i
.log2_scale_factor
= 1;
424 i
.log2_scale_factor
= 2;
427 i
.log2_scale_factor
= 3;
430 /* esp is invalid as index */
431 intel_state
.index
= i386_regtab
+ REGNAM_EAX
+ 4;
440 ret
= i386_intel_simplify_register (e
);
443 gas_assert (e
->X_add_number
< (unsigned short) -1);
444 e
->X_md
= (unsigned short) e
->X_add_number
+ 1;
445 e
->X_op
= O_constant
;
452 return i386_intel_simplify_register (e
);
457 if (e
->X_add_symbol
&& !i386_intel_simplify_symbol (e
->X_add_symbol
))
459 if (e
->X_op
== O_add
|| e
->X_op
== O_subtract
)
461 base
= intel_state
.base
;
462 state_index
= intel_state
.index
;
464 if (!i386_intel_check (the_reg
, base
, state_index
)
465 || (e
->X_op_symbol
&& !i386_intel_simplify_symbol (e
->X_op_symbol
))
466 || !i386_intel_check (the_reg
,
467 e
->X_op
!= O_add
? base
: intel_state
.base
,
468 e
->X_op
!= O_add
? state_index
: intel_state
.index
))
473 if (this_operand
>= 0 && e
->X_op
== O_symbol
&& !intel_state
.in_offset
)
475 segT seg
= S_GET_SEGMENT (e
->X_add_symbol
);
477 if (seg
!= absolute_section
478 && seg
!= reg_section
479 && seg
!= expr_section
)
480 intel_state
.is_mem
|= 2 - !intel_state
.in_bracket
;
486 int i386_need_index_operator (void)
488 return intel_syntax
< 0;
492 i386_intel_operand (char *operand_string
, int got_a_float
)
494 char *saved_input_line_pointer
, *buf
;
496 expressionS exp
, *expP
;
500 /* Initialize state structure. */
501 intel_state
.op_modifier
= O_absent
;
502 intel_state
.is_mem
= 0;
503 intel_state
.is_indirect
= 0;
504 intel_state
.has_offset
= 0;
505 intel_state
.base
= NULL
;
506 intel_state
.index
= NULL
;
507 intel_state
.seg
= NULL
;
508 operand_type_set (&intel_state
.reloc_types
, ~0);
509 gas_assert (!intel_state
.in_offset
);
510 gas_assert (!intel_state
.in_bracket
);
511 gas_assert (!intel_state
.in_scale
);
513 saved_input_line_pointer
= input_line_pointer
;
514 input_line_pointer
= buf
= xstrdup (operand_string
);
517 memset (&exp
, 0, sizeof(exp
));
518 exp_seg
= expression (&exp
);
519 ret
= i386_intel_simplify (&exp
);
523 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
525 as_bad (_("junk `%s' after expression"), input_line_pointer
);
528 else if (exp
.X_op
== O_illegal
|| exp
.X_op
== O_absent
)
530 as_bad (_("invalid expression"));
533 else if (!intel_state
.has_offset
534 && input_line_pointer
> buf
535 && *(input_line_pointer
- 1) == ']')
537 intel_state
.is_mem
|= 1;
538 intel_state
.is_indirect
= 1;
541 input_line_pointer
= saved_input_line_pointer
;
544 gas_assert (!intel_state
.in_offset
);
545 gas_assert (!intel_state
.in_bracket
);
546 gas_assert (!intel_state
.in_scale
);
551 if (intel_state
.op_modifier
!= O_absent
552 && current_templates
->start
->base_opcode
!= 0x8d /* lea */)
554 i
.types
[this_operand
].bitfield
.unspecified
= 0;
556 switch (intel_state
.op_modifier
)
559 i
.types
[this_operand
].bitfield
.byte
= 1;
560 suffix
= BYTE_MNEM_SUFFIX
;
564 i
.types
[this_operand
].bitfield
.word
= 1;
565 if ((current_templates
->start
->name
[0] == 'l'
566 && current_templates
->start
->name
[2] == 's'
567 && current_templates
->start
->name
[3] == 0)
568 || current_templates
->start
->base_opcode
== 0x62 /* bound */)
569 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
570 else if (got_a_float
== 2) /* "fi..." */
571 suffix
= SHORT_MNEM_SUFFIX
;
573 suffix
= WORD_MNEM_SUFFIX
;
577 i
.types
[this_operand
].bitfield
.dword
= 1;
578 if ((current_templates
->start
->name
[0] == 'l'
579 && current_templates
->start
->name
[2] == 's'
580 && current_templates
->start
->name
[3] == 0)
581 || current_templates
->start
->base_opcode
== 0x62 /* bound */)
582 suffix
= WORD_MNEM_SUFFIX
;
583 else if (flag_code
== CODE_16BIT
584 && (current_templates
->start
->opcode_modifier
.jump
585 || current_templates
->start
->opcode_modifier
.jumpdword
))
586 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
587 else if (got_a_float
== 1) /* "f..." */
588 suffix
= SHORT_MNEM_SUFFIX
;
590 suffix
= LONG_MNEM_SUFFIX
;
594 i
.types
[this_operand
].bitfield
.fword
= 1;
595 if (current_templates
->start
->name
[0] == 'l'
596 && current_templates
->start
->name
[2] == 's'
597 && current_templates
->start
->name
[3] == 0)
598 suffix
= LONG_MNEM_SUFFIX
;
599 else if (!got_a_float
)
601 if (flag_code
== CODE_16BIT
)
602 add_prefix (DATA_PREFIX_OPCODE
);
603 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
606 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
610 i
.types
[this_operand
].bitfield
.qword
= 1;
611 if (current_templates
->start
->base_opcode
== 0x62 /* bound */
612 || got_a_float
== 1) /* "f..." */
613 suffix
= LONG_MNEM_SUFFIX
;
615 suffix
= QWORD_MNEM_SUFFIX
;
619 i
.types
[this_operand
].bitfield
.tbyte
= 1;
620 if (got_a_float
== 1)
621 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
623 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
628 i
.types
[this_operand
].bitfield
.xmmword
= 1;
629 suffix
= XMMWORD_MNEM_SUFFIX
;
633 i
.types
[this_operand
].bitfield
.ymmword
= 1;
634 suffix
= YMMWORD_MNEM_SUFFIX
;
638 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
641 if (!current_templates
->start
->opcode_modifier
.jump
642 && !current_templates
->start
->opcode_modifier
.jumpdword
)
643 suffix
= got_a_float
/* so it will cause an error */
645 : LONG_DOUBLE_MNEM_SUFFIX
;
649 BAD_CASE (intel_state
.op_modifier
);
655 else if (i
.suffix
!= suffix
)
657 as_bad (_("conflicting operand size modifiers"));
662 /* Operands for jump/call need special consideration. */
663 if (current_templates
->start
->opcode_modifier
.jump
664 || current_templates
->start
->opcode_modifier
.jumpdword
665 || current_templates
->start
->opcode_modifier
.jumpintersegment
)
667 if (i
.op
[this_operand
].regs
|| intel_state
.base
|| intel_state
.index
668 || intel_state
.is_mem
> 1)
669 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
671 switch (intel_state
.op_modifier
)
675 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
677 intel_state
.is_mem
= 1;
681 if (!intel_state
.seg
)
683 intel_state
.is_mem
= 1;
684 if (intel_state
.op_modifier
== O_absent
)
686 if (intel_state
.is_indirect
== 1)
687 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
690 as_bad (_("cannot infer the segment part of the operand"));
693 else if (S_GET_SEGMENT (intel_state
.seg
) == reg_section
)
694 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
697 i386_operand_type types
;
699 if (i
.imm_operands
>= MAX_IMMEDIATE_OPERANDS
)
701 as_bad (_("at most %d immediate operands are allowed"),
702 MAX_IMMEDIATE_OPERANDS
);
705 expP
= &im_expressions
[i
.imm_operands
++];
706 memset (expP
, 0, sizeof(*expP
));
707 expP
->X_op
= O_symbol
;
708 expP
->X_add_symbol
= intel_state
.seg
;
709 i
.op
[this_operand
].imms
= expP
;
711 resolve_expression (expP
);
712 operand_type_set (&types
, ~0);
713 if (!i386_finalize_immediate (S_GET_SEGMENT (intel_state
.seg
),
714 expP
, types
, operand_string
))
716 if (i
.operands
< MAX_OPERANDS
)
718 this_operand
= i
.operands
++;
719 i
.types
[this_operand
].bitfield
.unspecified
= 1;
721 if (suffix
== LONG_DOUBLE_MNEM_SUFFIX
)
723 intel_state
.seg
= NULL
;
724 intel_state
.is_mem
= 0;
728 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
731 if (i
.types
[this_operand
].bitfield
.jumpabsolute
)
732 intel_state
.is_mem
|= 1;
734 else if (intel_state
.seg
)
735 intel_state
.is_mem
|= 1;
737 if (i
.op
[this_operand
].regs
)
739 i386_operand_type temp
;
741 /* Register operand. */
742 if (intel_state
.base
|| intel_state
.index
|| intel_state
.seg
)
744 as_bad (_("invalid operand"));
748 temp
= i
.op
[this_operand
].regs
->reg_type
;
749 temp
.bitfield
.baseindex
= 0;
750 i
.types
[this_operand
] = operand_type_or (i
.types
[this_operand
], temp
);
751 i
.types
[this_operand
].bitfield
.unspecified
= 0;
754 else if (intel_state
.base
|| intel_state
.index
|| intel_state
.seg
755 || intel_state
.is_mem
)
757 /* Memory operand. */
759 >= 2 - !current_templates
->start
->opcode_modifier
.isstring
)
763 call 0x9090,0x90909090
764 lcall 0x9090,0x90909090
765 jmp 0x9090,0x90909090
766 ljmp 0x9090,0x90909090
769 if ((current_templates
->start
->opcode_modifier
.jumpintersegment
770 || current_templates
->start
->opcode_modifier
.jumpdword
771 || current_templates
->start
->opcode_modifier
.jump
)
773 && intel_state
.seg
== NULL
774 && i
.mem_operands
== 1
775 && i
.disp_operands
== 1
776 && intel_state
.op_modifier
== O_absent
)
778 /* Try to process the first operand as immediate, */
780 if (i386_finalize_immediate (exp_seg
, i
.op
[0].imms
,
781 intel_state
.reloc_types
,
785 expP
= &im_expressions
[0];
786 i
.op
[this_operand
].imms
= expP
;
789 /* Try to process the second operand as immediate, */
790 if (i386_finalize_immediate (exp_seg
, expP
,
791 intel_state
.reloc_types
,
797 i
.types
[0].bitfield
.mem
= 0;
798 i
.types
[0].bitfield
.disp16
= 0;
799 i
.types
[0].bitfield
.disp32
= 0;
800 i
.types
[0].bitfield
.disp32s
= 0;
806 as_bad (_("too many memory references for `%s'"),
807 current_templates
->start
->name
);
811 expP
= &disp_expressions
[i
.disp_operands
];
812 memcpy (expP
, &exp
, sizeof(exp
));
813 resolve_expression (expP
);
815 if (expP
->X_op
!= O_constant
|| expP
->X_add_number
816 || (!intel_state
.base
&& !intel_state
.index
))
818 i
.op
[this_operand
].disps
= expP
;
821 if (flag_code
== CODE_64BIT
)
823 i
.types
[this_operand
].bitfield
.disp32
= 1;
824 if (!i
.prefix
[ADDR_PREFIX
])
826 i
.types
[this_operand
].bitfield
.disp64
= 1;
827 i
.types
[this_operand
].bitfield
.disp32s
= 1;
830 else if (!i
.prefix
[ADDR_PREFIX
] ^ (flag_code
== CODE_16BIT
))
831 i
.types
[this_operand
].bitfield
.disp32
= 1;
833 i
.types
[this_operand
].bitfield
.disp16
= 1;
835 #if defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)
837 * exp_seg is used only for verification in
838 * i386_finalize_displacement, and we can end up seeing reg_section
839 * here - but we know we removed all registers from the expression
840 * (or error-ed on any remaining ones) in i386_intel_simplify. I
841 * consider the check in i386_finalize_displacement bogus anyway, in
842 * particular because it doesn't allow for expr_section, so I'd
843 * rather see that check (and the similar one in
844 * i386_finalize_immediate) use SEG_NORMAL(), but not being an a.out
845 * expert I can't really say whether that would have other bad side
848 if (OUTPUT_FLAVOR
== bfd_target_aout_flavour
849 && exp_seg
== reg_section
)
850 exp_seg
= expP
->X_op
!= O_constant
? undefined_section
854 if (!i386_finalize_displacement (exp_seg
, expP
,
855 intel_state
.reloc_types
,
860 if (intel_state
.base
|| intel_state
.index
)
861 i
.types
[this_operand
].bitfield
.baseindex
= 1;
867 expP
= symbol_get_value_expression (intel_state
.seg
);
868 if (expP
->X_op
!= O_full_ptr
)
870 intel_state
.seg
= expP
->X_add_symbol
;
872 if (expP
->X_op
!= O_register
)
874 as_bad (_("segment register name expected"));
877 if (!i386_regtab
[expP
->X_add_number
].reg_type
.bitfield
.sreg2
878 && !i386_regtab
[expP
->X_add_number
].reg_type
.bitfield
.sreg3
)
880 as_bad (_("invalid use of register"));
883 switch (i386_regtab
[expP
->X_add_number
].reg_num
)
885 case 0: i
.seg
[i
.mem_operands
] = &es
; break;
886 case 1: i
.seg
[i
.mem_operands
] = &cs
; break;
887 case 2: i
.seg
[i
.mem_operands
] = &ss
; break;
888 case 3: i
.seg
[i
.mem_operands
] = &ds
; break;
889 case 4: i
.seg
[i
.mem_operands
] = &fs
; break;
890 case 5: i
.seg
[i
.mem_operands
] = &gs
; break;
891 case RegFlat
: i
.seg
[i
.mem_operands
] = NULL
; break;
895 /* Swap base and index in 16-bit memory operands like
896 [si+bx]. Since i386_index_check is also used in AT&T
897 mode we have to do that here. */
900 && intel_state
.base
->reg_type
.bitfield
.reg16
901 && intel_state
.index
->reg_type
.bitfield
.reg16
902 && intel_state
.base
->reg_num
>= 6
903 && intel_state
.index
->reg_num
< 6)
905 i
.base_reg
= intel_state
.index
;
906 i
.index_reg
= intel_state
.base
;
910 i
.base_reg
= intel_state
.base
;
911 i
.index_reg
= intel_state
.index
;
914 if (!i386_index_check (operand_string
))
917 i
.types
[this_operand
].bitfield
.mem
= 1;
923 if (i
.imm_operands
>= MAX_IMMEDIATE_OPERANDS
)
925 as_bad (_("at most %d immediate operands are allowed"),
926 MAX_IMMEDIATE_OPERANDS
);
930 expP
= &im_expressions
[i
.imm_operands
++];
931 i
.op
[this_operand
].imms
= expP
;
934 return i386_finalize_immediate (exp_seg
, expP
, intel_state
.reloc_types
,