Skip to main content

difference between att and intel (gdb)



AT&T immediate operands use a $ to denote them, whereas Intel immediate operands are undelimited. Thus, when referencing the decimal value 4 in AT&T syntax, you would use dollar 4, and in Intel syntax you would just use 4.
AT&T prefaces register names with a %, while Intel does not. Thus, referencing the EAX register in AT&T syntax, you would use %eax.
AT&T syntax uses the opposite order for source and destination operands. To move the decimal value 4 to the EAX register, AT&T syntax would be movl $4, %eax, whereas for Intel it would be mov eax, 4.
AT&T syntax uses a separate character at the end of mnemonics to reference the data size used in the operation, whereas in Intel syntax the size is declared as a separate operand. The AT&T instruction movl $test, %eax is equivalent to mov eax, dword ptr test in Intel syntax.
Long calls and jumps use a different syntax to define the segment and offset val


original assembly

 BITS 32

%include    'training.s'

global main
extern  exit  

; ===============================================
section .text

main:
    ; The program begins here:

    call    read_hex  
    mov     edx,eax
    call    read_hex  
    add     eax,edx
 
  
    call    print_eax 

    ; Exit the process:
   push 0
    call    exit


gdb assembly att format

(gdb) set disassembly-flavor att
(gdb) disas main
Dump of assembler code for function main:
   0x00001292 <+0>:    call   0x1218 <__x86.get_pc_thunk.dx+83>
   0x00001297 <+5>:    mov    %eax,%edx
   0x00001299 <+7>:    call   0x1218 <__x86.get_pc_thunk.dx+83>
   0x0000129e <+12>:    add    %edx,%eax
   0x000012a0 <+14>:    call   0x11d0 <__x86.get_pc_thunk.dx+11>
   0x000012a5 <+19>:    push   $0x0
   0x000012a7 <+21>:    call   0x12a8 <main+22>
   0x000012ac <+26>:    xchg   %ax,%ax
   0x000012ae <+28>:    xchg   %ax,%ax
End of assembler dump.



gdb assembly intel format


(gdb) set disassembly-flavor intel
(gdb) disas main
Dump of assembler code for function main:
   0x00001292 <+0>:    call   0x1218 <__x86.get_pc_thunk.dx+83>
   0x00001297 <+5>:    mov    edx,eax
   0x00001299 <+7>:    call   0x1218 <__x86.get_pc_thunk.dx+83>
   0x0000129e <+12>:    add    eax,edx
   0x000012a0 <+14>:    call   0x11d0 <__x86.get_pc_thunk.dx+11>
   0x000012a5 <+19>:    push   0x0
   0x000012a7 <+21>:    call   0x12a8 <main+22>
   0x000012ac <+26>:    xchg   ax,ax
   0x000012ae <+28>:    xchg   ax,ax
End of assembler dump.
(gdb)