X86 Assembly Language - Syntax

Syntax

x86 assembly language has two main syntax branches: Intel syntax, originally used for documentation of the x86 platform, and AT&T syntax. Intel syntax is dominant in the MS-DOS and Windows world, and AT&T syntax is dominant in the Unix world, since Unix was created at AT&T Bell Labs. Here is a summary of the main differences between Intel syntax and AT&T syntax:

AT&T Intel
Parameter order Source before the destination

eax := 5 is mov $5, %eax

Destination before source

eax := 5 is mov eax, 5

Parameter Size Mnemonics are suffixed with a letter indicating the size of the operands (e.g., "q" for qword, "l" for long (dword), "w" for word, and "b" for byte)

addl $4, %esp

Derived from the name of the register that is used (e.g., rax, eax, ax, al imply q,l,w,b in that order)

add esp, 4

Immediate value sigils Prefixed with a "$", and registers must be prefixed with a "%" The assembler automatically detects the type of symbols; i.e., if they are registers, constants or something else.
Effective addresses General syntax DISP(BASE,INDEX,SCALE)

Example:

movl mem_location(%ebx,%ecx,4), %eax

Use variables, and need to be in square brackets; additionally, size keywords like byte, word, or dword have to be used.

Example:

mov eax, dword

Many x86 assemblers use Intel syntax including MASM, TASM, NASM, FASM and YASM. GAS has supported both syntaxes since version 2.10 via the .intel_syntax directive.

Read more about this topic:  X86 Assembly Language