X86 Assembly Cheat Sheet



25 Mar 2014

This post is just a little cheat sheet for myself on Intel & AT&T syntax.

A useful table mapping some simple instructions between the two syntaxes linked through from the GCC-Inline-Assembly-HOWTO:

Intel CodeAT&T Code
mov eax,1movl $1,%eax
mov ebx,0ffhmovl $0xff,%ebx
int 80hint $0x80
mov ebx, eaxmovl %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

IA32 gnu Cheat Sheet Integer Registers (4 byte)%eip instruction pointer%esp stack pointer%ebp base pointer for stack frame%eax return values; low of pair for mul/div with%edx; intermediate%edx Signed Comparisons:high of pair for mul/div pair with%eax; intermediate%ecx intermediate%ebx base address for arrays; callee save. Bit Operations Bit Shifting & Rotation Bit Counting Specials Transactional Memory Comparisons String Compare Overview Each intrinsic i s only available on machines which support the.

Some important points to note:

At&t Assembly Cheat Sheet

  • Source and destinations are flipped in opcodes.
    • Intel is dest, src
    • AT&T is src, dest
  • AT&T decorates registers and immediates
    • Registers are prefixed with a “%”
    • Immediates are prefixed with a “$”. This applies to variables being passed in from C (when you’re inline).
  • Intel decorates memory operands to denote the operand’s size, AT&T uses different mnemonics to accomplish the same.
  • Intel syntax to dereference a memory location is “[ ]”. AT&T uses “( )”.

X64 Cheat Sheet

Sheet

X86 Assembly Cheat Sheet

Related Posts