Assembly
x86 and amd64 instruction reference
Registers & Function Call
x86 Registers (32-bit)
With the x86 elf architecture, arguments are passed on the stack.
eax
ax
al
Accumulator (arithmetic results) Return Value
ebx
bx
bl
Base register (addresses, general use)
ecx
cx
cl
Counter (loops, shifts)
edx
dx
dl
Data, multiplication/division
esi
si
/
Source index (strings, arrays)
edi
di
/
Destination index (strings, arrays)
esp
sp
/
Stack pointer (top of the stack)
ebp
bp
/
Base/frame pointer (stack frames)
eip
/
/
Extended Instruction Pointer (next instruction)
x64 Registers (64-bit)
In x64 linux arguments to a function are passed via registers.
rax
eax
ax
al
Accumulator (arithmetic results) Return Value
rbx
ebx
bx
bl
Base register (addresses, general use)
rcx
ecx
cx
cl
Counter (loops, shifts) 4. Fourth Argument
rdx
edx
dx
dl
Data, multiplication/division 3. Third Argument
rsi
esi
si
sil
Source index (strings, arrays) 2. Second Argument
rdi
edi
di
dil
Destination index (strings, arrays) 1. First Argument
rsp
esp
sp
spl
Stack pointer (top of the stack)
rbp
ebp
bp
bpl
Base/frame pointer (stack frames)
r8
r8d
r8w
r8b
General-purpose 5. Fifth Argument
r9
r9d
r9w
r9b
General-purpose 6. Sixth Argument
r10
r10d
r10w
r10b
General-purpose
r11
r11d
r11w
r11b
General-purpose
r12
r12d
r12w
r12b
General-purpose
r13
r13d
r13w
r13b
General-purpose
r14
r14d
r14w
r14b
General-purpose
r15
r15d
r15w
r15b
General-purpose
rip
eip
/
/
Register Instruction Pointer (next instruction)
Function Call
+-----------------+ 0x00000000
| ... |
+- +-----------------+ <- ESP
| | Old EIP |
F | +-----------------+
R | | ... |
A | | ... |
M | | Local Variable |
E | +-----------------+ <-- EBP = Old ESP
| | Old EBP |
+- +-----------------+
| Old EIP | <-- Return Address
+-----------------+
| ... |
+-----------------+ 0xffffffffcall function ; push eip
; jmp functionPrologue
push ebp ; save the old base pointer
mov ebp, esp ; save esp in ebp
sub esp, x ; allocate space for local variablesEpilogue
leave ; mov esp, ebp ; restore esp
; pop ebp ; restore ebp
ret ; pop eip ; restore executionInstructions & Note
MOV
Dereferencing []
LEA
ADD
SUB
PUSH
POP
CMP
JMP
JE/JNE/JG/JL/JZ/JNZ
XOR/AND/OR
Last updated