You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
9.4 KiB
HTML
129 lines
9.4 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>i386-Mnemonics - Using as</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="Using as">
|
||
|
<meta name="generator" content="makeinfo 4.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="i386_002dDependent.html#i386_002dDependent" title="i386-Dependent">
|
||
|
<link rel="prev" href="i386_002dSyntax.html#i386_002dSyntax" title="i386-Syntax">
|
||
|
<link rel="next" href="i386_002dRegs.html#i386_002dRegs" title="i386-Regs">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
This file documents the GNU Assembler "as".
|
||
|
|
||
|
Copyright (C) 1991-2015 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''.
|
||
|
|
||
|
-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family:serif; font-weight:normal; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="i386-Mnemonics"></a>
|
||
|
<a name="i386_002dMnemonics"></a>
|
||
|
<p>
|
||
|
Next: <a rel="next" accesskey="n" href="i386_002dRegs.html#i386_002dRegs">i386-Regs</a>,
|
||
|
Previous: <a rel="previous" accesskey="p" href="i386_002dSyntax.html#i386_002dSyntax">i386-Syntax</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="i386_002dDependent.html#i386_002dDependent">i386-Dependent</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h4 class="subsection">9.15.4 i386-Mnemonics</h4>
|
||
|
|
||
|
<h5 class="subsubsection">9.15.4.1 Instruction Naming</h5>
|
||
|
|
||
|
<p><a name="index-i386-instruction-naming-1077"></a><a name="index-instruction-naming_002c-i386-1078"></a><a name="index-x86_002d64-instruction-naming-1079"></a><a name="index-instruction-naming_002c-x86_002d64-1080"></a>
|
||
|
Instruction mnemonics are suffixed with one character modifiers which
|
||
|
specify the size of operands. The letters ‘<samp><span class="samp">b</span></samp>’, ‘<samp><span class="samp">w</span></samp>’, ‘<samp><span class="samp">l</span></samp>’
|
||
|
and ‘<samp><span class="samp">q</span></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><span class="samp">mov %ax, %bx</span></samp>’ is equivalent
|
||
|
to ‘<samp><span class="samp">movw %ax, %bx</span></samp>’; also, ‘<samp><span class="samp">mov $1, %bx</span></samp>’ is equivalent to
|
||
|
‘<samp><span class="samp">movw $1, bx</span></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>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><span class="samp">movs...</span></samp>’ and ‘<samp><span class="samp">movz...</span></samp>’ in AT&T syntax (‘<samp><span class="samp">movsx</span></samp>’
|
||
|
and ‘<samp><span class="samp">movzx</span></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><span class="samp">movsbl %al, %edx</span></samp>’ is AT&T syntax for
|
||
|
“move sign extend <em>from</em> %al <em>to</em> %edx.” Possible suffixes,
|
||
|
thus, are ‘<samp><span class="samp">bl</span></samp>’ (from byte to long), ‘<samp><span class="samp">bw</span></samp>’ (from byte to word),
|
||
|
‘<samp><span class="samp">wl</span></samp>’ (from word to long), ‘<samp><span class="samp">bq</span></samp>’ (from byte to quadruple word),
|
||
|
‘<samp><span class="samp">wq</span></samp>’ (from word to quadruple word), and ‘<samp><span class="samp">lq</span></samp>’ (from long to
|
||
|
quadruple word).
|
||
|
|
||
|
<p><a name="index-encoding-options_002c-i386-1081"></a><a name="index-encoding-options_002c-x86_002d64-1082"></a>
|
||
|
Different encoding options can be specified via optional mnemonic
|
||
|
suffix. ‘<samp><span class="samp">.s</span></samp>’ suffix swaps 2 register operands in encoding when
|
||
|
moving from one register to another. ‘<samp><span class="samp">.d8</span></samp>’ or ‘<samp><span class="samp">.d32</span></samp>’ suffix
|
||
|
prefers 8bit or 32bit displacement in encoding.
|
||
|
|
||
|
<p><a name="index-conversion-instructions_002c-i386-1083"></a><a name="index-i386-conversion-instructions-1084"></a><a name="index-conversion-instructions_002c-x86_002d64-1085"></a><a name="index-x86_002d64-conversion-instructions-1086"></a>The Intel-syntax conversion instructions
|
||
|
|
||
|
<ul>
|
||
|
<li>‘<samp><span class="samp">cbw</span></samp>’ — sign-extend byte in ‘<samp><span class="samp">%al</span></samp>’ to word in ‘<samp><span class="samp">%ax</span></samp>’,
|
||
|
|
||
|
<li>‘<samp><span class="samp">cwde</span></samp>’ — sign-extend word in ‘<samp><span class="samp">%ax</span></samp>’ to long in ‘<samp><span class="samp">%eax</span></samp>’,
|
||
|
|
||
|
<li>‘<samp><span class="samp">cwd</span></samp>’ — sign-extend word in ‘<samp><span class="samp">%ax</span></samp>’ to long in ‘<samp><span class="samp">%dx:%ax</span></samp>’,
|
||
|
|
||
|
<li>‘<samp><span class="samp">cdq</span></samp>’ — sign-extend dword in ‘<samp><span class="samp">%eax</span></samp>’ to quad in ‘<samp><span class="samp">%edx:%eax</span></samp>’,
|
||
|
|
||
|
<li>‘<samp><span class="samp">cdqe</span></samp>’ — sign-extend dword in ‘<samp><span class="samp">%eax</span></samp>’ to quad in ‘<samp><span class="samp">%rax</span></samp>’
|
||
|
(x86-64 only),
|
||
|
|
||
|
<li>‘<samp><span class="samp">cqo</span></samp>’ — sign-extend quad in ‘<samp><span class="samp">%rax</span></samp>’ to octuple in
|
||
|
‘<samp><span class="samp">%rdx:%rax</span></samp>’ (x86-64 only),
|
||
|
</ul>
|
||
|
|
||
|
<p class="noindent">are called ‘<samp><span class="samp">cbtw</span></samp>’, ‘<samp><span class="samp">cwtl</span></samp>’, ‘<samp><span class="samp">cwtd</span></samp>’, ‘<samp><span class="samp">cltd</span></samp>’, ‘<samp><span class="samp">cltq</span></samp>’, and
|
||
|
‘<samp><span class="samp">cqto</span></samp>’ in AT&T naming. <code>as</code> accepts either naming for these
|
||
|
instructions.
|
||
|
|
||
|
<p><a name="index-jump-instructions_002c-i386-1087"></a><a name="index-call-instructions_002c-i386-1088"></a><a name="index-jump-instructions_002c-x86_002d64-1089"></a><a name="index-call-instructions_002c-x86_002d64-1090"></a>Far call/jump instructions are ‘<samp><span class="samp">lcall</span></samp>’ and ‘<samp><span class="samp">ljmp</span></samp>’ in
|
||
|
AT&T syntax, but are ‘<samp><span class="samp">call far</span></samp>’ and ‘<samp><span class="samp">jump far</span></samp>’ in Intel
|
||
|
convention.
|
||
|
|
||
|
<h5 class="subsubsection">9.15.4.2 AT&T Mnemonic versus Intel Mnemonic</h5>
|
||
|
|
||
|
<p><a name="index-i386-mnemonic-compatibility-1091"></a><a name="index-mnemonic-compatibility_002c-i386-1092"></a>
|
||
|
<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><span class="samp">fadd</span></samp>’, ‘<samp><span class="samp">fdiv</span></samp>’, ‘<samp><span class="samp">fdivp</span></samp>’,
|
||
|
‘<samp><span class="samp">fdivr</span></samp>’, ‘<samp><span class="samp">fdivrp</span></samp>’, ‘<samp><span class="samp">fmul</span></samp>’, ‘<samp><span class="samp">fsub</span></samp>’, ‘<samp><span class="samp">fsubp</span></samp>’,
|
||
|
‘<samp><span class="samp">fsubr</span></samp>’ and ‘<samp><span class="samp">fsubrp</span></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.
|
||
|
|
||
|
</body></html>
|
||
|
|