asm AT&T vs intel

Author: Gemini
2026-04-14

The primary difference between AT&T and Intel assembly syntax is the operand order. Intel syntax (destination first) is the native format for x86 processors used in Windows and official Intel manuals , while AT&T syntax (source first) is the default for GNU tools like GCC and GDB on Linux/Unix systems. [1, 2, 3]

Key Syntax Differences

Feature [2, 4, 5, 6, 7] Intel Syntax AT&T Syntax
Operand Order Opcode Dest, Src Opcode Src, Dest
Register Prefix None (e.g., eax) % (e.g., %eax)
Immediate Value None (e.g., 5) $ (e.g., $5)
Size Suffixes Explicit specifiers (dword ptr) Suffixes on mnemonics (movl)
Memory Access [base + index*scale + disp] disp(base, index, scale)

Detailed Breakdown

  • Operand Direction: In Intel syntax, mov eax, 1 means “move 1 into eax” (reads like a variable assignment: eax = 1). In AT&T syntax, movl $1, %eax means “move 1 into eax” (reads like a function call or English sentence: “move 1 to eax”).
  • Memory Addressing: Intel uses a mathematical expression inside brackets, which many find more intuitive. AT&T uses a comma-separated format where the displacement is outside the parentheses, e.g., 8(%ebp, %ecx, 4).
  • Instruction Suffixes: AT&T uses a letter at the end of the instruction to denote data size: b (byte), w (word), l (long/32-bit), and q (quad/64-bit). Intel handles this with prefixes like byte ptr or qword ptr when the size is not clear from the registers. [2, 8, 9, 10, 11, 12]

Which One Should You Use?

  • Use Intel if you are developing for Windows (MASM/NASM), doing reverse engineering (IDA Pro/Ghidra default to Intel), or following official Intel/AMD documentation .
  • Use AT&T if you are writing inline assembly for GCC or Clang or working extensively in the Linux kernel where it is the established standard. [1, 8, 13, 14]

Note: Most modern tools allow you to switch. For example, in GDB, you can use set disassembly-flavor intel to see Intel syntax instead of the default AT&T. [8] Are you working on a specific project, like a Linux driver or a Windows application, that requires one of these?

avatar
除非注明,本博客所有文章皆为原创。
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。