Differences in Intel (NASM) vs AT&T (GAS) Syntax.

Register & Immediate Prefixes

   Intel Syntax
   mov     eax,1
   mov     ebx,0ffh
   int     80h

   AT&T Syntax
   movl    $1,%eax
   movl    $0xff,%ebx
   int     $0x80

Direction of Operands.

 Intel Syntax
 instr   dest,source
 mov     eax,[ecx]

 AT&T Syntax
 instr   source,dest
 movl    (%ecx),%eax

Memory Operands.

Intex Syntax
mov     eax,[ebx]
mov     eax,[ebx+3]

AT&T Syntax
movl    (%ebx),%eax
movl    3(%ebx),%eax

Complex instructions

Intel Syntax
instr   foo,segreg:[base+index*scale+disp]
mov     eax,[ebx+20h]
add     eax,[ebx+ecx*2h
lea     eax,[ebx+ecx]
sub     eax,[ebx+ecx*4h-20h]

AT&T Syntax
instr   %segreg:disp(base,index,scale),foo
movl    0x20(%ebx),%eax
addl    (%ebx,%ecx,0x2),%eax
leal    (%ebx,%ecx),%eax
subl    -0x20(%ebx,%ecx,0x4),%eax

Mnemonic Suffixes

Style 8 bits 16 bit 32 bits 64 bits
ATT(GAS) 'b' 'w' 'l' 'q'
Intel(NASM) byte ptr word ptr dword ptr qword ptr
 Intel Syntax
 mov     al,bl
 mov     ax,bx
 mov     eax,ebx
 mov     eax, dword ptr [ebx]

 AT&T Syntax
 movb    %bl,%al
 movw    %bx,%ax
 movl    %ebx,%eax
 movl    (%ebx),%eax

Data Size Declarations

Style 8 bits 16 bit 32 bits 64 bits Example
ATT(GAS) 'db' 'dw' 'dd' 'dq' var1 dd 40
Intel(NASM) .byte .int .long var1: .int 40

Comment

; in Intel and # or C style in Att.

Examples

NASM

; Text segment begins
section .text

   global _start

; Program entry point
   _start:

; Put the code number for system call
      mov   eax, 1

; Return value
      mov   ebx, 2

; Call the OS
      int   80h

GAS

# Text segment begins
.section .text

   .globl _start

# Program entry point
   _start:

# Put the code number for system call
      movl  $1, %eax

/* Return value */
      movl  $2, %ebx

# Call the OS
      int   $0x80

References