175 lines
9.4 KiB
HTML
175 lines
9.4 KiB
HTML
<!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-2016 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.2, 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="prev" 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="prev">i386-Syntax</a>, Up: <a href="i386_002dDependent.html#i386_002dDependent" accesskey="u" rel="up">i386-Dependent</a> [<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.15.4 i386-Mnemonics</h4>
|
|
<a name="Instruction-Naming"></a>
|
|
<h4 class="subsubsection">9.15.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 ‘<samp>b</samp>’, ‘<samp>w</samp>’, ‘<samp>l</samp>’
|
|
and ‘<samp>q</samp>’ 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, ‘<samp>mov %ax, %bx</samp>’ is equivalent
|
|
to ‘<samp>movw %ax, %bx</samp>’; also, ‘<samp>mov $1, %bx</samp>’ is equivalent to
|
|
‘<samp>movw $1, bx</samp>’. Note that this is incompatible with the AT&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>Almost all instructions have the same names in AT&T and Intel format.
|
|
There are a few exceptions. The sign extend and zero extend
|
|
instructions need two sizes to specify them. They need a size to
|
|
sign/zero extend <em>from</em> and a size to zero extend <em>to</em>. This
|
|
is accomplished by using two instruction mnemonic suffixes in AT&T
|
|
syntax. Base names for sign extend and zero extend are
|
|
‘<samp>movs…</samp>’ and ‘<samp>movz…</samp>’ in AT&T syntax (‘<samp>movsx</samp>’
|
|
and ‘<samp>movzx</samp>’ in Intel syntax). The instruction mnemonic suffixes
|
|
are tacked on to this base name, the <em>from</em> suffix before the
|
|
<em>to</em> suffix. Thus, ‘<samp>movsbl %al, %edx</samp>’ is AT&T syntax for
|
|
“move sign extend <em>from</em> %al <em>to</em> %edx.” Possible suffixes,
|
|
thus, are ‘<samp>bl</samp>’ (from byte to long), ‘<samp>bw</samp>’ (from byte to word),
|
|
‘<samp>wl</samp>’ (from word to long), ‘<samp>bq</samp>’ (from byte to quadruple word),
|
|
‘<samp>wq</samp>’ (from word to quadruple word), and ‘<samp>lq</samp>’ (from long to
|
|
quadruple word).
|
|
</p>
|
|
<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 optional mnemonic
|
|
suffix. ‘<samp>.s</samp>’ suffix swaps 2 register operands in encoding when
|
|
moving from one register to another. ‘<samp>.d8</samp>’ or ‘<samp>.d32</samp>’ suffix
|
|
prefers 8bit or 32bit displacement in encoding.
|
|
</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> ‘<samp>cbw</samp>’ — sign-extend byte in ‘<samp>%al</samp>’ to word in ‘<samp>%ax</samp>’,
|
|
|
|
</li><li> ‘<samp>cwde</samp>’ — sign-extend word in ‘<samp>%ax</samp>’ to long in ‘<samp>%eax</samp>’,
|
|
|
|
</li><li> ‘<samp>cwd</samp>’ — sign-extend word in ‘<samp>%ax</samp>’ to long in ‘<samp>%dx:%ax</samp>’,
|
|
|
|
</li><li> ‘<samp>cdq</samp>’ — sign-extend dword in ‘<samp>%eax</samp>’ to quad in ‘<samp>%edx:%eax</samp>’,
|
|
|
|
</li><li> ‘<samp>cdqe</samp>’ — sign-extend dword in ‘<samp>%eax</samp>’ to quad in ‘<samp>%rax</samp>’
|
|
(x86-64 only),
|
|
|
|
</li><li> ‘<samp>cqo</samp>’ — sign-extend quad in ‘<samp>%rax</samp>’ to octuple in
|
|
‘<samp>%rdx:%rax</samp>’ (x86-64 only),
|
|
</li></ul>
|
|
|
|
<p>are called ‘<samp>cbtw</samp>’, ‘<samp>cwtl</samp>’, ‘<samp>cwtd</samp>’, ‘<samp>cltd</samp>’, ‘<samp>cltq</samp>’, and
|
|
‘<samp>cqto</samp>’ in AT&T naming. <code>as</code> accepts either naming for these
|
|
instructions.
|
|
</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 ‘<samp>lcall</samp>’ and ‘<samp>ljmp</samp>’ in
|
|
AT&T syntax, but are ‘<samp>call far</samp>’ and ‘<samp>jump far</samp>’ in Intel
|
|
convention.
|
|
</p>
|
|
<a name="AT_0026T-Mnemonic-versus-Intel-Mnemonic"></a>
|
|
<h4 class="subsubsection">9.15.4.2 AT&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&T mnemonic with AT&T
|
|
syntax for compatibility with the output of <code>gcc</code>.
|
|
Several x87 instructions, ‘<samp>fadd</samp>’, ‘<samp>fdiv</samp>’, ‘<samp>fdivp</samp>’,
|
|
‘<samp>fdivr</samp>’, ‘<samp>fdivrp</samp>’, ‘<samp>fmul</samp>’, ‘<samp>fsub</samp>’, ‘<samp>fsubp</samp>’,
|
|
‘<samp>fsubr</samp>’ and ‘<samp>fsubrp</samp>’, are implemented in AT&T System V/386
|
|
assembler with different mnemonics from those in Intel IA32 specification.
|
|
<code>gcc</code> generates those instructions with AT&T mnemonic.
|
|
</p>
|
|
<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="prev">i386-Syntax</a>, Up: <a href="i386_002dDependent.html#i386_002dDependent" accesskey="u" rel="up">i386-Dependent</a> [<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>
|