You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
12KB

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