| <html lang="en"> |
| <head> |
| <title>i386-Variations - 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_002dSyntax.html#i386_002dSyntax" title="i386-Syntax"> |
| <link rel="next" href="i386_002dChars.html#i386_002dChars" title="i386-Chars"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU Assembler "as". |
| |
| Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
| 2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010, 2011 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-Variations"></a> |
| <a name="i386_002dVariations"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="i386_002dChars.html#i386_002dChars">i386-Chars</a>, |
| Up: <a rel="up" accesskey="u" href="i386_002dSyntax.html#i386_002dSyntax">i386-Syntax</a> |
| <hr> |
| </div> |
| |
| <h5 class="subsubsection">9.15.3.1 AT&T Syntax versus Intel Syntax</h5> |
| |
| <p><a name="index-i386-intel_005fsyntax-pseudo-op-933"></a><a name="index-intel_005fsyntax-pseudo-op_002c-i386-934"></a><a name="index-i386-att_005fsyntax-pseudo-op-935"></a><a name="index-att_005fsyntax-pseudo-op_002c-i386-936"></a><a name="index-i386-syntax-compatibility-937"></a><a name="index-syntax-compatibility_002c-i386-938"></a><a name="index-x86_002d64-intel_005fsyntax-pseudo-op-939"></a><a name="index-intel_005fsyntax-pseudo-op_002c-x86_002d64-940"></a><a name="index-x86_002d64-att_005fsyntax-pseudo-op-941"></a><a name="index-att_005fsyntax-pseudo-op_002c-x86_002d64-942"></a><a name="index-x86_002d64-syntax-compatibility-943"></a><a name="index-syntax-compatibility_002c-x86_002d64-944"></a> |
| <code>as</code> now supports assembly using Intel assembler syntax. |
| <code>.intel_syntax</code> selects Intel mode, and <code>.att_syntax</code> switches |
| back to the usual AT&T mode for compatibility with the output of |
| <code>gcc</code>. Either of these directives may have an optional |
| argument, <code>prefix</code>, or <code>noprefix</code> specifying whether registers |
| require a ‘<samp><span class="samp">%</span></samp>’ prefix. AT&T System V/386 assembler syntax is quite |
| different from Intel syntax. We mention these differences because |
| almost all 80386 documents use Intel syntax. Notable differences |
| between the two syntaxes are: |
| |
| <p><a name="index-immediate-operands_002c-i386-945"></a><a name="index-i386-immediate-operands-946"></a><a name="index-register-operands_002c-i386-947"></a><a name="index-i386-register-operands-948"></a><a name="index-jump_002fcall-operands_002c-i386-949"></a><a name="index-i386-jump_002fcall-operands-950"></a><a name="index-operand-delimiters_002c-i386-951"></a> |
| <a name="index-immediate-operands_002c-x86_002d64-952"></a><a name="index-x86_002d64-immediate-operands-953"></a><a name="index-register-operands_002c-x86_002d64-954"></a><a name="index-x86_002d64-register-operands-955"></a><a name="index-jump_002fcall-operands_002c-x86_002d64-956"></a><a name="index-x86_002d64-jump_002fcall-operands-957"></a><a name="index-operand-delimiters_002c-x86_002d64-958"></a> |
| <ul> |
| <li>AT&T immediate operands are preceded by ‘<samp><span class="samp">$</span></samp>’; Intel immediate |
| operands are undelimited (Intel ‘<samp><span class="samp">push 4</span></samp>’ is AT&T ‘<samp><span class="samp">pushl $4</span></samp>’). |
| AT&T register operands are preceded by ‘<samp><span class="samp">%</span></samp>’; Intel register operands |
| are undelimited. AT&T absolute (as opposed to PC relative) jump/call |
| operands are prefixed by ‘<samp><span class="samp">*</span></samp>’; they are undelimited in Intel syntax. |
| |
| <p><a name="index-i386-source_002c-destination-operands-959"></a><a name="index-source_002c-destination-operands_003b-i386-960"></a><a name="index-x86_002d64-source_002c-destination-operands-961"></a><a name="index-source_002c-destination-operands_003b-x86_002d64-962"></a><li>AT&T and Intel syntax use the opposite order for source and destination |
| operands. Intel ‘<samp><span class="samp">add eax, 4</span></samp>’ is ‘<samp><span class="samp">addl $4, %eax</span></samp>’. The |
| ‘<samp><span class="samp">source, dest</span></samp>’ convention is maintained for compatibility with |
| previous Unix assemblers. Note that ‘<samp><span class="samp">bound</span></samp>’, ‘<samp><span class="samp">invlpga</span></samp>’, and |
| instructions with 2 immediate operands, such as the ‘<samp><span class="samp">enter</span></samp>’ |
| instruction, do <em>not</em> have reversed order. <a href="i386_002dBugs.html#i386_002dBugs">i386-Bugs</a>. |
| |
| <p><a name="index-mnemonic-suffixes_002c-i386-963"></a><a name="index-sizes-operands_002c-i386-964"></a><a name="index-i386-size-suffixes-965"></a><a name="index-mnemonic-suffixes_002c-x86_002d64-966"></a><a name="index-sizes-operands_002c-x86_002d64-967"></a><a name="index-x86_002d64-size-suffixes-968"></a><li>In AT&T syntax the size of memory operands is determined from the last |
| character of the instruction mnemonic. Mnemonic suffixes of ‘<samp><span class="samp">b</span></samp>’, |
| ‘<samp><span class="samp">w</span></samp>’, ‘<samp><span class="samp">l</span></samp>’ and ‘<samp><span class="samp">q</span></samp>’ specify byte (8-bit), word (16-bit), long |
| (32-bit) and quadruple word (64-bit) memory references. Intel syntax accomplishes |
| this by prefixing memory operands (<em>not</em> the instruction mnemonics) with |
| ‘<samp><span class="samp">byte ptr</span></samp>’, ‘<samp><span class="samp">word ptr</span></samp>’, ‘<samp><span class="samp">dword ptr</span></samp>’ and ‘<samp><span class="samp">qword ptr</span></samp>’. Thus, |
| Intel ‘<samp><span class="samp">mov al, byte ptr </span><var>foo</var></samp>’ is ‘<samp><span class="samp">movb </span><var>foo</var><span class="samp">, %al</span></samp>’ in AT&T |
| syntax. |
| |
| <p>In 64-bit code, ‘<samp><span class="samp">movabs</span></samp>’ can be used to encode the ‘<samp><span class="samp">mov</span></samp>’ |
| instruction with the 64-bit displacement or immediate operand. |
| |
| <p><a name="index-return-instructions_002c-i386-969"></a><a name="index-i386-jump_002c-call_002c-return-970"></a><a name="index-return-instructions_002c-x86_002d64-971"></a><a name="index-x86_002d64-jump_002c-call_002c-return-972"></a><li>Immediate form long jumps and calls are |
| ‘<samp><span class="samp">lcall/ljmp $</span><var>section</var><span class="samp">, $</span><var>offset</var></samp>’ in AT&T syntax; the |
| Intel syntax is |
| ‘<samp><span class="samp">call/jmp far </span><var>section</var><span class="samp">:</span><var>offset</var></samp>’. Also, the far return |
| instruction |
| is ‘<samp><span class="samp">lret $</span><var>stack-adjust</var></samp>’ in AT&T syntax; Intel syntax is |
| ‘<samp><span class="samp">ret far </span><var>stack-adjust</var></samp>’. |
| |
| <p><a name="index-sections_002c-i386-973"></a><a name="index-i386-sections-974"></a><a name="index-sections_002c-x86_002d64-975"></a><a name="index-x86_002d64-sections-976"></a><li>The AT&T assembler does not provide support for multiple section |
| programs. Unix style systems expect all programs to be single sections. |
| </ul> |
| |
| </body></html> |
| |