Module 7 - Summary Exercises

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Suppose that you are given the following data segment and code snippet. What value does EAX contain at Execution Point A? (Ignore the .0000 that Canvas sticks on the end): .data idArray DWORD 1800, 1719, 1638, 1557, 1476, 1395, 1314, 1233, 1152, 1071, 990 idLength DWORD LENGTHOF idArray idSize DWORD SIZEOF idArray idType DWORD TYPE idArray .code main PROC ; ... MOV ESI, OFFSET idArray MOV EAX, [ESI+1*TYPE idArray] ; Execution Point A ; ... exit main ENDP

1,719

Given the following declarations, assume that the memory address of balance is 44h. What is the hexadecimal address of the first element of history? HISTLIMIT = 100 .data balance DWORD 0 account WORD ? history WORD HISTLIMIT DUP(?) isValid BYTE 0

4A How to solve: memory address of balance is 44h and since it is a DWORD we add 4 to the address to get 48h. We then look at account and since it's type is a WORD (16 bits) we add 2 to the address and get 4Ah.

For the following segment, what is SIZEOF myChecker2 in decimal? (ignore the .0000 from Canvas) .data myChecker2 BYTE 12h, 34h, 56h, 78h, 90h

5

Given list, an array of WORDs, what element is addressed by list[8]? 4th Element 8th Element 5th Element 9th Element

5th Element

Suppose that you are given the following partial program.Inside someProcedure, what numerical operand should be used with the RET instruction? (e.g. RET n, what should n be? Ignore any decimal points that Canvas adds) .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

8

Given the following partial data segment declarations and using Indexed Operands addressing, what value would I put in the brackets in MOV EAX, list[?] to move the 25th element of list into EAX? (Ignore the .0000 that Canvas may append to your answer). MAX = 50 .data list DWORD MAX DUP(0) a DWORD 25 b DWORD 15

96 How to solve: we want the 25th element which is at index 24. We multiply 24 by the type of list (which is 4 since DWORDS are 4 bytes). 9*4 = 96

(T/F) The following two instructions are equivalent. RET RET 4

False

When passing procedure parameters on the stack, why are the following lines of code often necessary in a procedure? PUSH EBP MOV EBP, ESP a.) Because the procedure might change the EBP register value. b.) To preserve the original EBP register value for register indirect addressing. c.) To keep additional usage of the stack within the procedure from invalidating the stack offsets. d.) They are never necessary.

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

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? a.) Run-time error b.) The disassembler prevents your program from compiling. c.) You attempt to access whatever data bytes are stored there. d.) Compile-time error

c.) You attempt to access whatever data bytes are stored there.

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 contains the address (OFFSET) of the first element of list.ESI register contains the address (OFFSET) of the eleventh element of list.EBX register contains the value 40. a.) MOV EAX, list[EBX] b.) MOV EAX, list[ESI] c.) MOV EAX, [EDX + EBX] d.) MOV EAX, [ESI]

d.) MOV EAX, [ESI]

The _________ operator returns the size, in bytes, of a single element of a data declaration. OFFSET SIZEOF LENGTHOF TYPE PTR

TYPE

Suppose that you are given the following partial 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 a.) The return address from someProcedure. b.) The previous value of EBP. c.) The decimal value 90. d.) The decimal value 153461. e.) The decimal value 37. f.) None of these. 1.) [ebp + 4] 2.) [ebp + 8] 3.) [ebp + 10] 4.) [ebp + 12] 5.) [ebp] 6.) [ebp + 6]

a.) [ebp + 4] The return address from someProcedure. b.) [ebp + 8] The decimal value 90. c.) [ebp + 10] The decimal value 37. d.) [ebp + 12] The decimal value 153461. e.) [ebp] The previous value of EBP. f.) [ebp + 6] None of these.

Arrays elements are stored in ____________ memory. Contiguous Random Disjoint

Contiguous

Suppose that you are given the following partial data segment. What value does idSize contain, in decimal? (Ignore the .0000 from Canvas) .data idArray WORD 3546, 1534, 12, 3481, 154, 6423 idLength DWORD LENGTHOF idArray idSize DWORD SIZEOF idArray idType DWORD TYPE idArray

12

The following instruction will increment the stack pointer (ESP) by how many bytes? (Ignore the .0 after the number. Canvas insists on pushing decimals even when kindly asked not to). ret 13

17 Why? Because the initial call on the stack (that is being returned to) is 4 bytes. So added together: 13+4 = 17

Suppose that you are given the following partial data segment. What value does idType contain, in decimal? (Ignore the .0000 from Canvas) .data idArray WORD 3546, 1534, 12, 3481, 154, 6423 idLength DWORD LENGTHOF idArray idSize DWORD SIZEOF idArray idType DWORD TYPE idArray

2

Please place the following components of the stack frame in the order in which they should be pushed (or room made for them) on the stack. - Local Variables - Procedure Return Address - Old EBP Value - Passed Parameters - Saved Registers

Answer 1: Passed Parameters Answer 2: Procedure Return Address Answer 3: Old EBP Value Answer 4: Local Variables Answer 5: Saved Registers

The _________ operator returns a count of the number of elements in a single data declaration. OFFSET TYPE PTR SIZEOF LENGTHOF

LENGTHOF

The _________ operator returns a value that is equivalent to multiplying the number of elements in a single data declaration by the size, in bytes, of a single element of a data declaration. PTR SIZEOF OFFSET TYPE LENGTHOF

SIZEOF


Set pelajaran terkait

S3: U5: Pain: Practice Questions

View Set

Series 7 Chapter 14: Economics & Analysis

View Set

Petroleum Engineering Flashcards (Gas Liquification - Seismic)

View Set

Chapter 13: Psychological Disorders

View Set

Culinary Vegetable Classifications

View Set

Unit 5 - Chapter 19 - The Worlds of the North and the South - CONTENT

View Set

Chapter 2: Theory, Research, and Evidence-Informed Practice (Combined)

View Set