Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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-Variations (Using as)</title>
  16. <meta name="description" content="i386-Variations (Using as)">
  17. <meta name="keywords" content="i386-Variations (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_002dSyntax.html#i386_002dSyntax" rel="up" title="i386-Syntax">
  25. <link href="i386_002dChars.html#i386_002dChars" rel="next" title="i386-Chars">
  26. <link href="i386_002dSyntax.html#i386_002dSyntax" rel="prev" title="i386-Syntax">
  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_002dVariations"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="i386_002dChars.html#i386_002dChars" accesskey="n" rel="next">i386-Chars</a>, Up: <a href="i386_002dSyntax.html#i386_002dSyntax" accesskey="u" rel="up">i386-Syntax</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="AT_0026T-Syntax-versus-Intel-Syntax"></a>
  63. <h4 class="subsubsection">9.16.3.1 AT&amp;T Syntax versus Intel Syntax</h4>
  64. <a name="index-i386-intel_005fsyntax-pseudo-op"></a>
  65. <a name="index-intel_005fsyntax-pseudo-op_002c-i386"></a>
  66. <a name="index-i386-att_005fsyntax-pseudo-op"></a>
  67. <a name="index-att_005fsyntax-pseudo-op_002c-i386"></a>
  68. <a name="index-i386-syntax-compatibility"></a>
  69. <a name="index-syntax-compatibility_002c-i386"></a>
  70. <a name="index-x86_002d64-intel_005fsyntax-pseudo-op"></a>
  71. <a name="index-intel_005fsyntax-pseudo-op_002c-x86_002d64"></a>
  72. <a name="index-x86_002d64-att_005fsyntax-pseudo-op"></a>
  73. <a name="index-att_005fsyntax-pseudo-op_002c-x86_002d64"></a>
  74. <a name="index-x86_002d64-syntax-compatibility"></a>
  75. <a name="index-syntax-compatibility_002c-x86_002d64"></a>
  76. <p><code>as</code> now supports assembly using Intel assembler syntax.
  77. <code>.intel_syntax</code> selects Intel mode, and <code>.att_syntax</code> switches
  78. back to the usual AT&amp;T mode for compatibility with the output of
  79. <code>gcc</code>. Either of these directives may have an optional
  80. argument, <code>prefix</code>, or <code>noprefix</code> specifying whether registers
  81. require a &lsquo;<samp>%</samp>&rsquo; prefix. AT&amp;T System V/386 assembler syntax is quite
  82. different from Intel syntax. We mention these differences because
  83. almost all 80386 documents use Intel syntax. Notable differences
  84. between the two syntaxes are:
  85. </p>
  86. <a name="index-immediate-operands_002c-i386"></a>
  87. <a name="index-i386-immediate-operands"></a>
  88. <a name="index-register-operands_002c-i386"></a>
  89. <a name="index-i386-register-operands"></a>
  90. <a name="index-jump_002fcall-operands_002c-i386"></a>
  91. <a name="index-i386-jump_002fcall-operands"></a>
  92. <a name="index-operand-delimiters_002c-i386"></a>
  93. <a name="index-immediate-operands_002c-x86_002d64"></a>
  94. <a name="index-x86_002d64-immediate-operands"></a>
  95. <a name="index-register-operands_002c-x86_002d64"></a>
  96. <a name="index-x86_002d64-register-operands"></a>
  97. <a name="index-jump_002fcall-operands_002c-x86_002d64"></a>
  98. <a name="index-x86_002d64-jump_002fcall-operands"></a>
  99. <a name="index-operand-delimiters_002c-x86_002d64"></a>
  100. <ul>
  101. <li> AT&amp;T immediate operands are preceded by &lsquo;<samp>$</samp>&rsquo;; Intel immediate
  102. operands are undelimited (Intel &lsquo;<samp>push 4</samp>&rsquo; is AT&amp;T &lsquo;<samp>pushl $4</samp>&rsquo;).
  103. AT&amp;T register operands are preceded by &lsquo;<samp>%</samp>&rsquo;; Intel register operands
  104. are undelimited. AT&amp;T absolute (as opposed to PC relative) jump/call
  105. operands are prefixed by &lsquo;<samp>*</samp>&rsquo;; they are undelimited in Intel syntax.
  106. </li><li> <a name="index-i386-source_002c-destination-operands"></a>
  107. <a name="index-source_002c-destination-operands_003b-i386"></a>
  108. <a name="index-x86_002d64-source_002c-destination-operands"></a>
  109. <a name="index-source_002c-destination-operands_003b-x86_002d64"></a>
  110. AT&amp;T and Intel syntax use the opposite order for source and destination
  111. operands. Intel &lsquo;<samp>add eax, 4</samp>&rsquo; is &lsquo;<samp>addl $4, %eax</samp>&rsquo;. The
  112. &lsquo;<samp>source, dest</samp>&rsquo; convention is maintained for compatibility with
  113. previous Unix assemblers. Note that &lsquo;<samp>bound</samp>&rsquo;, &lsquo;<samp>invlpga</samp>&rsquo;, and
  114. instructions with 2 immediate operands, such as the &lsquo;<samp>enter</samp>&rsquo;
  115. instruction, do <em>not</em> have reversed order. <a href="i386_002dBugs.html#i386_002dBugs">i386-Bugs</a>.
  116. </li><li> <a name="index-mnemonic-suffixes_002c-i386"></a>
  117. <a name="index-sizes-operands_002c-i386"></a>
  118. <a name="index-i386-size-suffixes"></a>
  119. <a name="index-mnemonic-suffixes_002c-x86_002d64"></a>
  120. <a name="index-sizes-operands_002c-x86_002d64"></a>
  121. <a name="index-x86_002d64-size-suffixes"></a>
  122. In AT&amp;T syntax the size of memory operands is determined from the last
  123. character of the instruction mnemonic. Mnemonic suffixes of &lsquo;<samp>b</samp>&rsquo;,
  124. &lsquo;<samp>w</samp>&rsquo;, &lsquo;<samp>l</samp>&rsquo; and &lsquo;<samp>q</samp>&rsquo; specify byte (8-bit), word (16-bit), long
  125. (32-bit) and quadruple word (64-bit) memory references. Mnemonic suffixes
  126. of &lsquo;<samp>x</samp>&rsquo;, &lsquo;<samp>y</samp>&rsquo; and &lsquo;<samp>z</samp>&rsquo; specify xmm (128-bit vector), ymm
  127. (256-bit vector) and zmm (512-bit vector) memory references, only when there&rsquo;s
  128. no other way to disambiguate an instruction. Intel syntax accomplishes this by
  129. prefixing memory operands (<em>not</em> the instruction mnemonics) with
  130. &lsquo;<samp>byte ptr</samp>&rsquo;, &lsquo;<samp>word ptr</samp>&rsquo;, &lsquo;<samp>dword ptr</samp>&rsquo;, &lsquo;<samp>qword ptr</samp>&rsquo;,
  131. &lsquo;<samp>xmmword ptr</samp>&rsquo;, &lsquo;<samp>ymmword ptr</samp>&rsquo; and &lsquo;<samp>zmmword ptr</samp>&rsquo;. Thus, Intel
  132. syntax &lsquo;<samp>mov al, byte ptr <var>foo</var></samp>&rsquo; is &lsquo;<samp>movb <var>foo</var>, %al</samp>&rsquo; in AT&amp;T
  133. syntax. In Intel syntax, &lsquo;<samp>fword ptr</samp>&rsquo;, &lsquo;<samp>tbyte ptr</samp>&rsquo; and
  134. &lsquo;<samp>oword ptr</samp>&rsquo; specify 48-bit, 80-bit and 128-bit memory references.
  135. <p>In 64-bit code, &lsquo;<samp>movabs</samp>&rsquo; can be used to encode the &lsquo;<samp>mov</samp>&rsquo;
  136. instruction with the 64-bit displacement or immediate operand.
  137. </p>
  138. </li><li> <a name="index-return-instructions_002c-i386"></a>
  139. <a name="index-i386-jump_002c-call_002c-return"></a>
  140. <a name="index-return-instructions_002c-x86_002d64"></a>
  141. <a name="index-x86_002d64-jump_002c-call_002c-return"></a>
  142. Immediate form long jumps and calls are
  143. &lsquo;<samp>lcall/ljmp $<var>section</var>, $<var>offset</var></samp>&rsquo; in AT&amp;T syntax; the
  144. Intel syntax is
  145. &lsquo;<samp>call/jmp far <var>section</var>:<var>offset</var></samp>&rsquo;. Also, the far return
  146. instruction
  147. is &lsquo;<samp>lret $<var>stack-adjust</var></samp>&rsquo; in AT&amp;T syntax; Intel syntax is
  148. &lsquo;<samp>ret far <var>stack-adjust</var></samp>&rsquo;.
  149. </li><li> <a name="index-sections_002c-i386"></a>
  150. <a name="index-i386-sections"></a>
  151. <a name="index-sections_002c-x86_002d64"></a>
  152. <a name="index-x86_002d64-sections"></a>
  153. The AT&amp;T assembler does not provide support for multiple section
  154. programs. Unix style systems expect all programs to be single sections.
  155. </li></ul>
  156. <hr>
  157. <div class="header">
  158. <p>
  159. Next: <a href="i386_002dChars.html#i386_002dChars" accesskey="n" rel="next">i386-Chars</a>, Up: <a href="i386_002dSyntax.html#i386_002dSyntax" accesskey="u" rel="up">i386-Syntax</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>
  160. </div>
  161. </body>
  162. </html>