<html lang="en"> <head> <title>i386-Prefixes - 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_002dRegs.html#i386_002dRegs" title="i386-Regs"> <link rel="next" href="i386_002dMemory.html#i386_002dMemory" title="i386-Memory"> <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-Prefixes"></a> <a name="i386_002dPrefixes"></a> <p> Next: <a rel="next" accesskey="n" href="i386_002dMemory.html#i386_002dMemory">i386-Memory</a>, Previous: <a rel="previous" accesskey="p" href="i386_002dRegs.html#i386_002dRegs">i386-Regs</a>, Up: <a rel="up" accesskey="u" href="i386_002dDependent.html#i386_002dDependent">i386-Dependent</a> <hr> </div> <h4 class="subsection">9.15.6 Instruction Prefixes</h4> <p><a name="index-i386-instruction-prefixes-1097"></a><a name="index-instruction-prefixes_002c-i386-1098"></a><a name="index-prefixes_002c-i386-1099"></a>Instruction prefixes are used to modify the following instruction. They are used to repeat string instructions, to provide section overrides, to perform bus lock operations, and to change operand and address sizes. (Most instructions that normally operate on 32-bit operands will use 16-bit operands if the instruction has an “operand size” prefix.) Instruction prefixes are best written on the same line as the instruction they act upon. For example, the ‘<samp><span class="samp">scas</span></samp>’ (scan string) instruction is repeated with: <pre class="smallexample"> repne scas %es:(%edi),%al </pre> <p>You may also place prefixes on the lines immediately preceding the instruction, but this circumvents checks that <code>as</code> does with prefixes, and will not work with all prefixes. <p>Here is a list of instruction prefixes: <p><a name="index-section-override-prefixes_002c-i386-1100"></a> <ul> <li>Section override prefixes ‘<samp><span class="samp">cs</span></samp>’, ‘<samp><span class="samp">ds</span></samp>’, ‘<samp><span class="samp">ss</span></samp>’, ‘<samp><span class="samp">es</span></samp>’, ‘<samp><span class="samp">fs</span></samp>’, ‘<samp><span class="samp">gs</span></samp>’. These are automatically added by specifying using the <var>section</var>:<var>memory-operand</var> form for memory references. <p><a name="index-size-prefixes_002c-i386-1101"></a><li>Operand/Address size prefixes ‘<samp><span class="samp">data16</span></samp>’ and ‘<samp><span class="samp">addr16</span></samp>’ change 32-bit operands/addresses into 16-bit operands/addresses, while ‘<samp><span class="samp">data32</span></samp>’ and ‘<samp><span class="samp">addr32</span></samp>’ change 16-bit ones (in a <code>.code16</code> section) into 32-bit operands/addresses. These prefixes <em>must</em> appear on the same line of code as the instruction they modify. For example, in a 16-bit <code>.code16</code> section, you might write: <pre class="smallexample"> addr32 jmpl *(%ebx) </pre> <p><a name="index-bus-lock-prefixes_002c-i386-1102"></a><a name="index-inhibiting-interrupts_002c-i386-1103"></a><li>The bus lock prefix ‘<samp><span class="samp">lock</span></samp>’ inhibits interrupts during execution of the instruction it precedes. (This is only valid with certain instructions; see a 80386 manual for details). <p><a name="index-coprocessor-wait_002c-i386-1104"></a><li>The wait for coprocessor prefix ‘<samp><span class="samp">wait</span></samp>’ waits for the coprocessor to complete the current instruction. This should never be needed for the 80386/80387 combination. <p><a name="index-repeat-prefixes_002c-i386-1105"></a><li>The ‘<samp><span class="samp">rep</span></samp>’, ‘<samp><span class="samp">repe</span></samp>’, and ‘<samp><span class="samp">repne</span></samp>’ prefixes are added to string instructions to make them repeat ‘<samp><span class="samp">%ecx</span></samp>’ times (‘<samp><span class="samp">%cx</span></samp>’ times if the current address size is 16-bits). <a name="index-REX-prefixes_002c-i386-1106"></a><li>The ‘<samp><span class="samp">rex</span></samp>’ family of prefixes is used by x86-64 to encode extensions to i386 instruction set. The ‘<samp><span class="samp">rex</span></samp>’ prefix has four bits — an operand size overwrite (<code>64</code>) used to change operand size from 32-bit to 64-bit and X, Y and Z extensions bits used to extend the register set. <p>You may write the ‘<samp><span class="samp">rex</span></samp>’ prefixes directly. The ‘<samp><span class="samp">rex64xyz</span></samp>’ instruction emits ‘<samp><span class="samp">rex</span></samp>’ prefix with all the bits set. By omitting the <code>64</code>, <code>x</code>, <code>y</code> or <code>z</code> you may write other prefixes as well. Normally, there is no need to write the prefixes explicitly, since gas will automatically generate them based on the instruction operands. </ul> </body></html>