Intro To 32 Bit x86 Assembly Flashcards
What are the general purpose registers?
EAX/EBX (used by some arithmetic instructions or to store function return values)
ECX (used in shift and rotation instructions, or as a loop counter)
EDX (used by chromatic instructions and in I/O operations)
ESI/EDI (used as source/dest indices in stream operations)
What are the pointer registers?
ESP (pointer to top of the stack)
EBP (pointer to base of the current stack frame)
EIP (address of next instruction to be executed)
What byte order is used?
Little endian (the significant byte at smallest address)
What happens when you invoke a system call?
Store its number in the EAX register then invoke syscall handler with int $0x80 instruction
What does the instruction “mov $0x02, %eax” do?
It copies the constant 32 bit value 0x02 into register %eax
Which of these assembly instructions has NULL bytes in its encoding?
a. mov $0x1, %eax
b. movl 0x1, (%eax)
c. mov $0x1, %al
d. movb 0x1, (%eax)
a. mov $0x1, %eax
The constant 0x1 must be copied into a 32 but register, therefore the encoding of mov will definitely have 00 00 00 01 to represent the immediate value 0x1
b and d copy contents stored at address 0x1 to wherever %eax is pointing to
c copies constant 0x1 to least significant 8 bits of %eax (does not require padding)
What does push <src> do?</src>
- decrements ESP by 4 bytes
- copies 32-bit operand <src> on top of the stack</src>
What does pop <dest> do?</dest>
- copies 4 bytes on the top of the stack to <dest></dest>
- increments ESP by 4 bytes