Week 5 Flashcards
How would you find the hexadecimal address of the last item in the following array?
.data
0x44 history WORD 100 DUP(?)
The array effectively spans from 0-198 bytes. So add 0x44 + 198d = 0x10A
What hexadecimal value does EIP hold immediately after “inc EAX” has executed?
0x26 inc EAX
0x2B mov EBX, z
0x30 xor EAX, EBX
0x2B
The following instruction will increment the stack pointer (ESP) by how many bytes?
ret 8
12
The following instruction will increment the stack pointer (ESP) by how many bytes?
ret 2
6
If you reference a point beyond the end of an array i.e. the 101st element of a 100-element array, what happens?
You access whatever data bytes are stored there.
Given the following register states, and using Register Indirect Addressing, how would you move the 11th element of the list array (of DWORDs) to the EAX register?
EDX = the address of list[0]
ESI = address of list[10]
EBX = 40
mov eax, [esi]
Given the following register states, and using Base Indexed Addressing, how would you move the 11th element of the list array (of DWORDs) to the EAX register?
EDX = the address of list[0]
ESI = address of list[10]
EBX = 40
mov eax, [edx + ebx]
Given the following register states, and using Indexed Addressing, how would you move the 11th element of the list array (of DWORDs) to the EAX register?
EDX = the address of list[0]
ESI = address of list[10]
EBX = 40
mov eax, list [ebx]
Given list, an array of WORDs, what element is addressed by list[7]?
4th element
The RET instruction (without operands) will pop how many bytes off the stack?
4
The following two instructions are equivalent:
ret
ret 4
False, the second instruction pops an additional 4 bytes off the stack.
When passing procedure parameters on the stack, why are the following lines of code often necessary?
push ebp
mov ebb, esp
To keep additional usage of the stack within the procedure from invalidating the stack offsets.
Register indirect addressing is defined as?
Indexed Addressing is defined as?
Base Indexed Addressing is defined as?
Register indirect addressing is accessing memory through an address stored in a register. mov esi, OFFSET list mov eax, [esi] add esi, 4 mov eax, [esi]
Indexed addressing is adding a constant to a register to generate an effective address.
mov esi, 0
mov eax, list[esi] ; or [list + esi]
Base Indexed Addressing is accessing lists through the base pointer in procedures.
mov esi, [ebp + 12] ; @list
mov edx, 0
mov eax, [esi + edx] ; gets curr element
What is SIZEOF myChecker (in decimal)?
.data
myChecker BYTE 12h
BYTE 34h
BYTE 56h
SIZEOF = 1
How do you obtain the value of the SIZEOF operator?
Multiply the number of elements in a data declaration by the size in bytes.
What is SIZEOF myChecker (in decimal)?
.data
myChecker BYTE 12h,
34h,
56h
SIZEOF = 3
What is the correct formula to obtain the address of an element in matrix[r][c]?
base address + data size * [(row index * elements/row) + column index]
Loading a string byte using string primitives increments or decrements which register?
ESI
EAX contains what value in hexadecimal?
.data
myList BYTE 12h, 34h, 56h, 78h, 90h, ABh, CDh
.code
mov eax, DWORD PTR [myList + 2]
eax = AB907856h
What is the value in decimal of y?
.data
myList WORD 12h, 34h, 56h, 78h, 90h, ABh
y DWORD SIZEOF myList
y = length * size y = 6 * 2 = 12
What is the value in decimal of x?
.data
myList WORD 12h, 34h, 56h, 78h, 90h, ABh
x DWORD LENGTHOF myList
x = 6
The _____ operator overrides the default type of. a label and can also be used to combine elements of a smaller data type and move them into a larger operand.
PTR
Two dimensional arrays are declared in _____ order in MASM?
row-major
If the string direction flag is not set, string operations will move backwards through the string.
False
Given the following array declaration, how many bytes of memory does array matrix require (in decimal)?
.data
matrix WORD 21 DUP (33 DUP(?))
1386
21 * 33 * 2