Вы находитесь на странице: 1из 2

Linux Assembler Cheat Sheet

by Gregor Lüdi (Siniansung) via cheatography.com/20378/cs/3174/

General Registers NASM Basics Example (cont)

EAX Accumu​lator -f filesystem ​ ​ ​ mov eax, 0x4

EBX Base -g debugg​infos ​ ​ ​ mov ebx, 0x1


​ ​ ​ mov ecx, msg
ECX Counter -o output
​ ​ ​ mov edx, len
EDX Data
Compiling a Code ​ ​ ​ int 0x80
General Registers: specific values are expected
exit:
when calling the kernel. nasm -f elf32 -g -o filename.o
​ ​ ​ mov eax, 0x1
filename.nasm
​ ​ ​ mov ebx, 0x1
Pointe​r-R​egi​sters ld -o filename filename.o
​ ​ ​ int 0x80
ESP Stackp​ointer in 64bit Archit​ecture use -f elf64
EBP Basepo​inter Misc
EIP Instru​cti​onp​ointer Syscal​l-N​umbers Linux
int Nr call Interrup Nr
EAX Name​(EBX, ECX, EDX)
Index-​Reg​isters call label jumps to label
1 exit( int)
ret returns to call
ESI Source Index 2 fork( pointer)
EDI Destin​ation Index nop no operation
3 read( uint, char*, int)

4 write( uint, char*, int) lea load effective addr. to dest


Segment- Registers dest​, src
5 open( char *, int, int)
ECS Code-S​egment
Linux Syscall Reference int 0x80 calls the Kernel in Linux
EDS Data-S​egment

ESS Stack-​Segment NASM Code-S​ections Logical Operations

EES Extra-​Segment two-Co​mpl​ement


.text Code neg op

.data initia​lized Data not op invert each bit


Flags
.bss uninit​ialized Data and dest= dest  source
​ urce
dest​, so
Example
or dest​= dest  source
global _start dest​, s​ource
.data
xor dest, surce dest = dest XOR source
​ ​ ​ msg db "​Hello World",0xa
​ ​ ​ len equ $-msg
.text
_start:

By Gregor Lüdi (Siniansung) Published 13th January, 2015. Sponsored by CrosswordCheats.com


cheatography.com/siniansung/ Last updated 19th January, 2015. Learn to solve cryptic crosswords!
www.ken.ch/%7elueg Page 1 of 2. http://crosswordcheats.com
Linux Assembler Cheat Sheet
by Gregor Lüdi (Siniansung) via cheatography.com/20378/cs/3174/

Control / Jumps (signed Int) Stack Operations

cmp op1,​op2 Compare op1 with op2 push source Insert Value onto the stack

test op1,​op2 bitwise comparison pop dest Remove value from stack

jmp dest uncond​itional Jump Stack is a LIFO-S​torage (Last In First Out)

je dest Jump if equal

jne dest Jump if not equal

jz dest Jump if zero

jnz dest Jump if not zero

jg dest Jump if greater

jge dest Jump if greater or equal

jl dest Jump if less

jle dest Jump if less or equal

For unsigned Integer use ja, jae (above) or


jb, jbe (below)

Mnemonics Intel

mov dest, Moves Data


source

add dest, value Add value to dest

sub Subtract value3 from


dest​, v​alue dest*

inc dest Increment dest

dec dest Decrement dest

mul src Multiply EAX and src

imul dest, dest = dest * source


source

General Structure:
[label] mnemonic [operands]
[;comment]

By Gregor Lüdi (Siniansung) Published 13th January, 2015. Sponsored by CrosswordCheats.com


cheatography.com/siniansung/ Last updated 19th January, 2015. Learn to solve cryptic crosswords!
www.ken.ch/%7elueg Page 2 of 2. http://crosswordcheats.com

Вам также может понравиться