as: i386-Variations
1
1 9.15.3.1 AT&T Syntax versus Intel Syntax
1 ........................................
1
1 'as' now supports assembly using Intel assembler syntax.
1 '.intel_syntax' selects Intel mode, and '.att_syntax' switches back to
1 the usual AT&T mode for compatibility with the output of 'gcc'. Either
1 of these directives may have an optional argument, 'prefix', or
1 'noprefix' specifying whether registers require a '%' prefix. AT&T
1 System V/386 assembler syntax is quite different from Intel syntax. We
1 mention these differences because almost all 80386 documents use Intel
1 syntax. Notable differences between the two syntaxes are:
1
1 * AT&T immediate operands are preceded by '$'; Intel immediate
1 operands are undelimited (Intel 'push 4' is AT&T 'pushl $4'). AT&T
1 register operands are preceded by '%'; Intel register operands are
1 undelimited. AT&T absolute (as opposed to PC relative) jump/call
1 operands are prefixed by '*'; they are undelimited in Intel syntax.
1
1 * AT&T and Intel syntax use the opposite order for source and
1 destination operands. Intel 'add eax, 4' is 'addl $4, %eax'. The
1 'source, dest' convention is maintained for compatibility with
1 previous Unix assemblers. Note that 'bound', 'invlpga', and
1 instructions with 2 immediate operands, such as the 'enter'
1 instruction, do _not_ have reversed order. ⇒i386-Bugs.
1
1 * In AT&T syntax the size of memory operands is determined from the
1 last character of the instruction mnemonic. Mnemonic suffixes of
1 'b', 'w', 'l' and 'q' specify byte (8-bit), word (16-bit), long
1 (32-bit) and quadruple word (64-bit) memory references. Intel
1 syntax accomplishes this by prefixing memory operands (_not_ the
1 instruction mnemonics) with 'byte ptr', 'word ptr', 'dword ptr' and
1 'qword ptr'. Thus, Intel 'mov al, byte ptr FOO' is 'movb FOO, %al'
1 in AT&T syntax.
1
1 In 64-bit code, 'movabs' can be used to encode the 'mov'
1 instruction with the 64-bit displacement or immediate operand.
1
1 * Immediate form long jumps and calls are 'lcall/ljmp $SECTION,
1 $OFFSET' in AT&T syntax; the Intel syntax is 'call/jmp far
1 SECTION:OFFSET'. Also, the far return instruction is 'lret
1 $STACK-ADJUST' in AT&T syntax; Intel syntax is 'ret far
1 STACK-ADJUST'.
1
1 * The AT&T assembler does not provide support for multiple section
1 programs. Unix style systems expect all programs to be single
1 sections.
1