General Registers
EAX |
Accumulator |
EBX |
Base |
ECX |
Counter |
EDX |
Data |
General Registers: specific values are expected when calling the kernel.
Pointer-Registers
ESP |
Stackpointer |
EBP |
Basepointer |
EIP |
Instructionpointer |
Index-Registers
ESI |
Source Index |
EDI |
Destination Index |
Segment- Registers
ECS |
Code-Segment |
EDS |
Data-Segment |
ESS |
Stack-Segment |
EES |
Extra-Segment |
NASM Basics
-f |
filesystem |
-g |
debugginfos |
-o |
output |
Compiling a Code
nasm -f elf32 -g -o filename.o filename.nasm
ld -o filename filename.o
|
in 64bit Architecture use -f elf64
|
|
Syscall-Numbers Linux
EAX |
Name(EBX, ECX, EDX) |
1 |
exit( int) |
2 |
fork( pointer) |
3 |
read( uint, char*, int) |
4 |
write( uint, char*, int) |
5 |
open( char *, int, int) |
NASM Code-Sections
.text |
Code |
.data |
initialized Data |
.bss |
uninitialized Data |
Example
global _start
.data
msg db "Hello World",0xa
len equ $-msg
.text
_start:
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg
mov edx, len
int 0x80
exit:
mov eax, 0x1
mov ebx, 0x1
int 0x80
|
Misc
|
call Interrup Nr |
|
jumps to label |
|
returns to call |
|
no operation |
|
load effective addr. to dest |
int 0x80
calls the Kernel in Linux
Logical Operations
|
two-Complement |
|
invert each bit |
|
dest= dest source |
|
dest=dest source |
|
dest = dest XOR source |
|
|
Control / Jumps (signed Int)
|
Compare op1 with op2 |
|
bitwise comparison |
|
unconditional Jump |
|
Jump if equal |
|
Jump if not equal |
|
Jump if zero |
|
Jump if not zero |
|
Jump if greater |
|
Jump if greater or equal |
|
Jump if less |
|
Jump if less or equal |
For unsigned Integer use ja, jae
(above) or jb, jbe
(below)
Mnemonics Intel
|
Moves Data |
|
Add value to dest |
|
Subtract value3 from dest* |
|
Increment dest |
|
Decrement dest |
|
Multiply EAX and src |
|
dest = dest * source |
General Structure:
[label] mnemonic [operands] [;comment]
Stack Operations
push source |
Insert Value onto the stack |
pop dest |
Remove value from stack |
Stack is a LIFO-Storage (Last In First Out)
|
Created By
www.ken.ch/%7elueg
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Siniansung