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.

i386_002dPrefixes.html 7.3KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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-Prefixes (Using as)</title>
  16. <meta name="description" content="i386-Prefixes (Using as)">
  17. <meta name="keywords" content="i386-Prefixes (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_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.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_002dPrefixes"></a>
  57. <div class="header">
  58. <p>
  59. 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>
  60. </div>
  61. <hr>
  62. <a name="Instruction-Prefixes"></a>
  63. <h4 class="subsection">9.16.6 Instruction Prefixes</h4>
  64. <a name="index-i386-instruction-prefixes"></a>
  65. <a name="index-instruction-prefixes_002c-i386"></a>
  66. <a name="index-prefixes_002c-i386"></a>
  67. <p>Instruction prefixes are used to modify the following instruction. They
  68. are used to repeat string instructions, to provide section overrides, to
  69. perform bus lock operations, and to change operand and address sizes.
  70. (Most instructions that normally operate on 32-bit operands will use
  71. 16-bit operands if the instruction has an &ldquo;operand size&rdquo; prefix.)
  72. Instruction prefixes are best written on the same line as the instruction
  73. they act upon. For example, the &lsquo;<samp>scas</samp>&rsquo; (scan string) instruction is
  74. repeated with:
  75. </p>
  76. <div class="smallexample">
  77. <pre class="smallexample"> repne scas %es:(%edi),%al
  78. </pre></div>
  79. <p>You may also place prefixes on the lines immediately preceding the
  80. instruction, but this circumvents checks that <code>as</code> does
  81. with prefixes, and will not work with all prefixes.
  82. </p>
  83. <p>Here is a list of instruction prefixes:
  84. </p>
  85. <a name="index-section-override-prefixes_002c-i386"></a>
  86. <ul>
  87. <li> Section override prefixes &lsquo;<samp>cs</samp>&rsquo;, &lsquo;<samp>ds</samp>&rsquo;, &lsquo;<samp>ss</samp>&rsquo;, &lsquo;<samp>es</samp>&rsquo;,
  88. &lsquo;<samp>fs</samp>&rsquo;, &lsquo;<samp>gs</samp>&rsquo;. These are automatically added by specifying
  89. using the <var>section</var>:<var>memory-operand</var> form for memory references.
  90. </li><li> <a name="index-size-prefixes_002c-i386"></a>
  91. Operand/Address size prefixes &lsquo;<samp>data16</samp>&rsquo; and &lsquo;<samp>addr16</samp>&rsquo;
  92. change 32-bit operands/addresses into 16-bit operands/addresses,
  93. while &lsquo;<samp>data32</samp>&rsquo; and &lsquo;<samp>addr32</samp>&rsquo; change 16-bit ones (in a
  94. <code>.code16</code> section) into 32-bit operands/addresses. These prefixes
  95. <em>must</em> appear on the same line of code as the instruction they
  96. modify. For example, in a 16-bit <code>.code16</code> section, you might
  97. write:
  98. <div class="smallexample">
  99. <pre class="smallexample"> addr32 jmpl *(%ebx)
  100. </pre></div>
  101. </li><li> <a name="index-bus-lock-prefixes_002c-i386"></a>
  102. <a name="index-inhibiting-interrupts_002c-i386"></a>
  103. The bus lock prefix &lsquo;<samp>lock</samp>&rsquo; inhibits interrupts during execution of
  104. the instruction it precedes. (This is only valid with certain
  105. instructions; see a 80386 manual for details).
  106. </li><li> <a name="index-coprocessor-wait_002c-i386"></a>
  107. The wait for coprocessor prefix &lsquo;<samp>wait</samp>&rsquo; waits for the coprocessor to
  108. complete the current instruction. This should never be needed for the
  109. 80386/80387 combination.
  110. </li><li> <a name="index-repeat-prefixes_002c-i386"></a>
  111. The &lsquo;<samp>rep</samp>&rsquo;, &lsquo;<samp>repe</samp>&rsquo;, and &lsquo;<samp>repne</samp>&rsquo; prefixes are added
  112. to string instructions to make them repeat &lsquo;<samp>%ecx</samp>&rsquo; times (&lsquo;<samp>%cx</samp>&rsquo;
  113. times if the current address size is 16-bits).
  114. </li><li> <a name="index-REX-prefixes_002c-i386"></a>
  115. The &lsquo;<samp>rex</samp>&rsquo; family of prefixes is used by x86-64 to encode
  116. extensions to i386 instruction set. The &lsquo;<samp>rex</samp>&rsquo; prefix has four
  117. bits &mdash; an operand size overwrite (<code>64</code>) used to change operand size
  118. from 32-bit to 64-bit and X, Y and Z extensions bits used to extend the
  119. register set.
  120. <p>You may write the &lsquo;<samp>rex</samp>&rsquo; prefixes directly. The &lsquo;<samp>rex64xyz</samp>&rsquo;
  121. instruction emits &lsquo;<samp>rex</samp>&rsquo; prefix with all the bits set. By omitting
  122. the <code>64</code>, <code>x</code>, <code>y</code> or <code>z</code> you may write other
  123. prefixes as well. Normally, there is no need to write the prefixes
  124. explicitly, since gas will automatically generate them based on the
  125. instruction operands.
  126. </p></li></ul>
  127. <hr>
  128. <div class="header">
  129. <p>
  130. 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>
  131. </div>
  132. </body>
  133. </html>