xref: /openbsd-src/gnu/usr.bin/binutils/gas/doc/c-i386.texi (revision 007c2a4539b8b8aaa95c5e73e77620090abe113b)
1b55d4692Sfgsch@c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001
2b55d4692Sfgsch@c Free Software Foundation, Inc.
32159047fSniklas@c This is part of the GAS manual.
42159047fSniklas@c For copying conditions, see the file as.texinfo.
52159047fSniklas@ifset GENERIC
62159047fSniklas@page
72159047fSniklas@node i386-Dependent
82159047fSniklas@chapter 80386 Dependent Features
92159047fSniklas@end ifset
102159047fSniklas@ifclear GENERIC
112159047fSniklas@node Machine Dependencies
122159047fSniklas@chapter 80386 Dependent Features
132159047fSniklas@end ifclear
142159047fSniklas
152159047fSniklas@cindex i386 support
162159047fSniklas@cindex i80306 support
17b55d4692Sfgsch@cindex x86-64 support
18b55d4692Sfgsch
19b55d4692SfgschThe i386 version @code{@value{AS}} supports both the original Intel 386
20b55d4692Sfgscharchitecture in both 16 and 32-bit mode as well as AMD x86-64 architecture
21b55d4692Sfgschextending the Intel architecture to 64-bits.
22b55d4692Sfgsch
232159047fSniklas@menu
242159047fSniklas* i386-Options::                Options
252159047fSniklas* i386-Syntax::                 AT&T Syntax versus Intel Syntax
26f7cc78ecSespie* i386-Mnemonics::              Instruction Naming
272159047fSniklas* i386-Regs::                   Register Naming
28f7cc78ecSespie* i386-Prefixes::               Instruction Prefixes
292159047fSniklas* i386-Memory::                 Memory References
30b55d4692Sfgsch* i386-Jumps::                  Handling of Jump Instructions
312159047fSniklas* i386-Float::                  Floating Point
32f7cc78ecSespie* i386-SIMD::                   Intel's MMX and AMD's 3DNow! SIMD Operations
332159047fSniklas* i386-16bit::                  Writing 16-bit Code
34b55d4692Sfgsch* i386-Arch::                   Specifying an x86 CPU architecture
35f7cc78ecSespie* i386-Bugs::                   AT&T Syntax bugs
362159047fSniklas* i386-Notes::                  Notes
372159047fSniklas@end menu
382159047fSniklas
392159047fSniklas@node i386-Options
402159047fSniklas@section Options
412159047fSniklas
42b55d4692Sfgsch@cindex options for i386
43b55d4692Sfgsch@cindex options for x86-64
44b55d4692Sfgsch@cindex i386 options
45b55d4692Sfgsch@cindex x86-64 options
46b55d4692Sfgsch
47b55d4692SfgschThe i386 version of @code{@value{AS}} has a few machine
48b55d4692Sfgschdependent options:
49b55d4692Sfgsch
50b55d4692Sfgsch@table @code
51b55d4692Sfgsch@cindex @samp{--32} option, i386
52b55d4692Sfgsch@cindex @samp{--32} option, x86-64
53b55d4692Sfgsch@cindex @samp{--64} option, i386
54b55d4692Sfgsch@cindex @samp{--64} option, x86-64
55b55d4692Sfgsch@item --32 | --64
56b55d4692SfgschSelect the word size, either 32 bits or 64 bits. Selecting 32-bit
57b55d4692Sfgschimplies Intel i386 architecture, while 64-bit implies AMD x86-64
58b55d4692Sfgscharchitecture.
59b55d4692Sfgsch
60b55d4692SfgschThese options are only available with the ELF object file format, and
61b55d4692Sfgschrequire that the necessary BFD support has been included (on a 32-bit
62b55d4692Sfgschplatform you have to add --enable-64-bit-bfd to configure enable 64-bit
63b55d4692Sfgschusage and use x86-64 as target platform).
64*007c2a45Smiod
65*007c2a45Smiod@item -n
66*007c2a45SmiodBy default, x86 GAS replaces multiple nop instructions used for
67*007c2a45Smiodalignment within code sections with multi-byte nop instructions such
68*007c2a45Smiodas leal 0(%esi,1),%esi.  This switch disables the optimization.
69b55d4692Sfgsch@end table
702159047fSniklas
712159047fSniklas@node i386-Syntax
722159047fSniklas@section AT&T Syntax versus Intel Syntax
732159047fSniklas
74b55d4692Sfgsch@cindex i386 intel_syntax pseudo op
75b55d4692Sfgsch@cindex intel_syntax pseudo op, i386
76b55d4692Sfgsch@cindex i386 att_syntax pseudo op
77b55d4692Sfgsch@cindex att_syntax pseudo op, i386
782159047fSniklas@cindex i386 syntax compatibility
792159047fSniklas@cindex syntax compatibility, i386
80b55d4692Sfgsch@cindex x86-64 intel_syntax pseudo op
81b55d4692Sfgsch@cindex intel_syntax pseudo op, x86-64
82b55d4692Sfgsch@cindex x86-64 att_syntax pseudo op
83b55d4692Sfgsch@cindex att_syntax pseudo op, x86-64
84b55d4692Sfgsch@cindex x86-64 syntax compatibility
85b55d4692Sfgsch@cindex syntax compatibility, x86-64
86b55d4692Sfgsch
87b55d4692Sfgsch@code{@value{AS}} now supports assembly using Intel assembler syntax.
88b55d4692Sfgsch@code{.intel_syntax} selects Intel mode, and @code{.att_syntax} switches
89b55d4692Sfgschback to the usual AT&T mode for compatibility with the output of
90b55d4692Sfgsch@code{@value{GCC}}.  Either of these directives may have an optional
91b55d4692Sfgschargument, @code{prefix}, or @code{noprefix} specifying whether registers
92b55d4692Sfgschrequire a @samp{%} prefix.  AT&T System V/386 assembler syntax is quite
932159047fSniklasdifferent from Intel syntax.  We mention these differences because
94f7cc78ecSespiealmost all 80386 documents use Intel syntax.  Notable differences
952159047fSniklasbetween the two syntaxes are:
962159047fSniklas
972159047fSniklas@cindex immediate operands, i386
982159047fSniklas@cindex i386 immediate operands
992159047fSniklas@cindex register operands, i386
1002159047fSniklas@cindex i386 register operands
1012159047fSniklas@cindex jump/call operands, i386
1022159047fSniklas@cindex i386 jump/call operands
1032159047fSniklas@cindex operand delimiters, i386
104b55d4692Sfgsch
105b55d4692Sfgsch@cindex immediate operands, x86-64
106b55d4692Sfgsch@cindex x86-64 immediate operands
107b55d4692Sfgsch@cindex register operands, x86-64
108b55d4692Sfgsch@cindex x86-64 register operands
109b55d4692Sfgsch@cindex jump/call operands, x86-64
110b55d4692Sfgsch@cindex x86-64 jump/call operands
111b55d4692Sfgsch@cindex operand delimiters, x86-64
1122159047fSniklas@itemize @bullet
1132159047fSniklas@item
1142159047fSniklasAT&T immediate operands are preceded by @samp{$}; Intel immediate
1152159047fSniklasoperands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}).
1162159047fSniklasAT&T register operands are preceded by @samp{%}; Intel register operands
1172159047fSniklasare undelimited.  AT&T absolute (as opposed to PC relative) jump/call
1182159047fSniklasoperands are prefixed by @samp{*}; they are undelimited in Intel syntax.
1192159047fSniklas
1202159047fSniklas@cindex i386 source, destination operands
1212159047fSniklas@cindex source, destination operands; i386
122b55d4692Sfgsch@cindex x86-64 source, destination operands
123b55d4692Sfgsch@cindex source, destination operands; x86-64
1242159047fSniklas@item
1252159047fSniklasAT&T and Intel syntax use the opposite order for source and destination
1262159047fSniklasoperands.  Intel @samp{add eax, 4} is @samp{addl $4, %eax}.  The
1272159047fSniklas@samp{source, dest} convention is maintained for compatibility with
128f7cc78ecSespieprevious Unix assemblers.  Note that instructions with more than one
129f7cc78ecSespiesource operand, such as the @samp{enter} instruction, do @emph{not} have
130f7cc78ecSespiereversed order.  @ref{i386-Bugs}.
1312159047fSniklas
132f7cc78ecSespie@cindex mnemonic suffixes, i386
1332159047fSniklas@cindex sizes operands, i386
1342159047fSniklas@cindex i386 size suffixes
135b55d4692Sfgsch@cindex mnemonic suffixes, x86-64
136b55d4692Sfgsch@cindex sizes operands, x86-64
137b55d4692Sfgsch@cindex x86-64 size suffixes
1382159047fSniklas@item
1392159047fSniklasIn AT&T syntax the size of memory operands is determined from the last
140f7cc78ecSespiecharacter of the instruction mnemonic.  Mnemonic suffixes of @samp{b},
141b55d4692Sfgsch@samp{w}, @samp{l} and @samp{q} specify byte (8-bit), word (16-bit), long
142b55d4692Sfgsch(32-bit) and quadruple word (64-bit) memory references.  Intel syntax accomplishes
143b55d4692Sfgschthis by prefixing memory operands (@emph{not} the instruction mnemonics) with
144b55d4692Sfgsch@samp{byte ptr}, @samp{word ptr}, @samp{dword ptr} and @samp{qword ptr}.  Thus,
145b55d4692SfgschIntel @samp{mov al, byte ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T
146b55d4692Sfgschsyntax.
1472159047fSniklas
1482159047fSniklas@cindex return instructions, i386
1492159047fSniklas@cindex i386 jump, call, return
150b55d4692Sfgsch@cindex return instructions, x86-64
151b55d4692Sfgsch@cindex x86-64 jump, call, return
1522159047fSniklas@item
1532159047fSniklasImmediate form long jumps and calls are
1542159047fSniklas@samp{lcall/ljmp $@var{section}, $@var{offset}} in AT&T syntax; the
1552159047fSniklasIntel syntax is
1562159047fSniklas@samp{call/jmp far @var{section}:@var{offset}}.  Also, the far return
1572159047fSniklasinstruction
1582159047fSniklasis @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is
1592159047fSniklas@samp{ret far @var{stack-adjust}}.
1602159047fSniklas
1612159047fSniklas@cindex sections, i386
1622159047fSniklas@cindex i386 sections
163b55d4692Sfgsch@cindex sections, x86-64
164b55d4692Sfgsch@cindex x86-64 sections
1652159047fSniklas@item
1662159047fSniklasThe AT&T assembler does not provide support for multiple section
1672159047fSniklasprograms.  Unix style systems expect all programs to be single sections.
1682159047fSniklas@end itemize
1692159047fSniklas
170f7cc78ecSespie@node i386-Mnemonics
171f7cc78ecSespie@section Instruction Naming
1722159047fSniklas
173f7cc78ecSespie@cindex i386 instruction naming
174f7cc78ecSespie@cindex instruction naming, i386
175b55d4692Sfgsch@cindex x86-64 instruction naming
176b55d4692Sfgsch@cindex instruction naming, x86-64
177b55d4692Sfgsch
178f7cc78ecSespieInstruction mnemonics are suffixed with one character modifiers which
179b55d4692Sfgschspecify the size of operands.  The letters @samp{b}, @samp{w}, @samp{l}
180b55d4692Sfgschand @samp{q} specify byte, word, long and quadruple word operands.  If
181b55d4692Sfgschno suffix is specified by an instruction then @code{@value{AS}} tries to
182b55d4692Sfgschfill in the missing suffix based on the destination register operand
183b55d4692Sfgsch(the last one by convention).  Thus, @samp{mov %ax, %bx} is equivalent
184b55d4692Sfgschto @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to
185b55d4692Sfgsch@samp{movw $1, bx}.  Note that this is incompatible with the AT&T Unix
186b55d4692Sfgschassembler which assumes that a missing mnemonic suffix implies long
187b55d4692Sfgschoperand size.  (This incompatibility does not affect compiler output
188b55d4692Sfgschsince compilers always explicitly specify the mnemonic suffix.)
1892159047fSniklas
190f7cc78ecSespieAlmost all instructions have the same names in AT&T and Intel format.
191f7cc78ecSespieThere are a few exceptions.  The sign extend and zero extend
192f7cc78ecSespieinstructions need two sizes to specify them.  They need a size to
193f7cc78ecSespiesign/zero extend @emph{from} and a size to zero extend @emph{to}.  This
194f7cc78ecSespieis accomplished by using two instruction mnemonic suffixes in AT&T
195f7cc78ecSespiesyntax.  Base names for sign extend and zero extend are
196f7cc78ecSespie@samp{movs@dots{}} and @samp{movz@dots{}} in AT&T syntax (@samp{movsx}
197f7cc78ecSespieand @samp{movzx} in Intel syntax).  The instruction mnemonic suffixes
198f7cc78ecSespieare tacked on to this base name, the @emph{from} suffix before the
199f7cc78ecSespie@emph{to} suffix.  Thus, @samp{movsbl %al, %edx} is AT&T syntax for
2002159047fSniklas``move sign extend @emph{from} %al @emph{to} %edx.''  Possible suffixes,
2012159047fSniklasthus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word),
202b55d4692Sfgsch@samp{wl} (from word to long), @samp{bq} (from byte to quadruple word),
203b55d4692Sfgsch@samp{wq} (from word to quadruple word), and @samp{lq} (from long to
204b55d4692Sfgschquadruple word).
2052159047fSniklas
2062159047fSniklas@cindex conversion instructions, i386
2072159047fSniklas@cindex i386 conversion instructions
208b55d4692Sfgsch@cindex conversion instructions, x86-64
209b55d4692Sfgsch@cindex x86-64 conversion instructions
2102159047fSniklasThe Intel-syntax conversion instructions
2112159047fSniklas
2122159047fSniklas@itemize @bullet
2132159047fSniklas@item
2142159047fSniklas@samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax},
2152159047fSniklas
2162159047fSniklas@item
2172159047fSniklas@samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax},
2182159047fSniklas
2192159047fSniklas@item
2202159047fSniklas@samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax},
2212159047fSniklas
2222159047fSniklas@item
2232159047fSniklas@samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax},
224b55d4692Sfgsch
225b55d4692Sfgsch@item
226b55d4692Sfgsch@samp{cdqe} --- sign-extend dword in @samp{%eax} to quad in @samp{%rax}
227b55d4692Sfgsch(x86-64 only),
228b55d4692Sfgsch
229b55d4692Sfgsch@item
230b55d4692Sfgsch@samp{cdo} --- sign-extend quad in @samp{%rax} to octuple in
231b55d4692Sfgsch@samp{%rdx:%rax} (x86-64 only),
2322159047fSniklas@end itemize
2332159047fSniklas
2342159047fSniklas@noindent
235b55d4692Sfgschare called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, @samp{cltd}, @samp{cltq}, and
236b55d4692Sfgsch@samp{cqto} in AT&T naming.  @code{@value{AS}} accepts either naming for these
237b55d4692Sfgschinstructions.
2382159047fSniklas
2392159047fSniklas@cindex jump instructions, i386
2402159047fSniklas@cindex call instructions, i386
241b55d4692Sfgsch@cindex jump instructions, x86-64
242b55d4692Sfgsch@cindex call instructions, x86-64
2432159047fSniklasFar call/jump instructions are @samp{lcall} and @samp{ljmp} in
2442159047fSniklasAT&T syntax, but are @samp{call far} and @samp{jump far} in Intel
2452159047fSniklasconvention.
2462159047fSniklas
2472159047fSniklas@node i386-Regs
2482159047fSniklas@section Register Naming
2492159047fSniklas
2502159047fSniklas@cindex i386 registers
2512159047fSniklas@cindex registers, i386
252b55d4692Sfgsch@cindex x86-64 registers
253b55d4692Sfgsch@cindex registers, x86-64
254f7cc78ecSespieRegister operands are always prefixed with @samp{%}.  The 80386 registers
2552159047fSniklasconsist of
2562159047fSniklas
2572159047fSniklas@itemize @bullet
2582159047fSniklas@item
2592159047fSniklasthe 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx},
2602159047fSniklas@samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the
2612159047fSniklasframe pointer), and @samp{%esp} (the stack pointer).
2622159047fSniklas
2632159047fSniklas@item
2642159047fSniklasthe 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx},
2652159047fSniklas@samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}.
2662159047fSniklas
2672159047fSniklas@item
2682159047fSniklasthe 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh},
2692159047fSniklas@samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These
2702159047fSniklasare the high-bytes and low-bytes of @samp{%ax}, @samp{%bx},
2712159047fSniklas@samp{%cx}, and @samp{%dx})
2722159047fSniklas
2732159047fSniklas@item
2742159047fSniklasthe 6 section registers @samp{%cs} (code section), @samp{%ds}
2752159047fSniklas(data section), @samp{%ss} (stack section), @samp{%es}, @samp{%fs},
2762159047fSniklasand @samp{%gs}.
2772159047fSniklas
2782159047fSniklas@item
2792159047fSniklasthe 3 processor control registers @samp{%cr0}, @samp{%cr2}, and
2802159047fSniklas@samp{%cr3}.
2812159047fSniklas
2822159047fSniklas@item
2832159047fSniklasthe 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2},
2842159047fSniklas@samp{%db3}, @samp{%db6}, and @samp{%db7}.
2852159047fSniklas
2862159047fSniklas@item
2872159047fSniklasthe 2 test registers @samp{%tr6} and @samp{%tr7}.
2882159047fSniklas
2892159047fSniklas@item
2902159047fSniklasthe 8 floating point register stack @samp{%st} or equivalently
2912159047fSniklas@samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)},
2922159047fSniklas@samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}.
293b55d4692SfgschThese registers are overloaded by 8 MMX registers @samp{%mm0},
294b55d4692Sfgsch@samp{%mm1}, @samp{%mm2}, @samp{%mm3}, @samp{%mm4}, @samp{%mm5},
295b55d4692Sfgsch@samp{%mm6} and @samp{%mm7}.
296b55d4692Sfgsch
297b55d4692Sfgsch@item
298b55d4692Sfgschthe 8 SSE registers registers @samp{%xmm0}, @samp{%xmm1}, @samp{%xmm2},
299b55d4692Sfgsch@samp{%xmm3}, @samp{%xmm4}, @samp{%xmm5}, @samp{%xmm6} and @samp{%xmm7}.
300b55d4692Sfgsch@end itemize
301b55d4692Sfgsch
302b55d4692SfgschThe AMD x86-64 architecture extends the register set by:
303b55d4692Sfgsch
304b55d4692Sfgsch@itemize @bullet
305b55d4692Sfgsch@item
306b55d4692Sfgschenhancing the 8 32-bit registers to 64-bit: @samp{%rax} (the
307b55d4692Sfgschaccumulator), @samp{%rbx}, @samp{%rcx}, @samp{%rdx}, @samp{%rdi},
308b55d4692Sfgsch@samp{%rsi}, @samp{%rbp} (the frame pointer), @samp{%rsp} (the stack
309b55d4692Sfgschpointer)
310b55d4692Sfgsch
311b55d4692Sfgsch@item
312b55d4692Sfgschthe 8 extended registers @samp{%r8}--@samp{%r15}.
313b55d4692Sfgsch
314b55d4692Sfgsch@item
315b55d4692Sfgschthe 8 32-bit low ends of the extended registers: @samp{%r8d}--@samp{%r15d}
316b55d4692Sfgsch
317b55d4692Sfgsch@item
318b55d4692Sfgschthe 8 16-bit low ends of the extended registers: @samp{%r8w}--@samp{%r15w}
319b55d4692Sfgsch
320b55d4692Sfgsch@item
321b55d4692Sfgschthe 8 8-bit low ends of the extended registers: @samp{%r8b}--@samp{%r15b}
322b55d4692Sfgsch
323b55d4692Sfgsch@item
324b55d4692Sfgschthe 4 8-bit registers: @samp{%sil}, @samp{%dil}, @samp{%bpl}, @samp{%spl}.
325b55d4692Sfgsch
326b55d4692Sfgsch@item
327b55d4692Sfgschthe 8 debug registers: @samp{%db8}--@samp{%db15}.
328b55d4692Sfgsch
329b55d4692Sfgsch@item
330b55d4692Sfgschthe 8 SSE registers: @samp{%xmm8}--@samp{%xmm15}.
3312159047fSniklas@end itemize
3322159047fSniklas
333f7cc78ecSespie@node i386-Prefixes
334f7cc78ecSespie@section Instruction Prefixes
3352159047fSniklas
336f7cc78ecSespie@cindex i386 instruction prefixes
337f7cc78ecSespie@cindex instruction prefixes, i386
3382159047fSniklas@cindex prefixes, i386
339f7cc78ecSespieInstruction prefixes are used to modify the following instruction.  They
340f7cc78ecSespieare used to repeat string instructions, to provide section overrides, to
341f7cc78ecSespieperform bus lock operations, and to change operand and address sizes.
342f7cc78ecSespie(Most instructions that normally operate on 32-bit operands will use
343f7cc78ecSespie16-bit operands if the instruction has an ``operand size'' prefix.)
344f7cc78ecSespieInstruction prefixes are best written on the same line as the instruction
345f7cc78ecSespiethey act upon. For example, the @samp{scas} (scan string) instruction is
346f7cc78ecSespierepeated with:
347f7cc78ecSespie
3482159047fSniklas@smallexample
349f7cc78ecSespie        repne scas %es:(%edi),%al
3502159047fSniklas@end smallexample
3512159047fSniklas
352f7cc78ecSespieYou may also place prefixes on the lines immediately preceding the
353f7cc78ecSespieinstruction, but this circumvents checks that @code{@value{AS}} does
354f7cc78ecSespiewith prefixes, and will not work with all prefixes.
355f7cc78ecSespie
356f7cc78ecSespieHere is a list of instruction prefixes:
3572159047fSniklas
3582159047fSniklas@cindex section override prefixes, i386
3592159047fSniklas@itemize @bullet
3602159047fSniklas@item
3612159047fSniklasSection override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es},
3622159047fSniklas@samp{fs}, @samp{gs}.  These are automatically added by specifying
3632159047fSniklasusing the @var{section}:@var{memory-operand} form for memory references.
3642159047fSniklas
3652159047fSniklas@cindex size prefixes, i386
3662159047fSniklas@item
3672159047fSniklasOperand/Address size prefixes @samp{data16} and @samp{addr16}
368f7cc78ecSespiechange 32-bit operands/addresses into 16-bit operands/addresses,
369f7cc78ecSespiewhile @samp{data32} and @samp{addr32} change 16-bit ones (in a
370f7cc78ecSespie@code{.code16} section) into 32-bit operands/addresses.  These prefixes
371f7cc78ecSespie@emph{must} appear on the same line of code as the instruction they
372f7cc78ecSespiemodify. For example, in a 16-bit @code{.code16} section, you might
373f7cc78ecSespiewrite:
374f7cc78ecSespie
375f7cc78ecSespie@smallexample
376f7cc78ecSespie        addr32 jmpl *(%ebx)
377f7cc78ecSespie@end smallexample
3782159047fSniklas
3792159047fSniklas@cindex bus lock prefixes, i386
3802159047fSniklas@cindex inhibiting interrupts, i386
3812159047fSniklas@item
382f7cc78ecSespieThe bus lock prefix @samp{lock} inhibits interrupts during execution of
383f7cc78ecSespiethe instruction it precedes.  (This is only valid with certain
384f7cc78ecSespieinstructions; see a 80386 manual for details).
3852159047fSniklas
3862159047fSniklas@cindex coprocessor wait, i386
3872159047fSniklas@item
388f7cc78ecSespieThe wait for coprocessor prefix @samp{wait} waits for the coprocessor to
389f7cc78ecSespiecomplete the current instruction.  This should never be needed for the
390f7cc78ecSespie80386/80387 combination.
3912159047fSniklas
3922159047fSniklas@cindex repeat prefixes, i386
3932159047fSniklas@item
3942159047fSniklasThe @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added
395f7cc78ecSespieto string instructions to make them repeat @samp{%ecx} times (@samp{%cx}
396f7cc78ecSespietimes if the current address size is 16-bits).
397b55d4692Sfgsch@cindex REX prefixes, i386
398b55d4692Sfgsch@item
399b55d4692SfgschThe @samp{rex} family of prefixes is used by x86-64 to encode
400b55d4692Sfgschextensions to i386 instruction set.  The @samp{rex} prefix has four
401b55d4692Sfgschbits --- an operand size overwrite (@code{64}) used to change operand size
402b55d4692Sfgschfrom 32-bit to 64-bit and X, Y and Z extensions bits used to extend the
403b55d4692Sfgschregister set.
404b55d4692Sfgsch
405b55d4692SfgschYou may write the @samp{rex} prefixes directly. The @samp{rex64xyz}
406b55d4692Sfgschinstruction emits @samp{rex} prefix with all the bits set.  By omitting
407b55d4692Sfgschthe @code{64}, @code{x}, @code{y} or @code{z} you may write other
408b55d4692Sfgschprefixes as well.  Normally, there is no need to write the prefixes
409b55d4692Sfgschexplicitly, since gas will automatically generate them based on the
410b55d4692Sfgschinstruction operands.
4112159047fSniklas@end itemize
4122159047fSniklas
4132159047fSniklas@node i386-Memory
4142159047fSniklas@section Memory References
4152159047fSniklas
4162159047fSniklas@cindex i386 memory references
4172159047fSniklas@cindex memory references, i386
418b55d4692Sfgsch@cindex x86-64 memory references
419b55d4692Sfgsch@cindex memory references, x86-64
4202159047fSniklasAn Intel syntax indirect memory reference of the form
4212159047fSniklas
4222159047fSniklas@smallexample
4232159047fSniklas@var{section}:[@var{base} + @var{index}*@var{scale} + @var{disp}]
4242159047fSniklas@end smallexample
4252159047fSniklas
4262159047fSniklas@noindent
4272159047fSniklasis translated into the AT&T syntax
4282159047fSniklas
4292159047fSniklas@smallexample
4302159047fSniklas@var{section}:@var{disp}(@var{base}, @var{index}, @var{scale})
4312159047fSniklas@end smallexample
4322159047fSniklas
4332159047fSniklas@noindent
4342159047fSniklaswhere @var{base} and @var{index} are the optional 32-bit base and
4352159047fSniklasindex registers, @var{disp} is the optional displacement, and
4362159047fSniklas@var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index}
4372159047fSniklasto calculate the address of the operand.  If no @var{scale} is
4382159047fSniklasspecified, @var{scale} is taken to be 1.  @var{section} specifies the
4392159047fSniklasoptional section register for the memory operand, and may override the
4402159047fSniklasdefault section register (see a 80386 manual for section register
441f7cc78ecSespiedefaults). Note that section overrides in AT&T syntax @emph{must}
4422159047fSniklasbe preceded by a @samp{%}.  If you specify a section override which
4432159047fSniklascoincides with the default section register, @code{@value{AS}} does @emph{not}
4442159047fSniklasoutput any section register override prefixes to assemble the given
4452159047fSniklasinstruction.  Thus, section overrides can be specified to emphasize which
4462159047fSniklassection register is used for a given memory operand.
4472159047fSniklas
4482159047fSniklasHere are some examples of Intel and AT&T style memory references:
4492159047fSniklas
4502159047fSniklas@table @asis
4512159047fSniklas@item AT&T: @samp{-4(%ebp)}, Intel:  @samp{[ebp - 4]}
4522159047fSniklas@var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{section} is
4532159047fSniklasmissing, and the default section is used (@samp{%ss} for addressing with
4542159047fSniklas@samp{%ebp} as the base register).  @var{index}, @var{scale} are both missing.
4552159047fSniklas
4562159047fSniklas@item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]}
4572159047fSniklas@var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is
4582159047fSniklas@samp{foo}.  All other fields are missing.  The section register here
4592159047fSniklasdefaults to @samp{%ds}.
4602159047fSniklas
4612159047fSniklas@item AT&T: @samp{foo(,1)}; Intel @samp{[foo]}
4622159047fSniklasThis uses the value pointed to by @samp{foo} as a memory operand.
4632159047fSniklasNote that @var{base} and @var{index} are both missing, but there is only
4642159047fSniklas@emph{one} @samp{,}.  This is a syntactic exception.
4652159047fSniklas
4662159047fSniklas@item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo}
4672159047fSniklasThis selects the contents of the variable @samp{foo} with section
4682159047fSniklasregister @var{section} being @samp{%gs}.
4692159047fSniklas@end table
4702159047fSniklas
4712159047fSniklasAbsolute (as opposed to PC relative) call and jump operands must be
4722159047fSniklasprefixed with @samp{*}.  If no @samp{*} is specified, @code{@value{AS}}
4732159047fSniklasalways chooses PC relative addressing for jump/call labels.
4742159047fSniklas
475f7cc78ecSespieAny instruction that has a memory operand, but no register operand,
476b55d4692Sfgsch@emph{must} specify its size (byte, word, long, or quadruple) with an
477b55d4692Sfgschinstruction mnemonic suffix (@samp{b}, @samp{w}, @samp{l} or @samp{q},
478b55d4692Sfgschrespectively).
4792159047fSniklas
480b55d4692SfgschThe x86-64 architecture adds an RIP (instruction pointer relative)
481b55d4692Sfgschaddressing.  This addressing mode is specified by using @samp{rip} as a
482b55d4692Sfgschbase register.  Only constant offsets are valid. For example:
483b55d4692Sfgsch
484b55d4692Sfgsch@table @asis
485b55d4692Sfgsch@item AT&T: @samp{1234(%rip)}, Intel: @samp{[rip + 1234]}
486b55d4692SfgschPoints to the address 1234 bytes past the end of the current
487b55d4692Sfgschinstruction.
488b55d4692Sfgsch
489b55d4692Sfgsch@item AT&T: @samp{symbol(%rip)}, Intel: @samp{[rip + symbol]}
490b55d4692SfgschPoints to the @code{symbol} in RIP relative way, this is shorter than
491b55d4692Sfgschthe default absolute addressing.
492b55d4692Sfgsch@end table
493b55d4692Sfgsch
494b55d4692SfgschOther addressing modes remain unchanged in x86-64 architecture, except
495b55d4692Sfgschregisters used are 64-bit instead of 32-bit.
496b55d4692Sfgsch
497b55d4692Sfgsch@node i386-Jumps
4982159047fSniklas@section Handling of Jump Instructions
4992159047fSniklas
5002159047fSniklas@cindex jump optimization, i386
5012159047fSniklas@cindex i386 jump optimization
502b55d4692Sfgsch@cindex jump optimization, x86-64
503b55d4692Sfgsch@cindex x86-64 jump optimization
5042159047fSniklasJump instructions are always optimized to use the smallest possible
5052159047fSniklasdisplacements.  This is accomplished by using byte (8-bit) displacement
5062159047fSniklasjumps whenever the target is sufficiently close.  If a byte displacement
507b55d4692Sfgschis insufficient a long displacement is used.  We do not support
508f7cc78ecSespieword (16-bit) displacement jumps in 32-bit mode (i.e. prefixing the jump
509f7cc78ecSespieinstruction with the @samp{data16} instruction prefix), since the 80386
510f7cc78ecSespieinsists upon masking @samp{%eip} to 16 bits after the word displacement
511b55d4692Sfgschis added. (See also @pxref{i386-Arch})
5122159047fSniklas
5132159047fSniklasNote that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz},
5142159047fSniklas@samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in byte
5152159047fSniklasdisplacements, so that if you use these instructions (@code{@value{GCC}} does
5162159047fSniklasnot use them) you may get an error message (and incorrect code).  The AT&T
5172159047fSniklas80386 assembler tries to get around this problem by expanding @samp{jcxz foo}
5182159047fSniklasto
5192159047fSniklas
5202159047fSniklas@smallexample
5212159047fSniklas         jcxz cx_zero
5222159047fSniklas         jmp cx_nonzero
5232159047fSniklascx_zero: jmp foo
5242159047fSniklascx_nonzero:
5252159047fSniklas@end smallexample
5262159047fSniklas
5272159047fSniklas@node i386-Float
5282159047fSniklas@section Floating Point
5292159047fSniklas
5302159047fSniklas@cindex i386 floating point
5312159047fSniklas@cindex floating point, i386
532b55d4692Sfgsch@cindex x86-64 floating point
533b55d4692Sfgsch@cindex floating point, x86-64
5342159047fSniklasAll 80387 floating point types except packed BCD are supported.
5352159047fSniklas(BCD support may be added without much difficulty).  These data
5362159047fSniklastypes are 16-, 32-, and 64- bit integers, and single (32-bit),
5372159047fSniklasdouble (64-bit), and extended (80-bit) precision floating point.
538f7cc78ecSespieEach supported type has an instruction mnemonic suffix and a constructor
539f7cc78ecSespieassociated with it.  Instruction mnemonic suffixes specify the operand's
540f7cc78ecSespiedata type.  Constructors build these data types into memory.
5412159047fSniklas
5422159047fSniklas@cindex @code{float} directive, i386
5432159047fSniklas@cindex @code{single} directive, i386
5442159047fSniklas@cindex @code{double} directive, i386
5452159047fSniklas@cindex @code{tfloat} directive, i386
546b55d4692Sfgsch@cindex @code{float} directive, x86-64
547b55d4692Sfgsch@cindex @code{single} directive, x86-64
548b55d4692Sfgsch@cindex @code{double} directive, x86-64
549b55d4692Sfgsch@cindex @code{tfloat} directive, x86-64
5502159047fSniklas@itemize @bullet
5512159047fSniklas@item
5522159047fSniklasFloating point constructors are @samp{.float} or @samp{.single},
5532159047fSniklas@samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats.
554f7cc78ecSespieThese correspond to instruction mnemonic suffixes @samp{s}, @samp{l},
555f7cc78ecSespieand @samp{t}. @samp{t} stands for 80-bit (ten byte) real.  The 80387
556f7cc78ecSespieonly supports this format via the @samp{fldt} (load 80-bit real to stack
557f7cc78ecSespietop) and @samp{fstpt} (store 80-bit real and pop stack) instructions.
5582159047fSniklas
5592159047fSniklas@cindex @code{word} directive, i386
5602159047fSniklas@cindex @code{long} directive, i386
5612159047fSniklas@cindex @code{int} directive, i386
5622159047fSniklas@cindex @code{quad} directive, i386
563b55d4692Sfgsch@cindex @code{word} directive, x86-64
564b55d4692Sfgsch@cindex @code{long} directive, x86-64
565b55d4692Sfgsch@cindex @code{int} directive, x86-64
566b55d4692Sfgsch@cindex @code{quad} directive, x86-64
5672159047fSniklas@item
5682159047fSniklasInteger constructors are @samp{.word}, @samp{.long} or @samp{.int}, and
569f7cc78ecSespie@samp{.quad} for the 16-, 32-, and 64-bit integer formats.  The
570f7cc78ecSespiecorresponding instruction mnemonic suffixes are @samp{s} (single),
571f7cc78ecSespie@samp{l} (long), and @samp{q} (quad).  As with the 80-bit real format,
572f7cc78ecSespiethe 64-bit @samp{q} format is only present in the @samp{fildq} (load
573f7cc78ecSespiequad integer to stack top) and @samp{fistpq} (store quad integer and pop
574f7cc78ecSespiestack) instructions.
5752159047fSniklas@end itemize
5762159047fSniklas
577f7cc78ecSespieRegister to register operations should not use instruction mnemonic suffixes.
578f7cc78ecSespie@samp{fstl %st, %st(1)} will give a warning, and be assembled as if you
579f7cc78ecSespiewrote @samp{fst %st, %st(1)}, since all register to register operations
580f7cc78ecSespieuse 80-bit floating point operands. (Contrast this with @samp{fstl %st, mem},
581f7cc78ecSespiewhich converts @samp{%st} from 80-bit to 64-bit floating point format,
582f7cc78ecSespiethen stores the result in the 4 byte location @samp{mem})
5832159047fSniklas
584f7cc78ecSespie@node i386-SIMD
585f7cc78ecSespie@section Intel's MMX and AMD's 3DNow! SIMD Operations
586f7cc78ecSespie
587f7cc78ecSespie@cindex MMX, i386
588f7cc78ecSespie@cindex 3DNow!, i386
589f7cc78ecSespie@cindex SIMD, i386
590b55d4692Sfgsch@cindex MMX, x86-64
591b55d4692Sfgsch@cindex 3DNow!, x86-64
592b55d4692Sfgsch@cindex SIMD, x86-64
593f7cc78ecSespie
594f7cc78ecSespie@code{@value{AS}} supports Intel's MMX instruction set (SIMD
595f7cc78ecSespieinstructions for integer data), available on Intel's Pentium MMX
596f7cc78ecSespieprocessors and Pentium II processors, AMD's K6 and K6-2 processors,
597f7cc78ecSespieCyrix' M2 processor, and probably others.  It also supports AMD's 3DNow!
598f7cc78ecSespieinstruction set (SIMD instructions for 32-bit floating point data)
599f7cc78ecSespieavailable on AMD's K6-2 processor and possibly others in the future.
600f7cc78ecSespie
601f7cc78ecSespieCurrently, @code{@value{AS}} does not support Intel's floating point
602f7cc78ecSespieSIMD, Katmai (KNI).
603f7cc78ecSespie
604f7cc78ecSespieThe eight 64-bit MMX operands, also used by 3DNow!, are called @samp{%mm0},
605f7cc78ecSespie@samp{%mm1}, ... @samp{%mm7}.  They contain eight 8-bit integers, four
606f7cc78ecSespie16-bit integers, two 32-bit integers, one 64-bit integer, or two 32-bit
607f7cc78ecSespiefloating point values.  The MMX registers cannot be used at the same time
608f7cc78ecSespieas the floating point stack.
609f7cc78ecSespie
610f7cc78ecSespieSee Intel and AMD documentation, keeping in mind that the operand order in
611f7cc78ecSespieinstructions is reversed from the Intel syntax.
6122159047fSniklas
6132159047fSniklas@node i386-16bit
6142159047fSniklas@section Writing 16-bit Code
6152159047fSniklas
6162159047fSniklas@cindex i386 16-bit code
6172159047fSniklas@cindex 16-bit code, i386
6182159047fSniklas@cindex real-mode code, i386
619f7cc78ecSespie@cindex @code{code16gcc} directive, i386
6202159047fSniklas@cindex @code{code16} directive, i386
6212159047fSniklas@cindex @code{code32} directive, i386
622b55d4692Sfgsch@cindex @code{code64} directive, i386
623b55d4692Sfgsch@cindex @code{code64} directive, x86-64
624b55d4692SfgschWhile @code{@value{AS}} normally writes only ``pure'' 32-bit i386 code
625b55d4692Sfgschor 64-bit x86-64 code depending on the default configuration,
626f7cc78ecSespieit also supports writing code to run in real mode or in 16-bit protected
627f7cc78ecSespiemode code segments.  To do this, put a @samp{.code16} or
628f7cc78ecSespie@samp{.code16gcc} directive before the assembly language instructions to
629f7cc78ecSespiebe run in 16-bit mode.  You can switch @code{@value{AS}} back to writing
630f7cc78ecSespienormal 32-bit code with the @samp{.code32} directive.
6312159047fSniklas
632f7cc78ecSespie@samp{.code16gcc} provides experimental support for generating 16-bit
633f7cc78ecSespiecode from gcc, and differs from @samp{.code16} in that @samp{call},
634f7cc78ecSespie@samp{ret}, @samp{enter}, @samp{leave}, @samp{push}, @samp{pop},
635f7cc78ecSespie@samp{pusha}, @samp{popa}, @samp{pushf}, and @samp{popf} instructions
636f7cc78ecSespiedefault to 32-bit size.  This is so that the stack pointer is
637f7cc78ecSespiemanipulated in the same way over function calls, allowing access to
638f7cc78ecSespiefunction parameters at the same stack offsets as in 32-bit mode.
639f7cc78ecSespie@samp{.code16gcc} also automatically adds address size prefixes where
640f7cc78ecSespienecessary to use the 32-bit addressing modes that gcc generates.
6412159047fSniklas
642f7cc78ecSespieThe code which @code{@value{AS}} generates in 16-bit mode will not
643f7cc78ecSespienecessarily run on a 16-bit pre-80386 processor.  To write code that
644f7cc78ecSespieruns on such a processor, you must refrain from using @emph{any} 32-bit
645f7cc78ecSespieconstructs which require @code{@value{AS}} to output address or operand
646f7cc78ecSespiesize prefixes.
6472159047fSniklas
648f7cc78ecSespieNote that writing 16-bit code instructions by explicitly specifying a
649f7cc78ecSespieprefix or an instruction mnemonic suffix within a 32-bit code section
650f7cc78ecSespiegenerates different machine instructions than those generated for a
651f7cc78ecSespie16-bit code segment.  In a 32-bit code section, the following code
652f7cc78ecSespiegenerates the machine opcode bytes @samp{66 6a 04}, which pushes the
653f7cc78ecSespievalue @samp{4} onto the stack, decrementing @samp{%esp} by 2.
654f7cc78ecSespie
655f7cc78ecSespie@smallexample
656f7cc78ecSespie        pushw $4
657f7cc78ecSespie@end smallexample
658f7cc78ecSespie
659f7cc78ecSespieThe same code in a 16-bit code section would generate the machine
660f7cc78ecSespieopcode bytes @samp{6a 04} (ie. without the operand size prefix), which
661f7cc78ecSespieis correct since the processor default operand size is assumed to be 16
662f7cc78ecSespiebits in a 16-bit code section.
663f7cc78ecSespie
664f7cc78ecSespie@node i386-Bugs
665f7cc78ecSespie@section AT&T Syntax bugs
666f7cc78ecSespie
667f7cc78ecSespieThe UnixWare assembler, and probably other AT&T derived ix86 Unix
668f7cc78ecSespieassemblers, generate floating point instructions with reversed source
669f7cc78ecSespieand destination registers in certain cases.  Unfortunately, gcc and
670f7cc78ecSespiepossibly many other programs use this reversed syntax, so we're stuck
671f7cc78ecSespiewith it.
672f7cc78ecSespie
673f7cc78ecSespieFor example
674f7cc78ecSespie
675f7cc78ecSespie@smallexample
676f7cc78ecSespie        fsub %st,%st(3)
677f7cc78ecSespie@end smallexample
678f7cc78ecSespie@noindent
679f7cc78ecSespieresults in @samp{%st(3)} being updated to @samp{%st - %st(3)} rather
680f7cc78ecSespiethan the expected @samp{%st(3) - %st}.  This happens with all the
681f7cc78ecSespienon-commutative arithmetic floating point operations with two register
682f7cc78ecSespieoperands where the source register is @samp{%st} and the destination
683f7cc78ecSespieregister is @samp{%st(i)}.
6842159047fSniklas
685b55d4692Sfgsch@node i386-Arch
686b55d4692Sfgsch@section Specifying CPU Architecture
687b55d4692Sfgsch
688b55d4692Sfgsch@cindex arch directive, i386
689b55d4692Sfgsch@cindex i386 arch directive
690b55d4692Sfgsch@cindex arch directive, x86-64
691b55d4692Sfgsch@cindex x86-64 arch directive
692b55d4692Sfgsch
693b55d4692Sfgsch@code{@value{AS}} may be told to assemble for a particular CPU
694b55d4692Sfgscharchitecture with the @code{.arch @var{cpu_type}} directive.  This
695b55d4692Sfgschdirective enables a warning when gas detects an instruction that is not
696b55d4692Sfgschsupported on the CPU specified.  The choices for @var{cpu_type} are:
697b55d4692Sfgsch
698b55d4692Sfgsch@multitable @columnfractions .20 .20 .20 .20
699b55d4692Sfgsch@item @samp{i8086} @tab @samp{i186} @tab @samp{i286} @tab @samp{i386}
700b55d4692Sfgsch@item @samp{i486} @tab @samp{i586} @tab @samp{i686} @tab @samp{pentium}
701b55d4692Sfgsch@item @samp{pentiumpro} @tab @samp{pentium4} @tab @samp{k6} @tab @samp{athlon}
702b55d4692Sfgsch@item @samp{sledgehammer}
703b55d4692Sfgsch@end multitable
704b55d4692Sfgsch
705b55d4692SfgschApart from the warning, there are only two other effects on
706b55d4692Sfgsch@code{@value{AS}} operation;  Firstly, if you specify a CPU other than
707b55d4692Sfgsch@samp{i486}, then shift by one instructions such as @samp{sarl $1, %eax}
708b55d4692Sfgschwill automatically use a two byte opcode sequence.  The larger three
709b55d4692Sfgschbyte opcode sequence is used on the 486 (and when no architecture is
710b55d4692Sfgschspecified) because it executes faster on the 486.  Note that you can
711b55d4692Sfgschexplicitly request the two byte opcode by writing @samp{sarl %eax}.
712b55d4692SfgschSecondly, if you specify @samp{i8086}, @samp{i186}, or @samp{i286},
713b55d4692Sfgsch@emph{and} @samp{.code16} or @samp{.code16gcc} then byte offset
714b55d4692Sfgschconditional jumps will be promoted when necessary to a two instruction
715b55d4692Sfgschsequence consisting of a conditional jump of the opposite sense around
716b55d4692Sfgschan unconditional jump to the target.
717b55d4692Sfgsch
718b55d4692SfgschFollowing the CPU architecture, you may specify @samp{jumps} or
719b55d4692Sfgsch@samp{nojumps} to control automatic promotion of conditional jumps.
720b55d4692Sfgsch@samp{jumps} is the default, and enables jump promotion;  All external
721b55d4692Sfgschjumps will be of the long variety, and file-local jumps will be promoted
722b55d4692Sfgschas necessary.  (@pxref{i386-Jumps})  @samp{nojumps} leaves external
723b55d4692Sfgschconditional jumps as byte offset jumps, and warns about file-local
724b55d4692Sfgschconditional jumps that @code{@value{AS}} promotes.
725b55d4692SfgschUnconditional jumps are treated as for @samp{jumps}.
726b55d4692Sfgsch
727b55d4692SfgschFor example
728b55d4692Sfgsch
729b55d4692Sfgsch@smallexample
730b55d4692Sfgsch .arch i8086,nojumps
731b55d4692Sfgsch@end smallexample
732b55d4692Sfgsch
7332159047fSniklas@node i386-Notes
7342159047fSniklas@section Notes
7352159047fSniklas
7362159047fSniklas@cindex i386 @code{mul}, @code{imul} instructions
7372159047fSniklas@cindex @code{mul} instruction, i386
7382159047fSniklas@cindex @code{imul} instruction, i386
739b55d4692Sfgsch@cindex @code{mul} instruction, x86-64
740b55d4692Sfgsch@cindex @code{imul} instruction, x86-64
7412159047fSniklasThere is some trickery concerning the @samp{mul} and @samp{imul}
742b55d4692Sfgschinstructions that deserves mention.  The 16-, 32-, 64- and 128-bit expanding
7432159047fSniklasmultiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5
7442159047fSniklasfor @samp{imul}) can be output only in the one operand form.  Thus,
7452159047fSniklas@samp{imul %ebx, %eax} does @emph{not} select the expanding multiply;
7462159047fSniklasthe expanding multiply would clobber the @samp{%edx} register, and this
7472159047fSniklaswould confuse @code{@value{GCC}} output.  Use @samp{imul %ebx} to get the
7482159047fSniklas64-bit product in @samp{%edx:%eax}.
7492159047fSniklas
7502159047fSniklasWe have added a two operand form of @samp{imul} when the first operand
7512159047fSniklasis an immediate mode expression and the second operand is a register.
7522159047fSniklasThis is just a shorthand, so that, multiplying @samp{%eax} by 69, for
7532159047fSniklasexample, can be done with @samp{imul $69, %eax} rather than @samp{imul
7542159047fSniklas$69, %eax, %eax}.
7552159047fSniklas
756