hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the GNU Assembler "as".
 
Copyright (C) 1991-2021 Free Software Foundation, Inc.
 
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts.  A copy of the license is included in the
section entitled "GNU Free Documentation License".
 -->
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Using as: i386-Mnemonics</title>
 
<meta name="description" content="Using as: i386-Mnemonics">
<meta name="keywords" content="Using as: i386-Mnemonics">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="i386_002dDependent.html#i386_002dDependent" rel="up" title="i386-Dependent">
<link href="i386_002dRegs.html#i386_002dRegs" rel="next" title="i386-Regs">
<link href="i386_002dChars.html#i386_002dChars" rel="previous" title="i386-Chars">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="i386_002dMnemonics"></a>
<div class="header">
<p>
Next: <a href="i386_002dRegs.html#i386_002dRegs" accesskey="n" rel="next">i386-Regs</a>, Previous: <a href="i386_002dSyntax.html#i386_002dSyntax" accesskey="p" rel="previous">i386-Syntax</a>, Up: <a href="i386_002dDependent.html#i386_002dDependent" accesskey="u" rel="up">i386-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="i386_002dMnemonics-1"></a>
<h4 class="subsection">9.16.4 i386-Mnemonics</h4>
<a name="Instruction-Naming"></a>
<h4 class="subsubsection">9.16.4.1 Instruction Naming</h4>
 
<a name="index-i386-instruction-naming"></a>
<a name="index-instruction-naming_002c-i386"></a>
<a name="index-x86_002d64-instruction-naming"></a>
<a name="index-instruction-naming_002c-x86_002d64"></a>
 
<p>Instruction mnemonics are suffixed with one character modifiers which
specify the size of operands.  The letters &lsquo;<samp>b</samp>&rsquo;, &lsquo;<samp>w</samp>&rsquo;, &lsquo;<samp>l</samp>&rsquo;
and &lsquo;<samp>q</samp>&rsquo; specify byte, word, long and quadruple word operands.  If
no suffix is specified by an instruction then <code>as</code> tries to
fill in the missing suffix based on the destination register operand
(the last one by convention).  Thus, &lsquo;<samp>mov %ax, %bx</samp>&rsquo; is equivalent
to &lsquo;<samp>movw %ax, %bx</samp>&rsquo;; also, &lsquo;<samp>mov $1, %bx</samp>&rsquo; is equivalent to
&lsquo;<samp>movw $1, bx</samp>&rsquo;.  Note that this is incompatible with the AT&amp;T Unix
assembler which assumes that a missing mnemonic suffix implies long
operand size.  (This incompatibility does not affect compiler output
since compilers always explicitly specify the mnemonic suffix.)
</p>
<p>When there is no sizing suffix and no (suitable) register operands to
deduce the size of memory operands, with a few exceptions and where long
operand size is possible in the first place, operand size will default
to long in 32- and 64-bit modes.  Similarly it will default to short in
16-bit mode. Noteworthy exceptions are
</p>
<ul>
<li> Instructions with an implicit on-stack operand as well as branches,
which default to quad in 64-bit mode.
 
</li><li> Sign- and zero-extending moves, which default to byte size source
operands.
 
</li><li> Floating point insns with integer operands, which default to short (for
perhaps historical reasons).
 
</li><li> CRC32 with a 64-bit destination, which defaults to a quad source
operand.
 
</li></ul>
 
<a name="index-encoding-options_002c-i386"></a>
<a name="index-encoding-options_002c-x86_002d64"></a>
 
<p>Different encoding options can be specified via pseudo prefixes:
</p>
<ul>
<li> &lsquo;<samp>{disp8}</samp>&rsquo; &ndash; prefer 8-bit displacement.
 
</li><li> &lsquo;<samp>{disp32}</samp>&rsquo; &ndash; prefer 32-bit displacement.
 
</li><li> &lsquo;<samp>{disp16}</samp>&rsquo; &ndash; prefer 16-bit displacement.
 
</li><li> &lsquo;<samp>{load}</samp>&rsquo; &ndash; prefer load-form instruction.
 
</li><li> &lsquo;<samp>{store}</samp>&rsquo; &ndash; prefer store-form instruction.
 
</li><li> &lsquo;<samp>{vex}</samp>&rsquo; &ndash;  encode with VEX prefix.
 
</li><li> &lsquo;<samp>{vex3}</samp>&rsquo; &ndash; encode with 3-byte VEX prefix.
 
</li><li> &lsquo;<samp>{evex}</samp>&rsquo; &ndash;  encode with EVEX prefix.
 
</li><li> &lsquo;<samp>{rex}</samp>&rsquo; &ndash; prefer REX prefix for integer and legacy vector
instructions (x86-64 only).  Note that this differs from the &lsquo;<samp>rex</samp>&rsquo;
prefix which generates REX prefix unconditionally.
 
</li><li> &lsquo;<samp>{nooptimize}</samp>&rsquo; &ndash; disable instruction size optimization.
</li></ul>
 
<p>Mnemonics of Intel VNNI instructions are encoded with the EVEX prefix
by default.  The pseudo &lsquo;<samp>{vex}</samp>&rsquo; prefix can be used to encode
mnemonics of Intel VNNI instructions with the VEX prefix.
</p>
<a name="index-conversion-instructions_002c-i386"></a>
<a name="index-i386-conversion-instructions"></a>
<a name="index-conversion-instructions_002c-x86_002d64"></a>
<a name="index-x86_002d64-conversion-instructions"></a>
<p>The Intel-syntax conversion instructions
</p>
<ul>
<li> &lsquo;<samp>cbw</samp>&rsquo; &mdash; sign-extend byte in &lsquo;<samp>%al</samp>&rsquo; to word in &lsquo;<samp>%ax</samp>&rsquo;,
 
</li><li> &lsquo;<samp>cwde</samp>&rsquo; &mdash; sign-extend word in &lsquo;<samp>%ax</samp>&rsquo; to long in &lsquo;<samp>%eax</samp>&rsquo;,
 
</li><li> &lsquo;<samp>cwd</samp>&rsquo; &mdash; sign-extend word in &lsquo;<samp>%ax</samp>&rsquo; to long in &lsquo;<samp>%dx:%ax</samp>&rsquo;,
 
</li><li> &lsquo;<samp>cdq</samp>&rsquo; &mdash; sign-extend dword in &lsquo;<samp>%eax</samp>&rsquo; to quad in &lsquo;<samp>%edx:%eax</samp>&rsquo;,
 
</li><li> &lsquo;<samp>cdqe</samp>&rsquo; &mdash; sign-extend dword in &lsquo;<samp>%eax</samp>&rsquo; to quad in &lsquo;<samp>%rax</samp>&rsquo;
(x86-64 only),
 
</li><li> &lsquo;<samp>cqo</samp>&rsquo; &mdash; sign-extend quad in &lsquo;<samp>%rax</samp>&rsquo; to octuple in
&lsquo;<samp>%rdx:%rax</samp>&rsquo; (x86-64 only),
</li></ul>
 
<p>are called &lsquo;<samp>cbtw</samp>&rsquo;, &lsquo;<samp>cwtl</samp>&rsquo;, &lsquo;<samp>cwtd</samp>&rsquo;, &lsquo;<samp>cltd</samp>&rsquo;, &lsquo;<samp>cltq</samp>&rsquo;, and
&lsquo;<samp>cqto</samp>&rsquo; in AT&amp;T naming.  <code>as</code> accepts either naming for these
instructions.
</p>
<a name="index-extension-instructions_002c-i386"></a>
<a name="index-i386-extension-instructions"></a>
<a name="index-extension-instructions_002c-x86_002d64"></a>
<a name="index-x86_002d64-extension-instructions"></a>
<p>The Intel-syntax extension instructions
</p>
<ul>
<li> &lsquo;<samp>movsx</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg16</samp>&rsquo;.
 
</li><li> &lsquo;<samp>movsx</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg32</samp>&rsquo;.
 
</li><li> &lsquo;<samp>movsx</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg64</samp>&rsquo;
(x86-64 only).
 
</li><li> &lsquo;<samp>movsx</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg16/mem16</samp>&rsquo; to &lsquo;<samp>reg32</samp>&rsquo;
 
</li><li> &lsquo;<samp>movsx</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg16/mem16</samp>&rsquo; to &lsquo;<samp>reg64</samp>&rsquo;
(x86-64 only).
 
</li><li> &lsquo;<samp>movsxd</samp>&rsquo; &mdash; sign-extend &lsquo;<samp>reg32/mem32</samp>&rsquo; to &lsquo;<samp>reg64</samp>&rsquo;
(x86-64 only).
 
</li><li> &lsquo;<samp>movzx</samp>&rsquo; &mdash; zero-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg16</samp>&rsquo;.
 
</li><li> &lsquo;<samp>movzx</samp>&rsquo; &mdash; zero-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg32</samp>&rsquo;.
 
</li><li> &lsquo;<samp>movzx</samp>&rsquo; &mdash; zero-extend &lsquo;<samp>reg8/mem8</samp>&rsquo; to &lsquo;<samp>reg64</samp>&rsquo;
(x86-64 only).
 
</li><li> &lsquo;<samp>movzx</samp>&rsquo; &mdash; zero-extend &lsquo;<samp>reg16/mem16</samp>&rsquo; to &lsquo;<samp>reg32</samp>&rsquo;
 
</li><li> &lsquo;<samp>movzx</samp>&rsquo; &mdash; zero-extend &lsquo;<samp>reg16/mem16</samp>&rsquo; to &lsquo;<samp>reg64</samp>&rsquo;
(x86-64 only).
</li></ul>
 
<p>are called &lsquo;<samp>movsbw/movsxb/movsx</samp>&rsquo;, &lsquo;<samp>movsbl/movsxb/movsx</samp>&rsquo;,
&lsquo;<samp>movsbq/movsb/movsx</samp>&rsquo;, &lsquo;<samp>movswl/movsxw</samp>&rsquo;, &lsquo;<samp>movswq/movsxw</samp>&rsquo;,
&lsquo;<samp>movslq/movsxl</samp>&rsquo;, &lsquo;<samp>movzbw/movzxb/movzx</samp>&rsquo;,
&lsquo;<samp>movzbl/movzxb/movzx</samp>&rsquo;, &lsquo;<samp>movzbq/movzxb/movzx</samp>&rsquo;,
&lsquo;<samp>movzwl/movzxw</samp>&rsquo; and &lsquo;<samp>movzwq/movzxw</samp>&rsquo; in AT&amp;T syntax.
</p>
<a name="index-jump-instructions_002c-i386"></a>
<a name="index-call-instructions_002c-i386"></a>
<a name="index-jump-instructions_002c-x86_002d64"></a>
<a name="index-call-instructions_002c-x86_002d64"></a>
<p>Far call/jump instructions are &lsquo;<samp>lcall</samp>&rsquo; and &lsquo;<samp>ljmp</samp>&rsquo; in
AT&amp;T syntax, but are &lsquo;<samp>call far</samp>&rsquo; and &lsquo;<samp>jump far</samp>&rsquo; in Intel
convention.
</p>
<a name="AT_0026T-Mnemonic-versus-Intel-Mnemonic"></a>
<h4 class="subsubsection">9.16.4.2 AT&amp;T Mnemonic versus Intel Mnemonic</h4>
 
<a name="index-i386-mnemonic-compatibility"></a>
<a name="index-mnemonic-compatibility_002c-i386"></a>
 
<p><code>as</code> supports assembly using Intel mnemonic.
<code>.intel_mnemonic</code> selects Intel mnemonic with Intel syntax, and
<code>.att_mnemonic</code> switches back to the usual AT&amp;T mnemonic with AT&amp;T
syntax for compatibility with the output of <code>gcc</code>.
Several x87 instructions, &lsquo;<samp>fadd</samp>&rsquo;, &lsquo;<samp>fdiv</samp>&rsquo;, &lsquo;<samp>fdivp</samp>&rsquo;,
&lsquo;<samp>fdivr</samp>&rsquo;, &lsquo;<samp>fdivrp</samp>&rsquo;, &lsquo;<samp>fmul</samp>&rsquo;, &lsquo;<samp>fsub</samp>&rsquo;, &lsquo;<samp>fsubp</samp>&rsquo;,
&lsquo;<samp>fsubr</samp>&rsquo; and &lsquo;<samp>fsubrp</samp>&rsquo;,  are implemented in AT&amp;T System V/386
assembler with different mnemonics from those in Intel IA32 specification.
<code>gcc</code> generates those instructions with AT&amp;T mnemonic.
</p>
<ul>
<li> &lsquo;<samp>movslq</samp>&rsquo; with AT&amp;T mnemonic only accepts 64-bit destination
register.  &lsquo;<samp>movsxd</samp>&rsquo; should be used to encode 16-bit or 32-bit
destination register with both AT&amp;T and Intel mnemonics.
</li></ul>
 
<hr>
<div class="header">
<p>
Next: <a href="i386_002dRegs.html#i386_002dRegs" accesskey="n" rel="next">i386-Regs</a>, Previous: <a href="i386_002dSyntax.html#i386_002dSyntax" accesskey="p" rel="previous">i386-Syntax</a>, Up: <a href="i386_002dDependent.html#i386_002dDependent" accesskey="u" rel="up">i386-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
</div>
 
 
 
</body>
</html>