Intro To 32 Bit x86 Assembly Flashcards

1
Q

What are the general purpose registers?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the pointer registers?

A

ESP (pointer to top of the stack)
EBP (pointer to base of the current stack frame)
EIP (address of next instruction to be executed)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What byte order is used?

A

Little endian (the significant byte at smallest address)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens when you invoke a system call?

A

Store its number in the EAX register then invoke syscall handler with int $0x80 instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the instruction “mov $0x02, %eax” do?

A

It copies the constant 32 bit value 0x02 into register %eax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does push <src> do?</src>

A
  • decrements ESP by 4 bytes
  • copies 32-bit operand <src> on top of the stack</src>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does pop <dest> do?</dest>

A
  • copies 4 bytes on the top of the stack to <dest></dest>
  • increments ESP by 4 bytes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly