Week 7 & 8- 271

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

To keep additional usage of the stack within the procedure from invalidating the stack offsets.

When passing procedure parameters on the stack, why are the following lines of code often necessary in a procedure? push ebp mov ebp,esp

0x1004

data idArray WORD 3546, 1534, 12, 3481, 154, 6423 x DWORD LENGTHOF idArray y DWORD SIZEOF idArray z DWORD TYPE idArray What is the hexadecimal OFFSET of the number "12" in idArray?

0x2B

uppose that you are given the following program (with memory addresses shown on the left). What hexadecimal value does EIP hold immediately after "inc EAX" has executed? .data 0x100 x DWORD 153461 0x104 y WORD 37 0x105 z WORD 90 .code main PROC 0x12 push x 0x17 mov AX, y 0x1C shl AX, 16 0x1C mov AX, z 0x21 call someProcedure 0x26 inc EAX 0x2B mov EBX, z 0x30 xor EAX, EBX 0x35 exit main ENDP END MAIN

5th Element

Given list, an array of WORDs, what element is addressed by list[8]? Hint: It's Love.

0x0380

What is the (hexadecimal) address of the 33rd element of list?

False

When passing parameters to a procedure on the stack, it is usually okay to change the value of the EBP register within the procedure.

Contiguous

Arrays are stored in ____________ memory.

mov eax,HI mov ebx,LO dec ebx sub eax,ebx call RandomRange add eax,LO mov x, eax mov eax,HI sub eax,LO inc eax call RandomRange add eax,LO mov x, eax

Assume that LO and HI have already been assigned as constants with LO < HI, and x has been declared as DWORD in the data segment. Also, Irvine's library is included, and Randomize has already been called. Which of the following code fragments will assign to x a "random" integer in the range [LO .. HI]? Check all that apply.

0x03A6

Assume that your program has access to the following data segment (starting at address 0x310): .data id DWORD 7 matrix WORD 50 DUP(10 DUP(?)) What is the hexadecimal address of matrix[7][3] (the 4th element of the 8th row)?

0x434

Assume that your program has access to the following data segment (starting at address 0x310): .data id DWORD 7 matrix WORD 50 DUP(10 DUP(?)) What is the hexadecimal address of matrix[7][3] (the 4th element of the 8th row)?

0x4A

For this problem, suppose that you are working with the partial data segment given below. Assume that the memory address of balance is 0x44. What hexadecimal address belongs to the first item in history? HISTLIMIT = 100 .data balance DWORD 0 account WORD ? history WORD HISTLIMIT DUP(?) isValid BYTE 0

0x110

For this problem, suppose that you are working with the partial data segment given below. Assume that the memory address of balance is 0x44. What hexadecimal address belongs to the last item in history? HISTLIMIT = 100 .data balance DWORD 0 account WORD ? history WORD HISTLIMIT DUP(?) isValid BYTE 0

480

Given the following array declaration, how many bytes of memory does array matrix require? (in decimal - ignore the .0000 from Canvas) .data matrix WORD 12 DUP(20 DUP(?))

1808

Given the following array declaration: .data matrix DWORD 50 DUP(10 DUP(?)) If matrix[0][0] is the 0th sequentially stored BYTE in memory, which sequentially stored BYTE is the first byte corresponding to matrix[45][2]? (in decimal - ignore the .0000 from Canvas)

0x220

Given the following partial data segment, which starts at address 0x0200 : .data list DWORD 1, 2, 6, 24, 120, 720, 5040, 40320 x DWORD LENGTHOF list y DWORD SIZEOF list Show addresses in 4-digit hexadecimal. Show contents in decimal. the address of x is

32

Given the following partial data segment, which starts at address 0x0200 : .data list DWORD 1, 2, 6, 24, 120, 720, 5040, 40320 x DWORD LENGTHOF list y DWORD SIZEOF list Show addresses in 4-digit hexadecimal. Show contents in decimal. . 2 y contains

8

Given the following partial data segment, which starts at address 0x0200 : .data list DWORD 1, 2, 6, 24, 120, 720, 5040, 40320 x DWORD LENGTHOF list y DWORD SIZEOF list Show addresses in 4-digit hexadecimal. Show contents in decimal. 1. x contains

mov eax, [edx + ebx]

Given the following register states, and using Base Indexed Addressing, which of the following lines of code will move the 11th element of the list array (of DWORDs) to the EAX register? EDX register contans the address of the first element of list. ESI register contains the address of the eleventh element of list. EBX register contains the value 40,

mov eax, list[ebx]

Given the following register states, and using Indexed Addressing, which of the following lines of code will move the 11th element of the list array (of DWORDs) to the EAX register? EDX register contans the address of the first element of list. ESI register contains the address of the eleventh element of list. EBX register contains the value 40,

mov eax, [esi]

Given the following register states, and using Register Indirect Addressing, which of the following lines of code will move the 11th element of the list array (of DWORDs) to the EAX register? EDX register contans the address of the first element of list. ESI register contains the address of the eleventh element of list. EBX register contains the value 40,

mov eax, [ebp + 16]

Here is a partial "listing file" that uses the data segment above: 00000000 main PROC 00000000 push a 00000005 push b 0000000A push OFFSET list 0000000F call someProc 00000014 next ... exit ;exit to operating system 0000006C main ENDP 0000006C someProc PROC 0000006C push ebp 0000006F mov ebp, esp 00000072 etc ... 0000008B C3 ret ;return to calling procedure 0000008C someProc ENDP Write a statement to move the value of actual parameter a into the eax register. (Global name a is not permitted.)

MOV ESI, [EBP + 8] ; move the OFFSET of list into ESI MOV EAX, 4 ; there are 4 bytes per DWORD MOV EBX, [EBP + 12] ; move the value of b into EBX MUL EBX ; Multiply EAX by b to (almost) get the offset to the bth element SUB EAX, 4 ; eax now holds the offset from ESI to the bth element of list MOV EBX, [ESI+EAX] ; move the element into EBX

Here is a partial "listing file" that uses the data segment above: 00000000 main PROC 00000000 push a 00000005 push b 0000000A push OFFSET list 0000000F call someProc 00000014 next ... exit ;exit to operating system 0000006C main ENDP 0000006C someProc PROC 0000006C push ebp 0000006F mov ebp, esp 00000072 etc ... 0000008B C3 ret ;return to calling procedure 0000008C someProc ENDP Write the statements to move the value of the bth element of list into the ebx register. (Consider b=0 to be the 1st element of list) (Global names b and list are not permitted.)

0x09F0

Here is a partial "listing file" that uses the data segment above: 00000000 main PROC 00000000 push a 00000005 push b 0000000A push OFFSET list 0000000F call someProc 00000014 next ... exit ;exit to operating system 0000006C main ENDP 0000006C someProc PROC 0000006C push ebp 0000006F mov ebp, esp 00000072 etc ... 0000008B C3 ret ;return to calling procedure 0000008C someProc ENDP ebp contains

0x03C8

Here is a partial data segment: MAX = 50 .data ... list DWORD MAX DUP(0) a DWORD 25 b DWORD 15 ... Given: the address of list is 0x0300. a. What is the (hexadecimal) address of a?

False

If the string direction flag is not set, string operations will move backward through the string.

You attempt to access whatever data bytes are stored there.

If you reference a point beyond the end of an array in MASM (for example, the address of the what would be the 105th element of a 100-element array), what happens?

lodsb

Load string byte

False

MASM will throw an error when assembling the following data segment: .data myChecker BYTE 12h BYTE 34h BYTE 56h BYTE 78h BYTE 90h

Accessing memory through an address stored in a register.

Register Indirect addressing is defined as follows:

stosb

Store string byte

0x4EAB

Suppose that you are given the following MASM data segment declarations: .data idNumber BYTE ? status WORD 0 list DWORD 42 DUP(?) count DWORD ? The address of idNumber is 0x4E00. What is the hexadecimal address of count?

0x4E37

Suppose that you are given the following MASM data segment declarations: .data idNumber BYTE ? status WORD 0 list DWORD 42 DUP(?) count DWORD ? The address of idNumber is 0x4E00. What is the hexadecimal address of the 14th element of list?

1800.0

Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719, 1638, 1557, 1476, 1395, 1314, 1233, 1152, 1071, 990 u DWORD LENGTHOF idArray v DWORD SIZEOF idArray What value does EAX contain after the following code has executed? (Ignore the .0000 that Canvas sticks on the end) mov esi, OFFSET idArray mov eax, [esi+0*TYPE idArray]

1476

Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719, 1638, 1557, 1476, 1395, 1314, 1233, 1152, 1071, 990 u DWORD LENGTHOF idArray v DWORD SIZEOF idArray What value does EAX contain after the following code has executed? (Ignore the .0000 that Canvas sticks on the end) mov esi, OFFSET idArray mov eax, [esi+4*TYPE idArray]

12

Suppose that you are given the following partial data segment, which starts at address offset 0x1000 : .data idArray WORD 3546, 1534, 12, 3481, 154, 6423 x DWORD LENGTHOF idArray y DWORD SIZEOF idArray z DWORD TYPE idArray y contains what value, in decimal? (Ignore the .0000 from Canvas)

0xAB907856

Suppose that you are given the following partial data segment: .data myPtrCheck BYTE 12h, 34h, 56h, 78h, 90h, ABh, CDh, EFh .code ... mov eax, DWORD PTR [myPtrCheck+2] EAX contains what value, in hexadecimal?

[ebp + 4] the return address from someProcedure [ebp + 8] Decimal value 90 [ebp + 10] Decimal value 37 [ebp + 12] Decimal value 153461 [ebp] previous value of ebp [ebp + 6] none

Suppose that you are given the following program. After the instruction "mov ebp, esp", which of the following is referenced by each of the following? .data x DWORD 153461 y WORD 37 z WORD 90 .code main PROC push x push y push z call someProcedure ... exit main ENDP someProcedure PROC push ebp mov ebp, esp ... pop ebp ret 8 someProcedure ENDP END MAIN

8

Suppose that you are given the following program. Inside someProcedure, what numerical operand should be used with the RET instruction? .data x DWORD 153461 y WORD 37 z WORD 90 .code main PROC push x push y push z call someProcedure inc EAX mov EBX, z xor EAX, EBX exit main ENDP END MAIN

4

Suppose that you are given the following program. Inside someProcedure, what numerical operand should be used with the RET instruction? .data x DWORD 153461 y WORD 37 z WORD 90 .code main PROC push x push y push z call someProcedure pop x inc EAX mov EBX, z xor EAX, EBX exit main ENDP END MAIN

4

The RET instruction (without operands) will pop how many bytes off the stack?

EIP

The RET instruction pops the top of the stack into what register?

LENGTHOF

The _________ operator returns a count of the number of elements in a single data declaration.

TYPE

The _________ operator returns the size, in bytes, of a single element of a data declaration.

Activation Record

The stack frame inside a procedure is also known as the ____________.

finit fld A fld B fadd fld C fsub fld D fdiv fld E fmul fstp Z

Which of the following FPU manipulations corresponds to the given infix notation? Z = (A + B - C) / D * E

3 * 3 - 5 / (4 * 2)

Which of the following infix expressions corresponds to the given postfix expression? 3 3 * 5 4 2 * / -

3 - 4 - (3 ^ (2 + 4)) - 2

Which of the following infix expressions corresponds to the given postfix expression? 3 4 - 3 2 4 2 - + ^ -

BaseAddress + elementSize * [(r * elementsPerRow) + c])

Which of the following is the correct addressing formula for matrix index M(r,c)?

1 4 2 / + 1 + 2 + 3 * 2 /

Which of the following postfix expressions corresponds to the given infix expression? (1 + 4 / 2 + 1 + 2) * 3 / 2

13 14 + 3 - 2 + 2 3 ^ /

Which of the following postfix expressions corresponds to the given infix expression? (13 + 14 - 3 + 2) / 2 ^ 3

5 3 + 12 * 3 4 * / 12 +

Which of the following postfix expressions corresponds to the given infix expression? (5 + 3) * 12 / (3 * 4) + 12

cld

clear directional flag

std

set directional flag


संबंधित स्टडी सेट्स

Saunders Integumentary Problems (Ch 43) Practice Questions

View Set

eegoo Part 19 부정사 형용사용법

View Set

Babylonian and Assyrian Civilization

View Set

Chapter 3 : PRENATAL DEVELOPMENT AND BIRTH

View Set

Geometry Review: TEST NEXT TUESDAY MUST STUDY!!!!!!

View Set

EOC17: End of Chapter Problems - Ch. 17: Public Goods and Common Resources

View Set