Questions tagged [att]

AT&T Syntax is an assembly syntax used in UNIX environments, that originates from AT&T Bell Labs. It is descended from PDP-11 assembly syntax.

AT&T Syntax is an assembly syntax used mostly in UNIX environments or by tools like gcc that originated in that environment. GNU (gcc/binutils) chose AT&T syntax for compatibility with AT&T Bell Labs' Unix assembler syntax for 386. That in turn based its syntax design on the PDP-11 PAL-11 assembler. (See also: Questions about AT&T x86 Syntax design and What was the original reason for the design of AT&T assembly syntax?)

It's used by the GNU assembler, and some compatible tools like clang's built-in assembler. These tools all also use GNU assembler directives like .globl main and .byte 0x12 instead of db 12h. See the GAS manual.

Most tools that default to AT&T syntax have options to use MASM-like GNU Intel Syntax. gcc -masm=intel -S or objdump -drwC -Mintel. Or in GAS, .intel_syntax noprefix is a directive. See the tag wiki.

See also the tag wiki for more about the x86 architecture and assembly in general. See the tag wiki for more about GNU C inline asm.


x87 syntax design bug / incompatibility with Intel syntax:

AT&T syntax reverses the mnemonics for fsubr and fsub, and other non-commutative x87 instructions like fdivr, when the destination is %st(i). See the GAS manual entry. Tools like objdump -d that disassemble in AT&T syntax are also compatible with this mnemonic -> opcode mapping. See also Objdump swapping fsubrp to fsubp on compiled assembly?

Modern version of objdump -d -Mintel use the Intel-syntax interpretation of the mnemonics as expected. (Editor's note: I seem to recall older versions of objdump and/or GAS in Intel-syntax mode still using the AT&T bug-compatible mnemonics.)


Syntax details

Operands are in destination-last order, the reverse of Intel syntax (used in Intel/AMD manuals). For example pshufd $0xE4, %xmm0, %xmm1 shuffles xmm0 and puts the result into xmm1. (Intel syntax pshufd xmm1, xmm0, 0E4h. To translate to/from Intel syntax, always reverse the list of operands.

Register names are prefixed with %, and immediates are prefixed with $. Operand-size is indicated with a b/w/l/q suffix on the mnemonic, but is optional if it's not implied by a register operand, the same way that dword or dword ptr is optional in NASM. Addressing modes use a totally different syntax, disp(base, idx, scale)

Examples:

  • sub $24, %rsp reserves 24 bytes on the stack.
  • mov foo, %eax is a load from the address of symbol foo.
  • mov $foo, %rax puts that address in %rax (mov-imm32)
  • lea foo(%rip), %rax (64-bit mode only) RIP-relative addressing mode for PIC (position-independent) code. (How to load address of function or label into register in GNU Assembler and what does "mov offset(%rip), %rax" do?)
  • movabs $0x123456789ABCDEF, %rax the imm64 or 64-bit absolute memory address forms of mov use the movabs mnemonic in AT&T syntax.
  • imul $13, 16(%rdi, %rcx, 4), %eax 32-bit load from rdi + rcx<<2 + 16, multiply that by 13, put the result in %eax. Intel imul eax, [16 + rdi + rcx*4], 13.
  • addb $1, byte_table(%rdi) increment a byte in a static table. (disp32+base addressing mode, so this is technically not an indexed addressing mode). Operand-size suffix is mandatory here, because neither operand is a register to imply a size.
  • addl $1, dword_table(, %rdi, 4) increment a dword in a static table. (disp32 + scaled-index addressing mode with no base register).
  • movswl (%rdi), %eax sign-extending load from word (w) to dword (l). Intel movsx eax, word [rdi]. AT&T needs different mnemonics for each source size of movzx / movsx. What does the MOVZBL instruction do in IA-32 AT&T syntax? and what does movsbl instruction do?.
  • cltq = cdqe in Intel, cltd = cdq. They (and related instructions for other sizes) sign extend within eax/rax or from eax into edx:eax (or rax into rdx:rax). The GNU assembler accepts the more-readable Intel mnemonics where the within-rax version always ends with e (except for cbw). See What does cltq do in assembly?.


Canonical Q&As:

1033 questions
212
votes
5 answers

The point of test %eax %eax

Possible Duplicate: x86 Assembly - ‘testl’ eax against eax? I'm very very new to assembly language programming, and I'm currently trying to read the assembly language generated from a binary. I've run across test %eax,%eax or test %rdi,…
pauliwago
  • 6,373
  • 11
  • 42
  • 52
97
votes
7 answers

Limitations of Intel Assembly Syntax Compared to AT&T

To me, Intel syntax is much easier to read. If I go traipsing through assembly forest concentrating only on Intel syntax, will I miss anything? Is there any reason I would want to switch to AT&T (outside of being able to read others' AT&T assembly)?…
oevna
  • 1,246
  • 1
  • 11
  • 10
59
votes
5 answers

NASM Vs GAS (Practical differences)

I'm not trying to prompt an Intel vs AT&T war (moot point anyway, now that they both support Intel syntax) or ask which one is "better" per se, I just want to know the practical differences in choosing one or the other. Basically, when I was picking…
Elliott
  • 1,127
  • 1
  • 9
  • 16
55
votes
7 answers

Set adb vendor keys

EDIT: I figured out the problem, i think. ADB found out I wasn't on the latest updates (at&t released a stagefright udpate and i didnt know) so ADB didn't let me debug. Everything is fine now. I have been debugging my app on an AT&T HTC One M8 for…
LonelyIdiot
  • 789
  • 2
  • 6
  • 16
52
votes
2 answers

What was the original reason for the design of AT&T assembly syntax?

When using assembly instructions on x86 or amd64, programmer can use "Intel" (i.e. nasm compiler) or "AT&T" (i.e. gas compiler) assembly syntax. "Intel" syntax is more popular on Windows, but "AT&T" is more popular on UNIX(-like) systems. But both…
antonone
  • 2,045
  • 1
  • 25
  • 35
49
votes
2 answers

What does the MOVZBL instruction do in IA-32 AT&T syntax?

What exactly does this instruction do? movzbl 0x01(%eax,%ecx), %eax
user663896
48
votes
5 answers

What do the dollar ($) and percentage (%) signs represent in x86 assembly?

I am trying to understand how the assembly language works for a micro-computer architecture class, and I keep facing different syntaxes in examples: sub $48, %esp mov %eax, 32(%esp) What do these codes mean? What is the 32 operand an addition to…
juliensaad
  • 2,019
  • 2
  • 20
  • 27
48
votes
2 answers

What is callq instruction?

I have some gnu assembler code for the x86_64 architecture generated by a tool and there are these instructions: movq %rsp, %rbp leaq str(%rip), %rdi callq puts movl $0, %eax I can not find actual documentation on the "callq" instruction. I have…
user10607
  • 3,011
  • 4
  • 24
  • 31
37
votes
4 answers

What does cltq do in assembly?

0x0000000000400553 : mov -0x4(%rbp),%eax 0x0000000000400556 : cltq 0x0000000000400558 : shl $0x3,%rax 0x000000000040055c : mov %rax,%rdx In fact my programe is as simple as : 5 int main(int…
R__
  • 1,441
  • 5
  • 16
  • 22
37
votes
1 answer

Difference between movq and movabsq in x86-64

I'm talking about data movement instructions in the x86-64 Intel architecture. I have read that the regular movq instruction can only have immediate source operands that can be represented as 32-bit two's complement numbers, while the movabsq…
IgNite
  • 652
  • 2
  • 6
  • 17
33
votes
2 answers

movq (%rsp), %rsp assembly stack pointer load?

I was reading some code and was not sure what this line does: movq (%rsp), %rsp
jamesatha
  • 7,280
  • 14
  • 37
  • 54
32
votes
7 answers

What does an asterisk * before an address mean in x86-64 AT&T assembly?

What does the following line mean: ... 401147: ff 24 c5 80 26 40 00 jmpq *0x402680(,%rax,8) ... What does the asterisk in front of the memory address mean? Also, what does it mean when the memory access method is missing it's first register…
de1337ed
  • 3,113
  • 12
  • 37
  • 55
23
votes
4 answers

Questions about AT&T x86 Syntax design

Can anyone explain to me why every constant in AT&T syntax has a '$' in front of it? Why do all registers have a '%'? Is this just another attempt to get me to do a lot of lame typing? Also, am I the only one that finds: 16(%esp) really…
Skeen
  • 4,614
  • 5
  • 41
  • 67
23
votes
4 answers

google compute engine tool gcloud is exceptionally slow

I tried downloading and using the gcloud bash tool to manage my accounts, however everything I do with the tool is exceptionally slow. It will take MINUTES to reply to a command that is typed. Is there perhaps a firewall I need to open up on my…
23
votes
6 answers

Why would one use "movl $1, %eax" as opposed to, say, "movb $1, %eax"

As the title states, why would one use "movl $1, %eax" as opposed to, say, "movb $1, %eax", I was told that movl would zero out the high order bits of %eax, but isn't %eax a register that's equivalent to the size of the system's wordsize? meaning…
1
2 3
68 69