📄 i386-syntax.html
字号:
<html lang="en">
<head>
<title>Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
</head>
<body>
<div class="node">
<p>
Node:<a name="i386-Syntax">i386-Syntax</a>,
Next:<a rel="next" accesskey="n" href="i386-Mnemonics.html#i386-Mnemonics">i386-Mnemonics</a>,
Previous:<a rel="previous" accesskey="p" href="i386-Options.html#i386-Options">i386-Options</a>,
Up:<a rel="up" accesskey="u" href="i386-Dependent.html#i386-Dependent">i386-Dependent</a>
<hr><br>
</div>
<h4 class="section">AT&T Syntax versus Intel Syntax</h4>
<p><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 <code>%</code> 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:
<ul>
<li>AT&T immediate operands are preceded by <code>$</code>; Intel immediate
operands are undelimited (Intel <code>push 4</code> is AT&T <code>pushl $4</code>).
AT&T register operands are preceded by <code>%</code>; Intel register operands
are undelimited. AT&T absolute (as opposed to PC relative) jump/call
operands are prefixed by <code>*</code>; they are undelimited in Intel syntax.
<li>AT&T and Intel syntax use the opposite order for source and destination
operands. Intel <code>add eax, 4</code> is <code>addl $4, %eax</code>. The
<code>source, dest</code> convention is maintained for compatibility with
previous Unix assemblers. Note that instructions with more than one
source operand, such as the <code>enter</code> instruction, do <em>not</em> have
reversed order. <a href="i386-Bugs.html#i386-Bugs">i386-Bugs</a>.
<li>In AT&T syntax the size of memory operands is determined from the last
character of the instruction mnemonic. Mnemonic suffixes of <code>b</code>,
<code>w</code>, <code>l</code> and <code>q</code> 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
<code>byte ptr</code>, <code>word ptr</code>, <code>dword ptr</code> and <code>qword ptr</code>. Thus,
Intel <code>mov al, byte ptr </code><var>foo</var><code></code> is <code>movb </code><var>foo</var><code>, %al</code> in AT&T
syntax.
<li>Immediate form long jumps and calls are
<code>lcall/ljmp $</code><var>section</var><code>, $</code><var>offset</var><code></code> in AT&T syntax; the
Intel syntax is
<code>call/jmp far </code><var>section</var><code>:</code><var>offset</var><code></code>. Also, the far return
instruction
is <code>lret $</code><var>stack-adjust</var><code></code> in AT&T syntax; Intel syntax is
<code>ret far </code><var>stack-adjust</var><code></code>.
<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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -