Next: A Simple Example of Inline Assembler, Up: Inline Assembler [Contents][Index]
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 exampleeax
`Immediate operand'
gcc /as
: Prefix with ’$’; for example$4
Intel: No extra punctuation; for example4
`Address'
gcc /as
: Prefix with ’$’; for example$loc
Intel: No extra punctuation; for exampleloc
`Memory contents'
gcc /as
: No extra punctuation; for exampleloc
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 example0xA0
Intel: Trailing ’h’; for exampleA0h
`Operand size'
gcc /as
: Explicit in op code; for examplemovw
to move a 16-bit word Intel: Implicit, deduced by assembler; for examplemov
`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 examplemovw $4, %eax
Intel: Destination first; for examplemov eax, 4
Next: A Simple Example of Inline Assembler, Up: Inline Assembler [Contents][Index]