Common x86/x64 assembly
Basics
add
add arg1, arg2 ; arg1 = arg + arg2 sub
sub arg1, arg2 ; arg1 = arg1 - arg2push/pop
3.1 Push
push arg ; place the operand (arg) onto the top of the stack in memoryDecrements ESP by 4 (stack grows from high to low addresses)
Place the operand into the content of the 32-bit (4 bytes) location at address [ESP]
Simply decrease the stack pointer and append a new value
3.2 Pop
pop arg ; removes the data element from the top of the stack into the specified operandMoves the 32-bit (4 bytes) data element from the top of the stack into the specified operand
Increments stack pointer (SP) by 4
Simply remove a value from stack and increase the stack pointer
lea(load effective address)
Note, the contents of the memory location are not loaded, only the effective address is computed and placed into the register. This is useful for obtaining a pointer into a memory region.
cmp
Performs operations to update the EFLAGS register
Used in conjunction with jump instructions
jump instructions
Used in conjunction with
cmp
5.1 Jump
Transfers program control flow to the instruction at the memory location indicated by the operand
5.2 Conditional jump
call,ret
call
a. First, push the current code location on the stack in memory (push)
b. Next, performs an unconditional jump to the code location indicated by the label operand (jmp)
Unlike the simple jump instructions, the call instruction saves the location to return to when the subroutine completes.
ret
Implements a subroutine return mechanism
a. First, pops a code location off the stack (pop)
b. Next, performs an unconditional jump to the retrieved code location (jmp)
leave
Last updated