View Single Post
Old Jul 9th, 2005, 4:03 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Generally speaking, to translate to ATT syntax, do the following:

Add a suffix to the instruction indicating the operand size (even though it's usually implicit in the register operands), prepend the register name with a '%', and reverse the source and destination operands.

Example: mov bl, al ==> movb %al, %bl.

Immediate values are indicated by a '$':
movl $0xffff, %eax

Indirect memory references use parentheses:
mov dword ptr [edi+4], edx ==> movl %edx, (%edi+4)

That's sort of from the seat of my pants, might have something wrong. GCC also has another mechanism using an instruction template with register constraints, but it seems unnecessarily complicated to me.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote