Home

Assembler Syntax


There are two distinct forms of syntax used for x86 programming.

Intel syntax

This is the syntax that you are probably most familiar with. It is used by, amongst others, nasm and fasm. A typical line of code looks like

mov eax, 1234

This moves the value 1234 into register eax. Note that the destination is on the left of the comma and the source on the right.

AT&T syntax

The same line in AT&T syntax would read

mov $1234, %eax

The most obvious difference is that the source is now on the left of the comma and the destination on the right. To me this seems more natural as I read it as "move 1234 into register eax".

I use the AT&T syntax. The main reason for this is that it is the "natural" syntax for the gcc toolset. (If you look at the assembler code produced by gcc you will see that it is in AT&T syntax.) This makes life easier, for me at any rate, when mixing C and assembler.

If you Google "assembler syntax" you'll find several pages explaining the AT&T syntax, including this one.