Link Search Menu Expand Document

ASM Cheatsheet

  • Assembly cheatsheet to help any programmers that get stuck and need a quick reference sheet.

Intel x86 Assembly Language Cheat Sheet

Instruction Effect   Examples

| - | - | :- | - |

Copying Data  
mov src,dest Copy src to dest   mov $10,%eax movw %eax,(2000)
Arithmetic  
add src,dest dest = dest + src   add $10, %esi
sub src,dest dest = dest – src   sub %eax,%ebx
mul reg edx:eax = eax * reg   mul %esi
div reg edx = edx:eax mod reg   div %edi
  eax = edx:eax  reg    
inc dest Increment destination   inc %eax
dec dest Decrement destination   dec (0x1000)
Function Calls  
call label Push eip, transfer control   call format_disk
ret Pop eip and return   ret
push item Push item (constant or register) to stack   pushl $32 push %eax
pop [reg] Pop item from stack; optionally store to register   pop %eax popl
Bitwise Operations  
and src,dest dest = src & dest   and %ebx, %eax
or src,dest dest = src dest   orl (0x2000),%eax
xor src,dest dest = src ^ dest   xor $0xffffffff,%ebx
shl count,dest dest = dest « count   shl $2,%eax
shr count,dest dest = dest » count   shr $4,(%eax)
Conditionals and Jumps  
cmp arg1,arg2 Compare arg1 to arg2; must immediately precede any of the conditional jump instructions   cmp $0,%eax
je label Jump to label if arg1 == arg2   je endloop
jne label Jump to label if arg1 != arg2   jne loopstart
jg label Jump to label if arg2 > arg1   jg exit
jge label Jump to label if arg2 > arg1   jge format_disk
jl label Jump to label if arg2 < arg1   jl error
jle label Jump to label if arg2 < arg1   jle finish
test reg,imm Bitwise compare of register and constant; must immediately precede the jz or jnz instructions   test $0xffff,%eax
jz label Jump to label if bits were not set (“zero”)   jz looparound
jnz label Jump to label if bits were set (“not zero”)   jnz error
jmp label Unconditional relative jump   jmp exit
jmp *reg Unconditional absolute jump; arg is a register   jmp *%eax
ljmp segment,offs Unconditional absolute far jump   ljmp $0x10,$0
Miscellaneous  
nop No-op (opcode 0x90)   nop
hlt Halt the CPU   hlt

Suffixes: b=byte (8 bits); w=word (16 bits); l=long (32 bits). Optional if instruction is unambiguous.

Arguments to instructions: Note that it is not possible for both src and dest to be memory addresses.

Constant (decimal or hex): $10  or  $0xff Fixed address: (2000) or (0x1000+53) Register: %eax   %bl Dynamic address: (%eax) or 16(%esp) 32-bit registers: %eax, %ebx, %ecx, %edx, %esi, %edi, %esp, %ebp

16-bit registers: %ax, %bx, %cx, %dx, %si, %di, %sp, %bp

8-bit registers: %al, %ah, %bl, %bh, %cl, %ch, %dl, %dh

Note


Disclaimer for KBVE:

We are doing our best to prepare the content of this site. However, KBVE (and its associations and subsidiaries) cannot warranty the expressions and suggestions of the contents, as well as its accuracy. In addition, to the extent permitted by the law, KBVE (assocations and subsidiaries) shall not be responsible for any losses and/or damages due to the usage of the information on our website(s). KBVE (content, site, files) is for informational and/or entertainment purposes only, you should not construe any such information or other material as legal, statutory, tax, investment, financial, or other advice. Nothing contained on KBVE (content, site, files ) constitutes a solicitation, recommendation, endorsement, or offer by KBVE or any third party service provider to buy or sell any securities or other financial instruments in this or in in any other jurisdiction in which such solicitation or offer would be unlawful under the securities laws of such jurisdiction. By using our website (including content), you hereby consent to our disclaimer and agree to its terms. The links contained on our website may lead to external sites, which are provided for convenience only. Any information or statements that appeared in these sites are not sponsored, endorsed, or otherwise approved by KBVE. For these external sites, KBVE cannot be held liable for the availability of, or the content located on or through it. Plus, any losses or damages occurred from using these contents or the internet generally.