03 - x86 Assembly Code Flashcards
Explain the GPR: EAX?
Accumulator, Return value of functions, data storage
Explain the GPR: EBX?
Data Index, data storage
Explain the GPR: ECX?
Loop Counter
Explain the GPR: EDX?
Data register, data storage
Explain the GPR: EIP?
Instruction Pointer
Explain the GPR: ESP?
Stack Pointer
Goes along the stack. Always contains the memory address of the top of the current stack.
Explain the GPR: EBP?
Base Pointer
Manages stack frame. EBP always contains the memory address of the bottom of the current stack.
Explain the GPR: ESI?
Source index, string operations
Explain the GPR: EDI?
Destination index, string operations
Explain the EEFLAG: CF
Carry Flag; is set if the last operation caused a carry. If the result of some arithmetic operation was bigger than the space allowed.
Explain the EEFLAG: PF
Parity Flag; is 1 if there is an even number of binary 1s in the result of an operation.
Explain the EEFLAG: ZF
Zero Flag: It is set if the last instruction had a result of zero.
Explain the EEFLAG: SF
Sign Flag; is set to indicate whether the last mathematical operation resulted in a value whose most significant bit was set to 1 (e.g it is a signed number, and is negative)
Explain the EEFLAG: TF
Trap Flag; Used with debuggers – instead of running all instructions, it will generate an exception that can be caught be a debugger after every instruction.
Explain the EEFLAG: DF
Direction Flag; Is used in string operations, e.g. do you want to read right-left or left-right.
Explain the EEFLAG: OF
Overflow Flag; is set when the MSB (most significant bit) is changed, indicating an arithmetic overflow.
MOV?
Simply moves a byte, word or dword from the source location to the destination location. There are some limitations to the mov instruction – for example the source and destination cannot both be a memory address, and the source and destination must be the same size.
- mov eax, ebx // Moves the value in the ebx register into eax
- mov eax, [ebx] // Moves the value at the memory address
LEA?
Load Effective Address. Takes the value passed in the source (which is normally a sum), calculates the final result, and stores that value into the destination.
- lea eax, [ebx+1] // Adds +1 to the value in the ebx register and moves it into eax