Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

NASM Intel x86 Assembly Language Cheat Sheet, Cheat Sheet of Assembly Language Programming

Typology: Cheat Sheet

2020/2021

Uploaded on 04/26/2021

ekambar
ekambar 🇺🇸

4.7

(23)

265 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NASM Intel x86 Assembly Language Cheat Sheet
Instruction Effect Examples
Copying Data
mov dest,src Copy src to dest mov eax,10
mov eax,[2000]
Arithmetic
add dest,src dest = dest + src add esi,10
sub dest,src dest = dest – src sub eax, ebx
mul reg edx:eax = eax * reg mul esi
div reg edx = edx:eax mod reg
eax = edx:eax reg
div edi
inc dest Increment destination inc eax
dec dest Decrement destination dec word [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.
I.e.: esp=esp-4; memory[esp] = item
push dword 32
push eax
pop [reg] Pop item from stack and store to register
I.e.: reg=memory[esp]; esp=esp+4
pop eax
Bitwise Operations
and dest, src dest = src & dest and ebx, eax
or dest,src dest = src | dest or eax,[0x2000]
xor dest, src dest = src ^ dest xor ebx, 0xfffffff
shl dest,count dest = dest << count shl eax, 2
shr dest,count dest = dest >> count shr dword [eax],4
Conditionals and Jumps
cmp b,a Compare b to a; must immediately precede any of
the conditional jump instructions
cmp eax,0
je label Jump to label if b == a je endloop
jne label Jump to label if b != a jne loopstart
jg label Jump to label if b > a jg exit
jge label Jump to label if b > a jge format_disk
jl label Jump to label if b < a jl error
jle label Jump to label if b < a jle finish
test reg,imm Bitwise compare of register and constant; should
immediately precede the jz or jnz instructions
test eax,0xffff
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
Miscellaneous
nop No-op (opcode 0x90) nop
hlt Halt the CPU hlt
Instructions with no memory references must include ‘byte’, ‘word’ or ‘dword’ size specifier.
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: [200] or [0x1000+53]
Register: eax bl Dynamic address: [eax] or [esp+16]
32-bit registers: eax, ebx, ecx, edx, esi, edi, ebp, esp (points to first used location on top of stack)
16-bit registers: ax, bx, cx, dx, si, di, sp, bp
8-bit registers: al, ah, bl, bh, cl, ch, dl, dh

Partial preview of the text

Download NASM Intel x86 Assembly Language Cheat Sheet and more Cheat Sheet Assembly Language Programming in PDF only on Docsity!

NASM Intel x86 Assembly Language Cheat Sheet

Instruction Effect Examples Copying Data mov dest,src Copy src to dest mov eax, mov eax,[2000] Arithmetic add dest , src dest = dest + src add esi, sub dest , src dest = dest – src sub eax, ebx mul reg edx:eax = eax * reg mul esi div reg edx = edx:eax mod reg eax = edx:eax  reg div edi inc dest Increment destination inc eax dec dest Decrement destination dec word [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. I.e.: esp=esp-4; memory[esp] = item push dword 32 push eax pop [reg] Pop item from stack and store to register I.e.: reg=memory[esp]; esp=esp+ pop eax Bitwise Operations and dest, src dest = src & dest and ebx, eax or dest,src dest = src | dest or eax,[0x2000] xor dest, src dest = src ^ dest xor ebx, 0xfffffff shl dest,count dest = dest << count shl eax, 2 shr dest,count dest = dest >> count shr dword [eax], Conditionals and Jumps cmp b,a Compare b to a; must immediately precede any of the conditional jump instructions cmp eax, je label Jump to label if b == a je endloop jne label Jump to label if b != a jne loopstart jg label Jump to label if b > a jg exit jge label Jump to label if b > a jge format_disk jl label Jump to label if b < a jl error jle label Jump to label if b < a jle finish test reg,imm Bitwise compare of register and constant; should immediately precede the jz or jnz instructions test eax,0xffff 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 Miscellaneous nop No-op (opcode 0x90) nop hlt Halt the CPU hlt Instructions with no memory references must include ‘byte’, ‘word’ or ‘dword’ size specifier. 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: [200] or [0x1000+53] Register: eax bl Dynamic address: [eax] or [esp+16] 32-bit registers: eax, ebx, ecx, edx, esi, edi, ebp, esp (points to first used location on top of stack) 16-bit registers: ax, bx, cx, dx, si, di, sp, bp 8-bit registers: al, ah, bl, bh, cl, ch, dl, dh