CS271 Week 5-7

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

1

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

5

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

4Ah

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

0110h

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

5th Element

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

340

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

658

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

40

Given the following partial data segment, what value would I put in the brackets in list5 5 to access the 11th element of list? (Ignore the .0000 that Canvas may append to your answer). .MAX = 50 .data list DWORD MAX DUP(0) a DWORD 25 b DWORD 15

28

Given the following partial data segment, what value would I put in the brackets in list8 8 to access the 8th element of list? (Ignore the .0000 that Canvas may append to your answer). .MAX = 50 .data list DWORD MAX DUP(0) a DWORD 25 b DWORD 15

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, [edx + ebx] mov eax, [esi] mov eax, list[esi] mov eax, list[ebx]

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, [edx + ebx] mov eax, [esi] mov eax, list[esi] mov eax, list[ebx]

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, [edx + ebx] mov eax, list[ebx] mov eax, list[esi] mov eax, [esi]

6

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 x contains what value, in decimal? (Ignore the .0000 from Canvas)

2

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 z contains what value, in decimal? (Ignore the .0000 from Canvas)

AB907856h

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?

78563412h

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 EAX contains what value, in hexadecimal?

6

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 BYTE 37 z BYTE 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

2

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 BYTE 37 z BYTE 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

PTR

The _________ operator overrides the default type of a label (variable), and can also be used to combine elements of a smaller data type and move them into a larger operand.

LENGTHOF

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

SIZEOF

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.

TYPE

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

12

The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the first number printed to the screen after this code executes? (ignore the .0000 from Canvas) main PROC push 3 push 13 call rcrsn exit main ENDP rcrsn PROC push ebp mov ebp,esp mov eax,[ebp + 12] mov ebx,[ebp + 8] cmp eax,ebx jl recurse jmp quit recurse: inc eax push eax push ebx call rcrsn mov eax,[ebp + 12] call WriteDec Space 2 quit: pop ebp ret 8 rcrsn ENDP

8

The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the first number printed to the screen after this code executes? (ignore the .0000 from Canvas) main PROC push 3 push 9 call rcrsn exit main ENDP rcrsn PROC push ebp mov ebp,esp mov eax,[ebp + 12] mov ebx,[ebp + 8] cmp eax,ebx jl recurse jmp quit recurse: inc eax push eax push ebx call rcrsn mov eax,[ebp + 12] call WriteDec Space 2 quit: pop ebp ret 8 rcrsn ENDP

14

The following instruction will increment the stack pointer (ESP) by how many bytes? ret 10

17

The following instruction will increment the stack pointer (ESP) by how many bytes? ret 13

False

The following two instructions are equivalent. ret ret 4

Activation Record

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

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.

B

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. They are never necessary. B. To keep additional usage of the stack within the procedure from invalidating the stack offsets. C. To preserve the original EBP register value for register indirect addressing. D. Because the procedure might change the EBP register value.

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

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

2 ^ 3 / (5 x 4) + 10

Which of the following infix expressions corresponds to the given postfix expression? 2 3 ^ 5 4 x / 10 +

5 3 + 12 x 3 4 x / 12 +

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

1 2 4 2 - x 4 1 1 + ^ / +

Which of the following postfix expressions corresponds to the given infix expression? 1 + 2 x (4 - 2) / 4 ^ (1 + 1)

56 42 2.6 x 2 x / 256 128 64 - / 3 12 ^ x +

Which of the following postfix expressions corresponds to the given infix expression? 56 / (42 x 2.6 x 2) + (256 / (128 - 64)) x 3 ^ 12

Procedures

Which structure is the following true for? _________ are translated only once, and can be called many times.

Procedures

Which structure is the following true for? _________ have a calling mechanism involving the EIP.

Procedures

Which structure is the following true for? _________ have a return mechanism involving the system stack.

Contiguous

Arrays are stored in ____________ memory.

cld

Clear direction flag

lodsb

Load string byte

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. push LO push HI call RandomRange pop x mov eax,HI sub eax,LO inc eax call RandomRange add eax,LO mov x, eax mov eax,HI call RandomRange mov x,eax mov eax,LO call RandomRange sub x,eax mov eax,HI mov ebx,LO dec ebx sub eax,ebx call RandomRange add eax,LO mov x, eax

03A6h

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)?

ESI

Loading a string byte using string primitives increments or decrements which register?

Accessing memory through an address stored in a register.

Register Indirect addressing is defined as follows:

std

Set direction flag

stosb

Store string byte

1566

Suppose that a program's data and executable code require 1024 bytes of memory. A new section of code must be added; it will be used with various values 53 times during the execution of a program. When implemented as a macro, the macro code requires 79 bytes of memory. When implemented as a procedure, the procedure code requires 118 bytes (including parameter-passing, etc.), and each procedure call requires 8 bytes. How many bytes of memory will the entire program require if the new code is added as a procedure?

7534

Suppose that a program's data and executable code require 1024 bytes of memory. A new section of code must be added; it will be used with various values 62 times during the execution of a program. When implemented as a macro, the macro code requires 105 bytes of memory. When implemented as a procedure, the procedure code requires 151 bytes (including parameter-passing, etc.), and each procedure call requires 11 bytes. How many bytes of memory will the entire program require if the new code is added as a macro?

4E37h

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?

4EABh

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?


Set pelajaran terkait

Chapter 4: Carpeting and Area Rugs

View Set

[MICRO 302] UNIT 4 - SECTION 10 - Microbial Metabolism

View Set

2 lecture: the evolution of quality

View Set