1. The first operand is source and the second is destination (just the opposite of Intel).
Copy the contents of the EAX register to EBX:
MOVL %eax,%EBX
2. Register before the name to add%
3. Add $ immediately before the number. Static C-language variables are also prefixed with $
4. The size of the operand is determined by the last character (b,w,l) of the operator. B:1 byte; W:2 bytes; L:4 bytes
5. Memory Operation:
Section:disp (base, index, scale)
Quite with Intel's
Section:[base + Index*scale + disp]
For constants that are used as scale and disp, do not prefix $
The following is a comparison of the Intel and at&t format 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 |