1. 第一个 operand 为 source, 第二个为 destination (和 Intel 的刚好相反).
将 EAX寄存器的内容拷贝到 EBX:
movl %eax, %ebx
2. 寄存器的名字前要加上 %
3. 立即数前面加上 $. 静态的 C语言变量也加前缀 $
4. operand 的大小通过operator 的最后一个字符(b,w,l)来确定。b: 1 byte; w: 2 bytes; l: 4 bytes
5. memory 操作:
section:disp(base, index, scale)
相当与 intel 的
section:[base + index*scale + disp]
对于用作 scale 和 disp的常量,不用加前缀 $
下面是 Intel 和 AT&T 格式的 assembly code 的对比:
+------------------------------+------------------------------------+ | Intel Code | AT&T Code | +------------------------------+------------------------------------+ | mov eax,1 | movl $1,%eax | | mov ebx,0ffh | movl $0xff,%ebx | | int 80h | int $0x80 | | mov ebx, eax | movl %eax, %ebx | | mov eax,[ecx] | movl (%ecx),%eax | | mov eax,[ebx+3] | movl 3(%ebx),%eax | | mov eax,[ebx+20h] | movl 0x20(%ebx),%eax | | add eax,[ebx+ecx*2h] | addl (%ebx,%ecx,0x2),%eax | | lea eax,[ebx+ecx] | leal (%ebx,%ecx),%eax | | sub eax,[ebx+ecx*4h-20h] | subl -0x20(%ebx,%ecx,0x4),%eax |