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 has_offset
; /* 1 if operand has offset. */
27 unsigned int in_offset
; /* >=1 if processing operand of offset. */
28 unsigned int in_bracket
; /* >=1 if processing operand in brackets. */
29 unsigned int in_scale
; /* >=1 if processing multipication operand
31 i386_operand_type reloc_types
; /* Value obtained from lex_got(). */
32 const reg_entry
*base
; /* Base register (if any). */
33 const reg_entry
*index
; /* Index register (if any). */
34 offsetT scale_factor
; /* Accumulated scale factor. */
39 /* offset X_add_symbol */
40 #define O_offset O_md32
41 /* offset X_add_symbol */
42 #define O_short O_md31
43 /* near ptr X_add_symbol */
44 #define O_near_ptr O_md30
45 /* far ptr X_add_symbol */
46 #define O_far_ptr O_md29
47 /* byte ptr X_add_symbol */
48 #define O_byte_ptr O_md28
49 /* word ptr X_add_symbol */
50 #define O_word_ptr O_md27
51 /* dword ptr X_add_symbol */
52 #define O_dword_ptr O_md26
53 /* qword ptr X_add_symbol */
54 #define O_qword_ptr O_md25
55 /* oword ptr X_add_symbol */
56 #define O_oword_ptr O_md24
57 /* fword ptr X_add_symbol */
58 #define O_fword_ptr O_md23
59 /* tbyte ptr X_add_symbol */
60 #define O_tbyte_ptr O_md22
61 /* xmmword ptr X_add_symbol */
62 #define O_xmmword_ptr O_md21
63 /* ymmword ptr X_add_symbol */
64 #define O_ymmword_ptr O_md20
70 unsigned int operands
;
72 const i386_operators
[] =
74 { "and", O_bit_and
, 2 },
80 { "mod", O_modulus
, 2 },
82 { "not", O_bit_not
, 1 },
83 { "offset", O_offset
, 1 },
84 { "or", O_bit_inclusive_or
, 2 },
85 { "shl", O_left_shift
, 2 },
86 { "short", O_short
, 1 },
87 { "shr", O_right_shift
, 2 },
88 { "xor", O_bit_exclusive_or
, 2 },
89 { NULL
, O_illegal
, 0 }
100 #define I386_TYPE(t, n) { #t, O_##t##_ptr, { n, n, n } }
106 I386_TYPE(tbyte
, 10),
107 I386_TYPE(oword
, 16),
108 I386_TYPE(xmmword
, 16),
109 I386_TYPE(ymmword
, 32),
111 { "near", O_near_ptr
, { 0xff04, 0xff02, 0xff08 } },
112 { "far", O_far_ptr
, { 0xff06, 0xff05, 0xff06 } },
113 { NULL
, O_illegal
, { 0, 0, 0 } }
116 operatorT
i386_operator (const char *name
, unsigned int operands
, char *pc
)
127 switch (*input_line_pointer
)
130 ++input_line_pointer
;
133 ++input_line_pointer
;
136 if (this_operand
>= 0 && i
.reloc
[this_operand
] == NO_RELOC
)
139 char *gotfree_input_line
= lex_got (&i
.reloc
[this_operand
],
141 &intel_state
.reloc_types
);
143 if (!gotfree_input_line
)
145 free (gotfree_input_line
);
146 *input_line_pointer
++ = '+';
147 memset (input_line_pointer
, '0', adjust
- 1);
148 input_line_pointer
[adjust
- 1] = ' ';
156 for (j
= 0; i386_operators
[j
].name
; ++j
)
157 if (strcasecmp (i386_operators
[j
].name
, name
) == 0)
159 if (i386_operators
[j
].operands
160 && i386_operators
[j
].operands
!= operands
)
162 return i386_operators
[j
].op
;
165 for (j
= 0; i386_types
[j
].name
; ++j
)
166 if (strcasecmp (i386_types
[j
].name
, name
) == 0)
168 if (i386_types
[j
].name
&& *pc
== ' ')
170 char *pname
= ++input_line_pointer
;
171 char c
= get_symbol_end ();
173 if (strcasecmp (pname
, "ptr") == 0)
177 if (intel_syntax
> 0 || operands
!= 1)
179 return i386_types
[j
].op
;
182 *input_line_pointer
= c
;
183 input_line_pointer
= pname
- 1;
189 static int i386_intel_parse_name (const char *name
, expressionS
*e
)
193 for (j
= 0; i386_types
[j
].name
; ++j
)
194 if (strcasecmp(i386_types
[j
].name
, name
) == 0)
196 e
->X_op
= O_constant
;
197 e
->X_add_number
= i386_types
[j
].sz
[flag_code
];
198 e
->X_add_symbol
= NULL
;
199 e
->X_op_symbol
= NULL
;
206 static INLINE
int i386_intel_check (const reg_entry
*rreg
,
207 const reg_entry
*base
,
208 const reg_entry
*iindex
)
210 if ((this_operand
>= 0 && rreg
!= i
.op
[this_operand
].regs
)
211 || base
!= intel_state
.base
|| iindex
!= intel_state
.index
)
213 as_bad (_("invalid use of register"));
219 static INLINE
void i386_intel_fold (expressionS
*e
, symbolS
*sym
)
221 if (S_GET_SEGMENT (sym
) == absolute_section
)
223 offsetT val
= e
->X_add_number
;
225 *e
= *symbol_get_value_expression (sym
);
226 e
->X_add_number
+= val
;
230 e
->X_add_symbol
= sym
;
231 e
->X_op_symbol
= NULL
;
237 i386_intel_simplify_register (expressionS
*e
)
241 if (this_operand
< 0 || intel_state
.in_offset
)
243 as_bad (_("invalid use of register"));
247 if (e
->X_op
== O_register
)
248 reg_num
= e
->X_add_number
;
250 reg_num
= e
->X_md
- 1;
252 if (!intel_state
.in_bracket
)
254 if (i
.op
[this_operand
].regs
)
256 as_bad (_("invalid use of register"));
259 if (i386_regtab
[reg_num
].reg_type
.bitfield
.sreg3
260 && i386_regtab
[reg_num
].reg_num
== RegFlat
)
262 as_bad (_("invalid use of pseudo-register"));
265 i
.op
[this_operand
].regs
= i386_regtab
+ reg_num
;
267 else if (!intel_state
.base
&& !intel_state
.in_scale
)
268 intel_state
.base
= i386_regtab
+ reg_num
;
269 else if (!intel_state
.index
)
270 intel_state
.index
= i386_regtab
+ reg_num
;
273 /* esp is invalid as index */
274 intel_state
.index
= i386_regtab
+ REGNAM_EAX
+ 4;
279 static int i386_intel_simplify (expressionS
*);
281 static INLINE
int i386_intel_simplify_symbol(symbolS
*sym
)
283 int ret
= i386_intel_simplify (symbol_get_value_expression (sym
));
287 S_SET_SEGMENT(sym
, absolute_section
);
293 static int i386_intel_simplify (expressionS
*e
)
295 const reg_entry
*the_reg
= this_operand
>= 0 ? i
.op
[this_operand
].regs
: NULL
;
296 const reg_entry
*base
= intel_state
.base
;
297 const reg_entry
*state_index
= intel_state
.index
;
308 if (!i386_intel_simplify_symbol (e
->X_add_symbol
)
309 || !i386_intel_check(the_reg
, intel_state
.base
, intel_state
.index
))
312 if (!intel_state
.in_offset
)
313 ++intel_state
.in_bracket
;
314 ret
= i386_intel_simplify_symbol (e
->X_op_symbol
);
315 if (!intel_state
.in_offset
)
316 --intel_state
.in_bracket
;
322 i386_intel_fold (e
, e
->X_op_symbol
);
326 intel_state
.has_offset
= 1;
327 ++intel_state
.in_offset
;
328 ret
= i386_intel_simplify_symbol (e
->X_add_symbol
);
329 --intel_state
.in_offset
;
330 if (!ret
|| !i386_intel_check(the_reg
, base
, state_index
))
332 i386_intel_fold (e
, e
->X_add_symbol
);
346 if (intel_state
.op_modifier
== O_absent
)
347 intel_state
.op_modifier
= e
->X_op
;
350 if (i386_is_register (symbol_get_value_expression (e
->X_add_symbol
),
353 as_bad (_("invalid use of register"));
356 if (!i386_intel_simplify_symbol (e
->X_add_symbol
))
358 i386_intel_fold (e
, e
->X_add_symbol
);
362 if (i386_is_register (symbol_get_value_expression (e
->X_op_symbol
),
365 as_bad (_("invalid use of register"));
368 if (!i386_intel_simplify_symbol (e
->X_op_symbol
)
369 || !i386_intel_check(the_reg
, intel_state
.base
, intel_state
.index
))
371 if (!intel_state
.in_offset
)
372 intel_state
.seg
= e
->X_add_symbol
;
373 i386_intel_fold (e
, e
->X_op_symbol
);
377 if (this_operand
>= 0 && intel_state
.in_bracket
)
379 expressionS
*scale
= NULL
;
381 if (intel_state
.index
)
384 if (!intel_state
.in_scale
++)
385 intel_state
.scale_factor
= 1;
387 ret
= i386_intel_simplify_symbol (e
->X_add_symbol
);
388 if (ret
&& !scale
&& intel_state
.index
)
389 scale
= symbol_get_value_expression (e
->X_op_symbol
);
392 ret
= i386_intel_simplify_symbol (e
->X_op_symbol
);
393 if (ret
&& !scale
&& intel_state
.index
)
394 scale
= symbol_get_value_expression (e
->X_add_symbol
);
396 if (ret
&& scale
&& (scale
+ 1))
398 resolve_expression (scale
);
399 if (scale
->X_op
!= O_constant
400 || intel_state
.index
->reg_type
.bitfield
.reg16
)
401 scale
->X_add_number
= 0;
402 intel_state
.scale_factor
*= scale
->X_add_number
;
405 --intel_state
.in_scale
;
409 if (!intel_state
.in_scale
)
410 switch (intel_state
.scale_factor
)
413 i
.log2_scale_factor
= 0;
416 i
.log2_scale_factor
= 1;
419 i
.log2_scale_factor
= 2;
422 i
.log2_scale_factor
= 3;
425 /* esp is invalid as index */
426 intel_state
.index
= i386_regtab
+ REGNAM_EAX
+ 4;
434 ret
= i386_intel_simplify_register (e
);
437 gas_assert (e
->X_add_number
< (unsigned short) -1);
438 e
->X_md
= (unsigned short) e
->X_add_number
+ 1;
439 e
->X_op
= O_constant
;
446 return i386_intel_simplify_register (e
);
450 if (e
->X_add_symbol
&& !i386_intel_simplify_symbol (e
->X_add_symbol
))
452 if (e
->X_op
== O_add
|| e
->X_op
== O_subtract
)
454 base
= intel_state
.base
;
455 state_index
= intel_state
.index
;
457 if (!i386_intel_check (the_reg
, base
, state_index
)
458 || (e
->X_op_symbol
&& !i386_intel_simplify_symbol (e
->X_op_symbol
))
459 || !i386_intel_check (the_reg
,
460 e
->X_op
!= O_add
? base
: intel_state
.base
,
461 e
->X_op
!= O_add
? state_index
: intel_state
.index
))
466 if (this_operand
>= 0 && e
->X_op
== O_symbol
&& !intel_state
.in_offset
)
468 segT seg
= S_GET_SEGMENT (e
->X_add_symbol
);
470 if (seg
!= absolute_section
471 && seg
!= reg_section
472 && seg
!= expr_section
)
473 intel_state
.is_mem
|= 2 - !intel_state
.in_bracket
;
479 int i386_need_index_operator (void)
481 return intel_syntax
< 0;
485 i386_intel_operand (char *operand_string
, int got_a_float
)
487 char *saved_input_line_pointer
, *buf
;
489 expressionS exp
, *expP
;
493 /* Initialize state structure. */
494 intel_state
.op_modifier
= O_absent
;
495 intel_state
.is_mem
= 0;
496 intel_state
.has_offset
= 0;
497 intel_state
.base
= NULL
;
498 intel_state
.index
= NULL
;
499 intel_state
.seg
= NULL
;
500 operand_type_set (&intel_state
.reloc_types
, ~0);
501 gas_assert (!intel_state
.in_offset
);
502 gas_assert (!intel_state
.in_bracket
);
503 gas_assert (!intel_state
.in_scale
);
505 saved_input_line_pointer
= input_line_pointer
;
506 input_line_pointer
= buf
= xstrdup (operand_string
);
508 /* A '$' followed by an identifier char is an identifier. Otherwise,
509 it's operator '.' followed by an expression. */
510 if (*buf
== '$' && !is_identifier_char (buf
[1]))
514 memset (&exp
, 0, sizeof(exp
));
515 exp_seg
= expression (&exp
);
516 ret
= i386_intel_simplify (&exp
);
520 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
522 as_bad (_("junk `%s' after expression"), input_line_pointer
);
525 else if (exp
.X_op
== O_illegal
|| exp
.X_op
== O_absent
)
527 as_bad (_("invalid expression"));
530 else if (!intel_state
.has_offset
531 && input_line_pointer
> buf
532 && *(input_line_pointer
- 1) == ']')
533 intel_state
.is_mem
|= 1;
535 input_line_pointer
= saved_input_line_pointer
;
538 gas_assert (!intel_state
.in_offset
);
539 gas_assert (!intel_state
.in_bracket
);
540 gas_assert (!intel_state
.in_scale
);
545 if (intel_state
.op_modifier
!= O_absent
546 && current_templates
->start
->base_opcode
!= 0x8d /* lea */)
548 i
.types
[this_operand
].bitfield
.unspecified
= 0;
550 switch (intel_state
.op_modifier
)
553 i
.types
[this_operand
].bitfield
.byte
= 1;
554 suffix
= BYTE_MNEM_SUFFIX
;
558 i
.types
[this_operand
].bitfield
.word
= 1;
559 if ((current_templates
->start
->name
[0] == 'l'
560 && current_templates
->start
->name
[2] == 's'
561 && current_templates
->start
->name
[3] == 0)
562 || current_templates
->start
->base_opcode
== 0x62 /* bound */)
563 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
564 else if (got_a_float
== 2) /* "fi..." */
565 suffix
= SHORT_MNEM_SUFFIX
;
567 suffix
= WORD_MNEM_SUFFIX
;
571 i
.types
[this_operand
].bitfield
.dword
= 1;
572 if ((current_templates
->start
->name
[0] == 'l'
573 && current_templates
->start
->name
[2] == 's'
574 && current_templates
->start
->name
[3] == 0)
575 || current_templates
->start
->base_opcode
== 0x62 /* bound */)
576 suffix
= WORD_MNEM_SUFFIX
;
577 else if (flag_code
== CODE_16BIT
578 && (current_templates
->start
->opcode_modifier
.jump
579 || current_templates
->start
->opcode_modifier
.jumpdword
))
580 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
581 else if (got_a_float
== 1) /* "f..." */
582 suffix
= SHORT_MNEM_SUFFIX
;
584 suffix
= LONG_MNEM_SUFFIX
;
588 i
.types
[this_operand
].bitfield
.fword
= 1;
589 if (current_templates
->start
->name
[0] == 'l'
590 && current_templates
->start
->name
[2] == 's'
591 && current_templates
->start
->name
[3] == 0)
592 suffix
= LONG_MNEM_SUFFIX
;
593 else if (!got_a_float
)
595 if (flag_code
== CODE_16BIT
)
596 add_prefix (DATA_PREFIX_OPCODE
);
597 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
600 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
604 i
.types
[this_operand
].bitfield
.qword
= 1;
605 if (current_templates
->start
->base_opcode
== 0x62 /* bound */
606 || got_a_float
== 1) /* "f..." */
607 suffix
= LONG_MNEM_SUFFIX
;
609 suffix
= QWORD_MNEM_SUFFIX
;
613 i
.types
[this_operand
].bitfield
.tbyte
= 1;
614 if (got_a_float
== 1)
615 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
617 suffix
= BYTE_MNEM_SUFFIX
; /* so it will cause an error */
622 i
.types
[this_operand
].bitfield
.xmmword
= 1;
623 suffix
= XMMWORD_MNEM_SUFFIX
;
627 i
.types
[this_operand
].bitfield
.ymmword
= 1;
628 suffix
= YMMWORD_MNEM_SUFFIX
;
632 suffix
= LONG_DOUBLE_MNEM_SUFFIX
;
635 if (!current_templates
->start
->opcode_modifier
.jump
636 && !current_templates
->start
->opcode_modifier
.jumpdword
)
637 suffix
= got_a_float
/* so it will cause an error */
639 : LONG_DOUBLE_MNEM_SUFFIX
;
643 BAD_CASE (intel_state
.op_modifier
);
649 else if (i
.suffix
!= suffix
)
651 as_bad (_("conflicting operand size modifiers"));
656 /* Operands for jump/call need special consideration. */
657 if (current_templates
->start
->opcode_modifier
.jump
658 || current_templates
->start
->opcode_modifier
.jumpdword
659 || current_templates
->start
->opcode_modifier
.jumpintersegment
)
661 if (i
.op
[this_operand
].regs
|| intel_state
.base
|| intel_state
.index
662 || intel_state
.is_mem
> 1)
663 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
665 switch (intel_state
.op_modifier
)
669 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
671 intel_state
.is_mem
= 1;
675 if (!intel_state
.seg
)
677 intel_state
.is_mem
= 1;
678 if (intel_state
.op_modifier
== O_absent
)
680 as_bad (_("cannot infer the segment part of the operand"));
683 else if (S_GET_SEGMENT (intel_state
.seg
) == reg_section
)
684 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
687 i386_operand_type types
;
689 if (i
.imm_operands
>= MAX_IMMEDIATE_OPERANDS
)
691 as_bad (_("at most %d immediate operands are allowed"),
692 MAX_IMMEDIATE_OPERANDS
);
695 expP
= &im_expressions
[i
.imm_operands
++];
696 memset (expP
, 0, sizeof(*expP
));
697 expP
->X_op
= O_symbol
;
698 expP
->X_add_symbol
= intel_state
.seg
;
699 i
.op
[this_operand
].imms
= expP
;
701 resolve_expression (expP
);
702 operand_type_set (&types
, ~0);
703 if (!i386_finalize_immediate (S_GET_SEGMENT (intel_state
.seg
),
704 expP
, types
, operand_string
))
706 if (i
.operands
< MAX_OPERANDS
)
708 this_operand
= i
.operands
++;
709 i
.types
[this_operand
].bitfield
.unspecified
= 1;
711 if (suffix
== LONG_DOUBLE_MNEM_SUFFIX
)
713 intel_state
.seg
= NULL
;
714 intel_state
.is_mem
= 0;
718 i
.types
[this_operand
].bitfield
.jumpabsolute
= 1;
721 if (i
.types
[this_operand
].bitfield
.jumpabsolute
)
722 intel_state
.is_mem
|= 1;
724 else if (intel_state
.seg
)
725 intel_state
.is_mem
|= 1;
727 if (i
.op
[this_operand
].regs
)
729 i386_operand_type temp
;
731 /* Register operand. */
732 if (intel_state
.base
|| intel_state
.index
|| intel_state
.seg
)
734 as_bad (_("invalid operand"));
738 temp
= i
.op
[this_operand
].regs
->reg_type
;
739 temp
.bitfield
.baseindex
= 0;
740 i
.types
[this_operand
] = operand_type_or (i
.types
[this_operand
], temp
);
741 i
.types
[this_operand
].bitfield
.unspecified
= 0;
744 else if (intel_state
.base
|| intel_state
.index
|| intel_state
.seg
745 || intel_state
.is_mem
)
747 /* Memory operand. */
749 >= 2 - !current_templates
->start
->opcode_modifier
.isstring
)
753 call 0x9090,0x90909090
754 lcall 0x9090,0x90909090
755 jmp 0x9090,0x90909090
756 ljmp 0x9090,0x90909090
759 if ((current_templates
->start
->opcode_modifier
.jumpintersegment
760 || current_templates
->start
->opcode_modifier
.jumpdword
761 || current_templates
->start
->opcode_modifier
.jump
)
763 && intel_state
.seg
== NULL
764 && i
.mem_operands
== 1
765 && i
.disp_operands
== 1
766 && intel_state
.op_modifier
== O_absent
)
768 /* Try to process the first operand as immediate, */
770 if (i386_finalize_immediate (exp_seg
, i
.op
[0].imms
,
771 intel_state
.reloc_types
,
775 expP
= &im_expressions
[0];
776 i
.op
[this_operand
].imms
= expP
;
779 /* Try to process the second operand as immediate, */
780 if (i386_finalize_immediate (exp_seg
, expP
,
781 intel_state
.reloc_types
,
787 i
.types
[0].bitfield
.mem
= 0;
788 i
.types
[0].bitfield
.disp16
= 0;
789 i
.types
[0].bitfield
.disp32
= 0;
790 i
.types
[0].bitfield
.disp32s
= 0;
796 as_bad (_("too many memory references for `%s'"),
797 current_templates
->start
->name
);
801 expP
= &disp_expressions
[i
.disp_operands
];
802 memcpy (expP
, &exp
, sizeof(exp
));
803 resolve_expression (expP
);
805 if (expP
->X_op
!= O_constant
|| expP
->X_add_number
806 || (!intel_state
.base
&& !intel_state
.index
))
808 i
.op
[this_operand
].disps
= expP
;
811 if (flag_code
== CODE_64BIT
)
813 i
.types
[this_operand
].bitfield
.disp32
= 1;
814 if (!i
.prefix
[ADDR_PREFIX
])
816 i
.types
[this_operand
].bitfield
.disp64
= 1;
817 i
.types
[this_operand
].bitfield
.disp32s
= 1;
820 else if (!i
.prefix
[ADDR_PREFIX
] ^ (flag_code
== CODE_16BIT
))
821 i
.types
[this_operand
].bitfield
.disp32
= 1;
823 i
.types
[this_operand
].bitfield
.disp16
= 1;
825 #if defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)
827 * exp_seg is used only for verification in
828 * i386_finalize_displacement, and we can end up seeing reg_section
829 * here - but we know we removed all registers from the expression
830 * (or error-ed on any remaining ones) in i386_intel_simplify. I
831 * consider the check in i386_finalize_displacement bogus anyway, in
832 * particular because it doesn't allow for expr_section, so I'd
833 * rather see that check (and the similar one in
834 * i386_finalize_immediate) use SEG_NORMAL(), but not being an a.out
835 * expert I can't really say whether that would have other bad side
838 if (OUTPUT_FLAVOR
== bfd_target_aout_flavour
839 && exp_seg
== reg_section
)
840 exp_seg
= expP
->X_op
!= O_constant
? undefined_section
844 if (!i386_finalize_displacement (exp_seg
, expP
,
845 intel_state
.reloc_types
,
850 if (intel_state
.base
|| intel_state
.index
)
851 i
.types
[this_operand
].bitfield
.baseindex
= 1;
857 expP
= symbol_get_value_expression (intel_state
.seg
);
858 if (expP
->X_op
!= O_full_ptr
)
860 intel_state
.seg
= expP
->X_add_symbol
;
862 if (!i386_is_register (expP
, 1))
864 as_bad (_("segment register name expected"));
867 if (!i386_regtab
[expP
->X_add_number
].reg_type
.bitfield
.sreg2
868 && !i386_regtab
[expP
->X_add_number
].reg_type
.bitfield
.sreg3
)
870 as_bad (_("invalid use of register"));
873 switch (i386_regtab
[expP
->X_add_number
].reg_num
)
875 case 0: i
.seg
[i
.mem_operands
] = &es
; break;
876 case 1: i
.seg
[i
.mem_operands
] = &cs
; break;
877 case 2: i
.seg
[i
.mem_operands
] = &ss
; break;
878 case 3: i
.seg
[i
.mem_operands
] = &ds
; break;
879 case 4: i
.seg
[i
.mem_operands
] = &fs
; break;
880 case 5: i
.seg
[i
.mem_operands
] = &gs
; break;
881 case RegFlat
: i
.seg
[i
.mem_operands
] = NULL
; break;
885 /* Swap base and index in 16-bit memory operands like
886 [si+bx]. Since i386_index_check is also used in AT&T
887 mode we have to do that here. */
890 && intel_state
.base
->reg_type
.bitfield
.reg16
891 && intel_state
.index
->reg_type
.bitfield
.reg16
892 && intel_state
.base
->reg_num
>= 6
893 && intel_state
.index
->reg_num
< 6)
895 i
.base_reg
= intel_state
.index
;
896 i
.index_reg
= intel_state
.base
;
900 i
.base_reg
= intel_state
.base
;
901 i
.index_reg
= intel_state
.index
;
904 if (!i386_index_check (operand_string
))
907 i
.types
[this_operand
].bitfield
.mem
= 1;
913 if (i
.imm_operands
>= MAX_IMMEDIATE_OPERANDS
)
915 as_bad (_("at most %d immediate operands are allowed"),
916 MAX_IMMEDIATE_OPERANDS
);
920 expP
= &im_expressions
[i
.imm_operands
++];
921 i
.op
[this_operand
].imms
= expP
;
924 return i386_finalize_immediate (exp_seg
, expP
, intel_state
.reloc_types
,