i386_002dPrefixes.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: i386-Prefixes</title>
  15. <meta name="description" content="Using as: i386-Prefixes">
  16. <meta name="keywords" content="Using as: i386-Prefixes">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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_002dMemory.html#i386_002dMemory" rel="next" title="i386-Memory">
  26. <link href="i386_002dRegs.html#i386_002dRegs" rel="prev" title="i386-Regs">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="i386_002dPrefixes"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="i386_002dMemory.html#i386_002dMemory" accesskey="n" rel="next">i386-Memory</a>, Previous: <a href="i386_002dRegs.html#i386_002dRegs" accesskey="p" rel="prev">i386-Regs</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>
  61. </div>
  62. <hr>
  63. <a name="Instruction-Prefixes"></a>
  64. <h4 class="subsection">9.15.6 Instruction Prefixes</h4>
  65. <a name="index-i386-instruction-prefixes"></a>
  66. <a name="index-instruction-prefixes_002c-i386"></a>
  67. <a name="index-prefixes_002c-i386"></a>
  68. <p>Instruction prefixes are used to modify the following instruction. They
  69. are used to repeat string instructions, to provide section overrides, to
  70. perform bus lock operations, and to change operand and address sizes.
  71. (Most instructions that normally operate on 32-bit operands will use
  72. 16-bit operands if the instruction has an &ldquo;operand size&rdquo; prefix.)
  73. Instruction prefixes are best written on the same line as the instruction
  74. they act upon. For example, the &lsquo;<samp>scas</samp>&rsquo; (scan string) instruction is
  75. repeated with:
  76. </p>
  77. <div class="smallexample">
  78. <pre class="smallexample"> repne scas %es:(%edi),%al
  79. </pre></div>
  80. <p>You may also place prefixes on the lines immediately preceding the
  81. instruction, but this circumvents checks that <code>as</code> does
  82. with prefixes, and will not work with all prefixes.
  83. </p>
  84. <p>Here is a list of instruction prefixes:
  85. </p>
  86. <a name="index-section-override-prefixes_002c-i386"></a>
  87. <ul>
  88. <li> Section override prefixes &lsquo;<samp>cs</samp>&rsquo;, &lsquo;<samp>ds</samp>&rsquo;, &lsquo;<samp>ss</samp>&rsquo;, &lsquo;<samp>es</samp>&rsquo;,
  89. &lsquo;<samp>fs</samp>&rsquo;, &lsquo;<samp>gs</samp>&rsquo;. These are automatically added by specifying
  90. using the <var>section</var>:<var>memory-operand</var> form for memory references.
  91. </li><li> <a name="index-size-prefixes_002c-i386"></a>
  92. Operand/Address size prefixes &lsquo;<samp>data16</samp>&rsquo; and &lsquo;<samp>addr16</samp>&rsquo;
  93. change 32-bit operands/addresses into 16-bit operands/addresses,
  94. while &lsquo;<samp>data32</samp>&rsquo; and &lsquo;<samp>addr32</samp>&rsquo; change 16-bit ones (in a
  95. <code>.code16</code> section) into 32-bit operands/addresses. These prefixes
  96. <em>must</em> appear on the same line of code as the instruction they
  97. modify. For example, in a 16-bit <code>.code16</code> section, you might
  98. write:
  99. <div class="smallexample">
  100. <pre class="smallexample"> addr32 jmpl *(%ebx)
  101. </pre></div>
  102. </li><li> <a name="index-bus-lock-prefixes_002c-i386"></a>
  103. <a name="index-inhibiting-interrupts_002c-i386"></a>
  104. The bus lock prefix &lsquo;<samp>lock</samp>&rsquo; inhibits interrupts during execution of
  105. the instruction it precedes. (This is only valid with certain
  106. instructions; see a 80386 manual for details).
  107. </li><li> <a name="index-coprocessor-wait_002c-i386"></a>
  108. The wait for coprocessor prefix &lsquo;<samp>wait</samp>&rsquo; waits for the coprocessor to
  109. complete the current instruction. This should never be needed for the
  110. 80386/80387 combination.
  111. </li><li> <a name="index-repeat-prefixes_002c-i386"></a>
  112. The &lsquo;<samp>rep</samp>&rsquo;, &lsquo;<samp>repe</samp>&rsquo;, and &lsquo;<samp>repne</samp>&rsquo; prefixes are added
  113. to string instructions to make them repeat &lsquo;<samp>%ecx</samp>&rsquo; times (&lsquo;<samp>%cx</samp>&rsquo;
  114. times if the current address size is 16-bits).
  115. </li><li> <a name="index-REX-prefixes_002c-i386"></a>
  116. The &lsquo;<samp>rex</samp>&rsquo; family of prefixes is used by x86-64 to encode
  117. extensions to i386 instruction set. The &lsquo;<samp>rex</samp>&rsquo; prefix has four
  118. bits &mdash; an operand size overwrite (<code>64</code>) used to change operand size
  119. from 32-bit to 64-bit and X, Y and Z extensions bits used to extend the
  120. register set.
  121. <p>You may write the &lsquo;<samp>rex</samp>&rsquo; prefixes directly. The &lsquo;<samp>rex64xyz</samp>&rsquo;
  122. instruction emits &lsquo;<samp>rex</samp>&rsquo; prefix with all the bits set. By omitting
  123. the <code>64</code>, <code>x</code>, <code>y</code> or <code>z</code> you may write other
  124. prefixes as well. Normally, there is no need to write the prefixes
  125. explicitly, since gas will automatically generate them based on the
  126. instruction operands.
  127. </p></li></ul>
  128. <hr>
  129. <div class="header">
  130. <p>
  131. Next: <a href="i386_002dMemory.html#i386_002dMemory" accesskey="n" rel="next">i386-Memory</a>, Previous: <a href="i386_002dRegs.html#i386_002dRegs" accesskey="p" rel="prev">i386-Regs</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>
  132. </div>
  133. </body>
  134. </html>