- register is 32 bit wide
- eax - accumulator
- ebx - base
- ecx - counter
- edx - data
- esi - source index
- edi - destination index
- esp - stack pointer
- ebp - base pointer
- register is 64 bit wide
- an x86-64 register contains a 32-bit section
- no stack operations required
- %(register) => memory location
- memory is like an array(index -> value) ==> MEM[index] -> VALUE
- displacement memory address mode ==> 8(%ebp) == MEM[ebp + 8]
- indirect mode => %(ebp) | %ebp
- state = memory + register + stack
- gcc -S => generates / compiles to ASM
- switch cases in ASM are implemented using JUMP tables
- (Rb, Ri) == MEM[REGISTER[Rb] + REGISTER[Ri]]
- D(Ri) == MEM[REGISTER[Ri] + D]
- (Rb, Ri, D) == MEM[REGISTER[Rb] + REGISTER[Ri] * D]
- (, Ri,D) == MEM[REGISTER[Ri] * D]
- leal (set dst to address mode expression) => leal (%edx, ecx, 4), %eax
- %eip - instruction pointer => pointer to next instruction to execute
- load - load from register into memory
- store - store data in memory into a register
movX src dest, where X in [b | w | l]
b = 1 byte
w = 2 bytes
l = 4 bytes
src = (memory) | register
- CF => set if result of operation is signed or positive
- SF => set if result of operation is unsigned or negative
- ZF => set if result of operation is zero (0)
- OF => set if result of operation is greater than the memory available or stack space
Sorry, no fancy graphics available at the moment.
- instructions (executable)
- literals (non-executable)
- static data (constants, global vars)
- dynamic data (HEAP, managed by programmer)
- STACK (managed automatically by compiler)
This is the state/context for a single procedure
- local variables
- function arguments
- return address (pointer to caller)
- saved register context
- stack frame = %esp - %ebp