Basic Assembler Syntax (GNAT User’s Guide for Native Platforms)

### 10.1 Basic Assembler Syntax ¶

The assembler used by GNAT and gcc is based not on the Intel assembly language, but rather on a language that descends from the AT&T Unix assembler `as` (and which is often referred to as ‘AT&T syntax’). The following table summarizes the main features of `as` syntax and points out the differences from the Intel conventions. See the gcc `as` and `gas` (an `as` macro pre-processor) documentation for further information.

    ‘Register names’

    gcc / as: Prefix with ‘%’; for example %eax
    Intel: No extra punctuation; for example eax

    ‘Immediate operand’

    gcc / as: Prefix with ‘$’; for example $4
    Intel: No extra punctuation; for example 4

    ‘Address’

    gcc / as: Prefix with ‘$’; for example $loc
    Intel: No extra punctuation; for example loc

    ‘Memory contents’

    gcc / as: No extra punctuation; for example loc
    Intel: Square brackets; for example [loc]

    ‘Register contents’

    gcc / as: Parentheses; for example (%eax)
    Intel: Square brackets; for example [eax]

    ‘Hexadecimal numbers’

    gcc / as: Leading ‘0x’ (C language syntax); for example 0xA0
    Intel: Trailing ‘h’; for example A0h

    ‘Operand size’

    gcc / as: Explicit in op code; for example movw to move a 16-bit word
    Intel: Implicit, deduced by assembler; for example mov

    ‘Instruction repetition’

    gcc / as: Split into two lines; for example

    rep
    stosl

    Intel: Keep on one line; for example rep stosl

    ‘Order of operands’

    gcc / as: Source first; for example movw $4, %eax
    Intel: Destination first; for example mov eax, 4