COMSC260 Quiz 2, COMSC260 Quiz 3, COSMC260 Quiz 4, COMSC260 Quiz 5, COMSC 260 Quiz 6, COMSC 260 Quiz 7, COMSC 260 Quiz 8, COMSC 260 Test 1, COMSC 260 Quiz 9, COMSC 260 Quiz 10, COMSC 260 QUIZ 11, COMSC 260 Quiz 12, COMSC 260 Quiz 13, COMSC 260 Test 2

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

Which of the options below will: 1) store 6 in eax 2) store 3 in ebx ------------------------------------- D-) .data arr WORD 99, 51, 73 23, 47, 61 17, 89, 93 .code mov eax, LENGTHOF arr mov ebx, SIZEOF arr ------------------------------------- C-) .data arr WORD 99, 51, 73 23, 47, 61 17, 89, 93 .code mov eax, SIZEOF arr mov ebx, LENGTHOF arr ------------------------------------- B-) .data arr WORD 99, 51, 73 WORD 23, 47, 61 WORD 17, 89, 93 .code mov eax, LENGTHOF arr mov ebx, SIZEOF arr ------------------------------------- A-) .data arr WORD 99, 51, 73 WORD 23, 47, 61 WORD 17, 89, 93 .code mov eax, SIZEOF arr mov ebx, LENGTHOF arr

A-) .data arr WORD 99, 51, 73 WORD 23, 47, 61 WORD 17, 89, 93 .code mov eax, SIZEOF arr mov ebx, LENGTHOF arr

The _ bus is used for synchronization. Control Data Address I/O

Control

Suppose a program has the following memory layout: *Relative Address Value* 0000 'A' (ASCII code 41h) 0001 'B' (ASCII code 42h) 0002 'C' (ASCII code 43h) 0003 'D' (ASCII code 44h) 0004 'E' (ASCII code 45h) 0005 'F' (ASCII code 46h) 0006 'G' (ASCII code 47h) 0007 'H' (ASCII code 48h) All of the following data segments would result in this memory layout *EXCEPT*: A-) someval WORD 4241h, 4443h someval2 BYTE 45h, 46h, 47h, 48h B-) Someval BYTE 41h, 42h someval2 WORD 4443h, 4645h, 4847h C-) someval DWORD 44434241h someval2 WORD 4645h, 4847h D-) *someval WORD 4241h, 4443h* *someval2 DWORD 45464748h*

D-) *someval WORD 4241h, 4443h* *someval2 DWORD 45464748h*

Which of the options below will store the two's complement of A1h in register al? B-) mov al, 00Fh mov bl, 0A1h sub al, bl add al, 1 A-) mov al, 00Fh mov bl, 0A1h sub al, bl sub al, 1 D-) mov al, 0FFh mov bl, 0A1h sub al, bl add al, 1 C-) mov al, 0FFh mov bl, 0A1h sub al, bl sub al, 1

D-) mov al, 0FFh mov bl, 0A1h sub al, bl add al, 1

Which of the options below is the correct truth table for the logical *AND* operator? ----------------------- P Q P AND Q F F F F T F T F F T T T

P Q P AND Q F F F F T F T F F T T T

Which of the options below is the correct truth table for the logical AND operator? ----------------------- P Q P AND Q F F F F T F T F F T T T

P Q P AND Q F F F F T F T F F T T T

Which of the options below is the correct truth table for the logical *OR* operator? ----------------------- P Q P OR Q F F F F T T T F T T T T

P Q P OR Q F F F F T T T F T T T T

Which of the options below is the correct truth table for the logical OR operator? ----------------------- P Q P OR Q F F F F T T T F T T T T

P Q P OR Q F F F F T T T F T T T T

Suppose a program has the following data segment: .data A BYTE 4 B BYTE 5 result BYTE ? Which of the options below will store the value 20 in the result variable? (the value 20 is also the product of the two numbers: A * B = 4 * 5 = 20) mov al, B add al, B add al, B add al, B add al, B mov result, al --------------------- mov al, B add al, B add al, B add al, B mov result, al --------------------- add al, B add al, B add al, B add al, B add al, B mov result, al --------------------- add al, B add al, B add al, B add al, B mov result, al

mov al, B add al, B add al, B add al, B mov result, al

Which of the following options below describes the correct algorithm for converting an *UN*signed decimal number to binary? 1. Divide the number by 2 2. Calculate and store the quotient 3. Calculate and store the remainder 4. Set number = _ 5. If the _ is not equal to 0, go back to step 1, else go to step 6 6. The binary number is stored in the remainder ----------------------------- 4. remainder 5. quotient 4. quotient 5. remainder 4. remainder 5. remainder *4. quotient* *5. quotient*

*4. quotient* *5. quotient*

var1 BYTE 7 dup("COMSC 260") How many bytes is var1? 7 14 *63* 126

*63*

Which of the options below is the *largest SIGNED* hexadecimal number that you can make with two (2) hexadecimal symbols ----------------------- *7F* 8F FF 0F

*7F*

Which of the options below is the largest SIGNED hexadecimal number that you can make with two (2) hexadecimal symbols ----------------------- *7F* 8F FF 0F

*7F*

How many bits are in a byte? ----------------------------- 32 *8* 16 64

*8*

Which of the options below is the *smallest SIGNED* hexadecimal number that you can make with two (2) hexadecimal symbols? ----------------------- 00 *80* 7F FF

*80*

Suppose a program has the following data segment: arrB BYTE 01h, 23h, 45h, 67h, 89, 0ABh, 0CDh, 0EFh Which of the following instructions below will move AB896745h into eax? C-) mov ax, DWORD PTR [arrB+5] B-) mov eax, DWORD PTR [arrB+3] D-) mov eax, DWORD PTR [arrB+6] *A-) mov eax, DWORD PTR [arrB+2]*

*A-) mov eax, DWORD PTR [arrB+2]*

What is the logic behind the loop instruction? ------------------ C-) 1. ECX = ECX - 1 2. if ECX > 0, jump to target ------------------ B-) 1. if ECX != 0, jump to target 2. ECX = ECX - 1 ------------------ D-) 1. if ECX > 0, jump to target 2. ECX = ECX - 1 ------------------ *A-)* *1. ECX = ECX - 1* *2. if ECX != 0, jump to target*

*A-)* *1. ECX = ECX - 1* *2. if ECX != 0, jump to target*

Suppose a program is supposed to reverse an array. Part of the program is as follows: .data array DWORD 1,5,6,8,0Ah,1Bh,1Eh,22h,2Ah,32h .code mov edx, 0 L1: mov eax, array[edx] xchg eax, array[ebx] mov array[edx], eax add edx, TYPE array sub ebx, TYPE array loop L1 For this program to work correctly, ebx and ecx must both be initialized correctly. Which of the options below correctly initializes *both* registers? C-) mov ebx, SIZEOF array - TYPE array mov ecx, LENGTHOF array / 2 - 1 D-) mov ebx, SIZEOF array - TYPE array - 4 mov ecx, LENGTHOF array / 2 - 1 *A-)* *mov ebx, SIZEOF array - TYPE array* *mov ecx, LENGTHOF array / 2* B-) mov ebx, SIZEOF array - TYPE array - 4 mov ecx, LENGTHOF array / 2

*A-)* *mov ebx, SIZEOF array - TYPE array* *mov ecx, LENGTHOF array / 2*

All of the options below will cause an infinite loop* EXCEPT*: Here "infinite loop" means either a loop that literally never ends, or a loop that does eventually end but has many, many..... many more iterations than it normally should have (e.g., billions of loop iterations). C-) mov ecx, -1 L1: mov eax, ecx inc ecx loop L1 *A-)* *mov ecx, 0* *L1:* *mov eax, ecx* *inc ecx* *loop L1* D-) mov ecx, -1 L1: mov eax, ecx dec ecx loop L1 B-) mov ecx, 0 L1: mov eax, ecx dec ecx loop L1

*A-)* *mov ecx, 0* *L1:* *mov eax, ecx* *inc ecx* *loop L1*

All of the following are part of the CPU (Central Processing Unit) *EXCEPT*: -------------------- *Address Bus* General Registers Control Unit Internal Clock

*Address Bus*

When a loop instruction is encountered, and the jump is taken, which register is affected by the jump? *B-) EIP * A-) ESI C-) ESP D-) EBP

*B-) EIP *

Suppose a program has the following data segment: .data arr BYTE 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 And the goal is to change second value in the array to 99. After the program has finished arr should be: [1, *99*, 3, 4, 5, 6, 7, 8, 9, 10] Which of the options below is the correct implementation of the program? D-) mov [arr+SIZEOF arr - (SIZEOF arr -2)], 99 *B-) mov [arr+SIZEOF arr - (SIZEOF arr -1)], 99 * C-) mov [arr+SIZEOF arr - SIZEOF arr -2], 99 A-) mov [arr+SIZEOF arr - SIZEOF arr -1], 99

*B-) mov [arr+SIZEOF arr - (SIZEOF arr -1)], 99 *

Suppose a program has the following data segment: .data valA BYTE 1h valB BYTE 2h, 3h, 4h, 5h Which of the following mov instructions will store 4h in register al? D-) mov al, [valA+12] *B-) mov al, [valA+3] * C-) mov al, [valA+8] A-) mov al, [valA+2]

*B-) mov al, [valA+3] *

The relative offset used for jumping in a loop instruction is encoded by a single byte. What is the largest possible backward jump? What is the largest possible forward jump? *B-)* *1. -128* *2. +127* D-) 1. -128 2. +128 C-) 1. -127 2. +127 A-) 1. -127 2. +128

*B-)* *1. -128* *2. +127*

Suppose the following is declared in the data segment: .data val1 WORD 2h, 1h All of the options below will move the number 2 into al EXCEPT: B-) mov al, TYPE val1 *C-) mov al, SIZEOF val1* A-) mov al, BYTE PTR val1 D-) mov al, LENGTHOF val1

*C-) mov al, SIZEOF val1*

Which of the following options below will 1) Produce the largest sum (and store it in al) *AND* 2) *NOT* produce a carry out of the MSB (most significant bit)? HINT: How many bits are registers al and bl? *mov al, 254 * *mov bl, 1 * *add al, bl* mov al, 255 mov bl, 1 add al, bl mov al, 126 mov bl, 1 add al, bl mov al, 127 mov bl, 1 add al, bl

*mov al, 254 * *mov bl, 1 * *add al, bl*

Which of the following options below will produce a carry out of the MSB (most significant bit)? *HINT*: How many bits are registers al and bl? mov al, 126 mov bl, 1 add al, bl *mov al, 255 * *mov bl, 1 * *add al, bl* mov al, 127 mov bl, 1 add al, bl mov al, 254 mov bl, 1 add al, bl

*mov al, 255 * *mov bl, 1 * *add al, bl*

What are the three steps of the instruction execution cycle in the correct order? -------------------- 1. Decode 2. Fetch 3. Execute -------------------- 1. Fetch 2. Execute 3. Decode -------------------- 1. Fetch 2. Decode 3. Execute -------------------- 1. Execute 2. Fetch 3. Decode

1. Fetch 2. Decode 3. Execute

AB + CD What is the sum of the hexadecimal numbers shown above? ------------------- *178* 189 F79 F58

*178*

Suppose n = number of bits. Which of the options below is the correct formula that will give you the *largest UN*signed binary number that you can represent for a given number of bits? ----------------------------- 2^(n-1) - 1 2^(n) + 1 *2^(n) - 1* 2^(n+1) + 1

*2^(n) - 1*

What is the *largest UN*signed number that you can make with five (5) bits? ----------------------------- *31* 32 16 15

*31*

X DWORD 12000000h, 34000000h, 56000000h, 78000000h, 9A000000h, 0B000000h, 0C000000h, 0D000000h, 0E000000h, 0F000000h How many bits is X? -------------------- 80 *320* 160 640

*320*

Suppose we want to represent the decimal number *65* as an *UN*signed binary number using the *least* number of bits possible. Which of the options below is correct? ----------------------------- 10000001 010000001 01000001 *1000001*

*1000001*

What is the largest SIGNED number that can be represented with 8 binary bits? ------------------- 128 256 255 *127*

*127*

What is the *UN*signed hexadecimal number 80 converted to decimal? ----------------------------- -128 -256 *128* 256

*128*

Which of the options below will cause al to store 0? C-) mov al, 255 add al, 1 D-) mov al, 256 add al, 1 B-) mov al, 128 add al, 1 A-) mov al, 127 add al, 1

C-) mov al, 255 add al, 1

Which of the options below is the largest UNsigned hexadecimal number that you can make with two (2) hexadecimal symbols ----------------------------- 8F 7F 0F FF

FF

Which of the following is the correct SIGNED hexadecimal representation of -6? FFA 1FA 11A F1A

FFA

Suppose n = number of hexadecimal symbols. Which of the options below is the correct formula that will give you the largest UNsigned hexadecimal number that you can represent for a given number of hexadecimal symbols? ----------------------------- 16^(n-1) - 1 16^(n)+ 1 16^(n+1) + 1 *16^(n) - 1*

*16^(n) - 1*

When adding hexadecimal numbers together in a column, what two steps are performed if their sum is greater than 15? 1. What you put down in the column is calculated by the formula: _ 2. Carry a 1 over to the next column ------------------- 1. sum = 15 mod sum *1. sum = sum mod 16* 1. sum = 16 mod sum 1. sum = sum mod 15

*1. sum = sum mod 16*

When adding binary numbers together in a column, what two steps are performed if their sum is greater than 1? 1. What you put down in the column is calculated by the formula: _ 2. Carry a 1 over to the next column HINT: 1 + 1 = 10 1 + 1 + 1 = 11 ----------------------------- 1. sum = 2 mod sum 1. sum = 1 mod sum 1. sum = sum mod 1 *1. sum = sum mod 2*

*1. sum = sum mod 2*

What are the two steps to get the two's complement of a hexadecimal number? 1. For each hexadecimal symbol i, perform: _ 2. _ ----------------------- *1. flipped_hex[i] = 15 - hex[i]* *2. Add 1* 1. flipped_hex[i] = hex[i] - 15 2. Subtract 1 1. flipped_hex[i] = hex[i] - 15 2. Add 1 1. flipped_hex[i] = 15 - hex[i] 2. Subtract 1

*1. flipped_hex[i] = 15 - hex[i]* *2. Add 1*

What is the formula for finding the largest SIGNED binary value for a given number of bits? Note: N represents the number of bits in the formula ------------------- (2^N) - 1 2^N 2^(N-1) *(2^(N-1)) - 1*

*(2^(N-1)) - 1*

What is the *SIGNED* binary number 10000000 converted to decimal? ------------------- *-128* 128 256 -256

*-128*

What is the SIGNED hexadecimal number 80 converted to decimal? ----------------------- -256 256 128 *-128*

*-128*

What is the smallest *SIGNED* number that can be represented with 8 binary bits? ------------------- -255 -127 -256 *-128*

*-128*

What is the range of values for a *SIGNED 6-bit* binary number? -31 to +31 *-32 to+31* -31 to +32 -32 to +32

*-32 to+31*

.data val1 BYTE ? val2 WORD ? val3 WORD ? val4 WORD ? Assuming the data segment starts at 0000 0000: mov esi, OFFSET val4 Which address would the above instruction move into esi? 0000 000A *0000 0005* 0000 0006 0000 0009

*0000 0005*

X DWORD 87654321h How is X stored in memory? -------------------- *0000: 21* *0001: 43* *0002: 65* *0003: 87* 0000: 78 0001: 56 0002: 34 0003: 12 0000: 87 0001: 65 0002: 43 0003: 21 0000: 12 0001: 34 0002: 56 0003: 78

*0000: 21* *0001: 43* *0002: 65* *0003: 87*

X WORD 1A2Bh, 3C4Dh, 5E6Fh How is X stored in memory? 0000: F6 0001: E5 0002: D4 0003: C3 0004: B2 0005: A1 *0000: 2B* *0001: 1A* *0002: 4D* *0003: 3C* *0004: 6F* *0005: 5E* 0000: B2 0001: A1 0002: D4 0003: C3 0004: F6 0005: E5 0000: 6F 0001: 5E 0002: 4D 0003: 3C 0004: 2B 0005: 1A

*0000: 2B* *0001: 1A* *0002: 4D* *0003: 3C* *0004: 6F* *0005: 5E*

Suppose we have the following *UN*signed binary number: 10 And we want to *sign-extend* this binary number to four binary bits. The binary number *MUST* have the same value, but now it will be four binary bits rather than two. Which of the options below is correct? ----------------------------- 0110 *0010* 1010 1110

*0010*

Suppose we want to represent the decimal number *19* as a *SIGNED* binary number using the least number of bits possible. Which of the options below is correct? ----------------------- 10011 0100011 *010011* 100011

*010011*

Suppose we have run through the *signed* decimal -> *signed* hexadecimal conversion algorithm. The original decimal number that we wanted to convert to hexadecimal was a *NEGATIVE* number, but we ran through the algorithm with the positive equivalent (e.g., if the decimal number was -26 then we would run through the algorithm with +26, etc.). After building the table, suppose we have *7* for the *MSH* in the remainder column of the table: 1. We *must* to add a leading 0 to the hexadecimal number in the remainder column of the table. For example, if the hexadecimal number in the remainder column of the table is 7C, then we need to make it *0*7C. 2. After evaluating statement number 1 above, the result needs to be run through two's complement.* * NOTE: If you answered false for statement number 1, then "the result" would mean just the number from the remainder column of the table. If you answered true for statement number 1, then "the result" would mean a leading 0 followed by the number from the remainder column of the table. ----------------------- 1. True 2. False 1. True 2. True 1. False 2. False *1. False* *2. True*

*1. False* *2. True*

What are the three steps of the instruction execution cycle in the correct order? -------------------- 1. Decode 2. Fetch 3. Execute 1. Fetch 2. Execute 3. Decode *1. Fetch * *2. Decode * *3. Execute* 1. Execute 2. Fetch 3. Decode

*1. Fetch * *2. Decode * *3. Execute*

To do the subtraction A - B between two binary numbers, we can: 1) Do the addition A + -B 2) Discard the carry out of the MSB if there is one ----------------------- 1. False 2. True *1. True* *2. True* 1. False 2. False 1. True 2. False

*1. True* *2. True*

What are the two steps to get the *two's complement* of a binary number? 1. For each binary bit i, perform: _ 2. ____ ------------------- 1. flipped_bit[i] = bit[i] - 1 2. Subtract 1 1. flipped_bit[i] = bit[i] - 1 2. Add 1 1. flipped_bit[i] = 1 - bit[i] 2. Subtract 1 *1. flipped_bit[i] = 1 - bit[i]* *2. Add 1*

*1. flipped_bit[i] = 1 - bit[i]* *2. Add 1*

Which of the options below is the *smallest SIGNED* binary number that you can make with six (6) bits? ------------------- 011111 *100000* 111111 000000

*100000*

Suppose a program is supposed to swap adjacent pairs in an array that always has an even number of elements. For example the array [1, 2, 3, 4, 5, 6, 7, 8] would become [2, 1, 4, 3, 6, 5, 8, 7] The start of the program is as follows: .data array WORD 1,2,3,4,5,6,7,8,9,10 .code main PROC mov esi,0 mov ecx, LENGTHOF array / 2 Which of the options below is the correct continuation of the program? --------------------------------------- D-) L1: mov ax, array[esi] xchg ax, array[esi+4] mov array[esi], ax add esi, 4 loop L1 --------------------------------------- *C-)* *L1:* * mov ax, array[esi]* * xchg ax, array[esi+2]* * mov array[esi], ax* * add esi, 4* * loop L1* --------------------------------------- A-) L1: mov ax, array[esi] xchg ax, array[esi+2] mov array[esi], ax add esi, 2 loop L1 --------------------------------------- B-) L1: mov ax, array[esi] xchg ax, array[esi+4] mov array[esi], ax add esi, 2 loop L1

*C-)* *L1:* * mov ax, array[esi]* * xchg ax, array[esi+2]* * mov array[esi], ax* * add esi, 4* * loop L1*

The _ bus is used for synchronization. -------------------- Data I/O Address *Control*

*Control*

_ RAM is known as main memory. -------------------- CMOS S V *D*

*D*

Suppose a program has the following data segment: arrB BYTE 1, 1, 1, 1, 1, 1 And then the following instructions are executed in the code segment: mov al, [arrB+1] add al, arrB mov [arrB+2], al mov al, [arrB+2] add al, [arrB+1] mov [arrB+3], al What does arrB look like after these instructions have executed? A-) [1, 2, 2, 1, 1, 1] B-) [1, 1, 2, 2, 1, 1] C-) [1, 2, 3, 1, 1, 1] *D-) [1, 1, 2, 3, 1, 1] *

*D-) [1, 1, 2, 3, 1, 1] *

Which of the options below meets *BOTH* of the following criteria: The loop is a *pretest* loop. This means the condition for the loop is checked *BEFORE* executing the body of the loop. The body of the loop (i.e., add eax, eax) is executed exactly five times. ------------------------- *D-)* *mov eax, 0* *mov ecx, 6* *jmp L2* *L1:* * add eax, eax* *L2: * loop L1* ------------------------- B-) mov eax, 0 mov ecx, 5 jmp L2 L1: add eax, eax L2: loop L1 ------------------------- A-) mov eax, 0 mov ecx, 5 jmp L1 L1: add eax, eax L2: loop L1 ------------------------- C-) mov eax, 0 mov ecx, 6 jmp L1 L1: add eax, eax L2: loop L1

*D-)* *mov eax, 0* *mov ecx, 6* *jmp L2* *L1:* * add eax, eax* *L2:* * loop L1*

Suppose a program has the following data segment: source BYTE "ASSEMBLY", 0 target BYTE LENGTHOF source dup('#') Which of the options below will move the *address* of the "L" into *BOTH* eax *AND* ebx? A-) mov eax, OFFSET source + SIZEOF source -2 mov ebx, OFFSET target - 3 B-) mov eax, OFFSET source + SIZEOF source -3 mov ebx, OFFSET target - 2 C-) mov eax, OFFSET source + SIZEOF source -2 mov ebx, OFFSET target - 2 *D-)* *mov eax, OFFSET source + SIZEOF source -3* *mov ebx, OFFSET target - 3*

*D-)* *mov eax, OFFSET source + SIZEOF source -3* *mov ebx, OFFSET target - 3*

Suppose a program is supposed to calculate the sum of the *gaps* in an array. For example, for the array [0, 2, 5, 9, 10], the sum of the *gaps* is 2+3+4+1 = 10. The start of this program is as follows: .data dwarray dword 0,2,5,9,10 count = LENGTHOF dwarray result dword ? .code mov ebx, 0 mov edx, 0 Which of the options below will correctly continue the program and store the sum of the *gaps* in the array in the result variable? *D-)* *mov ecx, count - 1* *L1:* * mov eax, dwarray[ebx+4]* * sub eax, dwarray[ebx]* * add edx, eax* * add ebx, TYPE dwarray* * loop L1* *mov result, edx* -------------------------------------- C-) mov ecx, count L1: mov eax, dwarray[ebx+4] sub eax, dwarray[ebx] add edx, eax add ebx, TYPE dwarray loop L1 mov result, edx -------------------------------------- A-) mov ecx, count L1: mov eax, dwarray[ebx] sub eax, dwarray[ebx+4] add edx, eax add ebx, TYPE dwarray loop L1 mov result, edx -------------------------------------- B-) mov ecx, count - 1 L1: mov eax, dwarray[ebx] sub eax, dwarray[ebx+4] add edx, eax add ebx, TYPE dwarray loop L1 mov result, edx

*D-)* *mov ecx, count - 1* *L1:* * mov eax, dwarray[ebx+4]* * sub eax, dwarray[ebx]* * add edx, eax* * add ebx, TYPE dwarray* * loop L1* *mov result, edx*

Which register is the frame pointer? -------------------- ESP EDI *EBP* EIP

*EBP*

Which register is used to keep track of loop iterations? -------------------- ESI *ECX* EDI EDX

*ECX*

What is the *two's complement* of the *hexadecimal* number 101101? ----------------------- 010010 EFEEFE *EFEEFF* 010011

*EFEEFF*

Which register is used to store the address of the next instruction that will be executed? -------------------- EDI *EIP* EBP ESI

*EIP*

Which of the options below is the *largest UN*signed hexadecimal number that you can make with two (2) hexadecimal symbols ----------------------------- 8F 7F 0F *FF*

*FF*

Which of the following is the correct *SIGNED* hexadecimal representation of -6? ----------------------- *FFA* 11A F1A 1FA

*FFA*

_ ExitProcess, 0 notifies the operating system that the program has successfully finished in a 32-bit mode program. -------------------- *INVOKE* JMP RETURN CALL

*INVOKE*

Which of the following options below is the correct way to end a string with the null terminator character? Text BYTE "Hello World", '0' *Text BYTE "Hello World", 0* Text BYTE "Hello World", \0 Text BYTE "Hello World", "0"

*Text BYTE "Hello World", 0*

Which of the following options below represents a 16 bit unsigned integer? FWORD DWORD QWORD *WORD*

*WORD*

Which of the following options below is the correct way to do a line return (new line) in x86 assembly language? line_return BYTE 0Ah, 0Dh line_return BYTE 0Ah, 0Ah line_return BYTE 0Dh, 0Dh *line_return BYTE 0Dh, 0Ah*

*line_return BYTE 0Dh, 0Ah*

Suppose a program has the following data segment: .data num1 BYTE 3 num2 BYTE 4 num3 BYTE 5 result BYTE ? Which of the options below will store the value 4 in the result variable? -------------------- add al, num1 add al, -1 add al, -1 add al, -1 add bl, num3 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add al, bl add al, num2 mov result, al -------------------- add al, num1 add al, -1 add al, -1 add al, -1 add al, -1 add bl, num3 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add al, bl add al, num2 mov result, al -------------------- *mov al, num1* *add al, -1* *add al, -1* *add al, -1* *mov bl, num3* *add bl, -1* *add bl, -1* *add bl, -1* *add bl, -1* *add bl, -1* *add al, bl* *add al, num2* *mov result, al* -------------------- mov al, num1 add al, -1 add al, -1 add al, -1 add al, -1 mov bl, num3 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add bl, -1 add al, bl add al, num2 mov result, al

*mov al, num1* *add al, -1* *add al, -1* *add al, -1* *mov bl, num3* *add bl, -1* *add bl, -1* *add bl, -1* *add bl, -1* *add bl, -1* *add al, bl* *add al, num2* *mov result, al*

Suppose a program has the following data segment: .data var1 BYTE 22 var2 BYTE 12 var3 BYTE 8 result BYTE ? Which of the options below will store the value *2* it in the result variable? (the value 2 is also the difference of the three numbers: var1 - var2 - var3 = 22 - 12 - 8 = 2) mov al, var3 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 mov result, al add al, var3 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 mov result, al *mov al, var3* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *mov result, al* mov al, var3 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 add al, -1 mov result, al

*mov al, var3* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *add al, -1* *mov result, al*

Suppose the following array has been declared in the data segment: .data arr DWORD 1234ABCDh, 7594AE36h, 0FEAB4321h result DWORD ? Which of the options below will correctly add up all of the values in the array and store the sum in the result variable? *mov eax, arr* *add eax, [arr+4]* *add eax, [arr+8]* *mov result, eax* mov ax, arr add ax, [arr+4] add ax, [arr+8] mov result, ax mov ax, arr add ax, [arr+2] add ax, [arr+4] mov result, ax mov eax, arr add eax, [arr+2] add eax, [arr+4] mov result, eax

*mov eax, arr* *add eax, [arr+4]* *add eax, [arr+8]* *mov result, eax*

What is the formula for finding the *smallest SIGNED* binary value for a given number of bits? Note: N represents the number of bits in the formula ----------------------- -1 * (2^N) -1 * ((2^N) - 1) -1 * ((2^(N-1)) - 1) -1 * (2^(N-1)) (correct)

-1 * (2^(N-1))

What is the SIGNED hexadecimal number 80 converted to decimal? -128 -256 128 256

-128

Suppose we have the following UNsigned binary number: 10 And we want to sign-extend this binary number to four binary bits. The binary number MUST have the same value, but now it will be four binary bits rather than two. Which of the options below is correct? 1010 0010 1110 0110

0010

Suppose we want to represent the decimal number 19 as a SIGNED binary number using the least number of bits possible. Which of the options below is correct? 010011 0100011 100011 10011

010011

Suppose we want to represent the decimal number 65 as an UNsigned binary number using the least number of bits possible. Which of the options below is correct? 01000001 10000001 010000001 1000001

1000001

How many bits are in a byte? ----------------------------- 32 8 16 64

8

Which of the options below is the smallest SIGNED hexadecimal number that you can make with two (2) hexadecimal symbols? 00 7F FF 80

80

Suppose the following array is declared in the data segment: .data arr BYTE 1, 2, 3, 4 And the goal of the program is to swap the first half and second half of the array. After the program is finished, arr should be: [3, 4, 1, 2] Which of the options below is the correct implementation of the program? --------------------------------------- B-) mov al, arr mov bl, [arr+LENGTHOF arr/2-1] mov arr, bl mov [arr+LENGTHOF arr/2-1], al mov al, [arr+1] mov bl, [arr+LENGTHOF arr/2] mov [arr+1], bl mov [arr+LENGTHOF arr/2], al --------------------------------------- C-) mov al, [arr+1] mov bl, [arr+LENGTHOF arr/2+1] mov [arr+1], bl mov [arr+LENGTHOF arr/2+1], al mov al, [arr+2] mov bl, [arr+LENGTHOF arr/2+2] mov [arr+2], bl mov [arr+LENGTHOF arr/2+2], al --------------------------------------- D-) mov al, [arr+1] mov bl, [arr+LENGTHOF arr/2] mov [arr+1], bl mov [arr+LENGTHOF arr/2], al mov al, [arr+2] mov bl, [arr+LENGTHOF arr/2+1] mov [arr+2], bl mov [arr+LENGTHOF arr/2+1], al --------------------------------------- A-) mov al, arr mov bl, [arr+LENGTHOF arr/2] mov arr, bl mov [arr+LENGTHOF arr/2], al mov al, [arr+1] mov bl, [arr+LENGTHOF arr/2+1] mov [arr+1], bl mov [arr+LENGTHOF arr/2+1], al

A-) mov al, arr mov bl, [arr+LENGTHOF arr/2] mov arr, bl mov [arr+LENGTHOF arr/2], al mov al, [arr+1] mov bl, [arr+LENGTHOF arr/2+1] mov [arr+1], bl mov [arr+LENGTHOF arr/2+1], al

All of the following are part of the CPU (Central Processing Unit) EXCEPT: Control Unit General Registers Internal Clock Address Bus

Address Bus

Suppose a program has the following array declared in the data segment: array WORD 1, 5, 7 The program is supposed to calculate the sum of the gaps in the array. A gap in an array is the distance between two adjacent elements in the array. For the array given above, the gaps are: 5 - 1 = 4 7 - 5 = 2 So the sum of the gaps is 4+2=6 Which of the options below is the correct implementation of the program? A-) mov ax, 0 mov bx, array sub bx, [array+2] add ax, bx mov bx, [array+2] sub bx, [array+4] add ax, bx B-) *mov ax, 0* *mov bx, [array+2]* *sub bx, array* *add ax, bx* *mov bx, [array+4]* *sub bx, [array+2]* *add ax, bx* C-) mov ax, 0 mov bx, array sub bx, [array+4] add ax, bx mov bx, [array+4] sub bx, [array+8] add ax, bx D-) mov ax, 0 mov bx, [array+4] sub bx, array add ax, bx mov bx, [array+8] sub bx, [array+4] add ax, bx

B-) *mov ax, 0* *mov bx, [array+2]* *sub bx, array* *add ax, bx* *mov bx, [array+4]* *sub bx, [array+2]* *add ax, bx*

1. LENGTHOF is equivalent to SIZEOF * TYPE 2. LENGTHOF returns the number of bytes in a data declaration. A-) 1. False 2.True D-) 1. True 2. True Correct! C-) *1. False* *2. False* B-) 1. True 2. False

C-) *1. False* *2. False*

Suppose a program is supposed to write to memory letter/digit pairs, where the letter comes first and the digit comes second. Each pairing of a capital letter (A - Z) and a digit (0 - 9) should be written to memory in the following order: A0, A1, ...., A9, B0, B1, .... B9, ...., Y0, Y1, .... Y9, Z0, Z1, .... Z9* In addition, the total number of pairings should be stored in num_of_pairs. *Remember if you were to actually run this in visual studio, you would see the ASCII codes in memory itself, and the characters ('A', '0', etc.) off to the side The start of this program is as follows: LETTERS = 26 DIGITS = 10 .data outer_loop DWORD ? pair WORD ? num_of_pairs DWORD ? .code main proc mov outer_loop, LETTERS mov ah, '0' mov al, 'A' mov pair, ax mov num_of_pairs, 1 Which of the options below is the correct continuation of this program? NOTE: inc is the increment instruction -- it increments the value of it's operand by one. ------------------------------- D-) mov ecx, DIGITS jmp L2 L1: mov outer_loop, ecx mov ecx, DIGITS mov ah, '0' mov al, BYTE PTR pair inc al mov pair, ax inc num_of_pairs L2: inc BYTE PTR [pair+1] inc num_of_pairs loop L2 mov ecx, outer_loop loop L1 ------------------------------- B-) mov ecx, DIGITS-1 jmp L2 L1: mov outer_loop, ecx mov ecx, DIGITS-1 mov ah, '0' mov al, BYTE PTR pair inc al mov pair, ax inc num_of_pairs L2: inc BYTE PTR [pair+1] inc num_of_pairs loop L2 mov ecx, outer_loop loop L1 ------------------------------- A-) mov ecx, DIGITS-1 jmp L2 L1: mov outer_loop, ecx mov ecx, DIGITS-1 mov ah, '0' mov al, BYTE PTR pair inc al mov pair, ax L2: inc BYTE PTR [pair+1] inc num_of_pairs loop L2 mov ecx, outer_loop loop L1 ------------------------------- C-) mov ecx, DIGITS jmp L2 L1: mov outer_loop, ecx mov ecx, DIGITS mov ah, '0' mov al, BYTE PTR pair inc al mov pair, ax L2: inc BYTE PTR [pair+1] inc num_of_pairs loop L2 mov ecx, outer_loop loop L1

B-) mov ecx, DIGITS-1 jmp L2 L1: mov outer_loop, ecx mov ecx, DIGITS-1 mov ah, '0' mov al, BYTE PTR pair inc al mov pair, ax inc num_of_pairs L2: inc BYTE PTR [pair+1] inc num_of_pairs loop L2 mov ecx, outer_loop loop L1

Suppose a program has the following array in the data segment: arr BYTE 1, 2, 3, 4 And the goal is to remove the first and third elements in the array, and move the second and fourth elements up to the beginning of the array. Here an element will be "removed" by putting a 0 in it's place. After the program has finished running arr should be: [2, 4, 0, 0] Which of the options below is the correct implementation of the program? ----------------------------- A-) mov al, [arr+LENGTHOF arr-3] mov [arr+1], al mov al, [arr+LENGTHOF arr-1] mov [arr+2], al mov [arr+LENGTHOF arr-2], 0 mov [arr+LENGTHOF arr-1], 0 ----------------------------- D-) mov al, [arr+LENGTHOF arr-3] mov [arr], al mov al, [arr+LENGTHOF arr-1] mov [arr+1], al mov [arr+LENGTHOF arr-2], 0 mov [arr+LENGTHOF arr-1], 0 ----------------------------- C-) mov al, [arr+LENGTHOF arr-2] mov [arr], al mov al, [arr+LENGTHOF arr] mov [arr+1], al mov [arr+LENGTHOF arr-1], 0 mov [arr+LENGTHOF arr], 0 ----------------------------- B-) mov al, [arr+LENGTHOF arr-2] mov [arr+1], al mov al, [arr+LENGTHOF arr] mov [arr+2], al mov [arr+LENGTHOF arr-1], 0 mov [arr+LENGTHOF arr], 0

D-) mov al, [arr+LENGTHOF arr-3] mov [arr], al mov al, [arr+LENGTHOF arr-1] mov [arr+1], al mov [arr+LENGTHOF arr-2], 0 mov [arr+LENGTHOF arr-1], 0

Suppose a program has the string "COMSC 260" stored in source. The goal of the program is to store the reversed string, "062 CSMOC" in target. Part of the program is as follows: .data source BYTE "COMSC 260", 0 target BYTE SIZEOF source DUP(?) .code main PROC mov ecx,SIZEOF source-1 L1: mov al, [esi] mov [edi], al dec esi inc edi loop L1 mov BYTE PTR [edi], 0 For this program to work correctly, esi and edi must both be initialized correctly. Which of the options below correctly initializes *both* registers? NOTE: The source string ends with a null terminator (0). After the program finishes running, the target string will also end with a null terminator (0). NOTE: inc is the increment instruction -- it increments the value of it's operand by one. Likewise dec is the decrement instruction -- it decrements the value of it's operand by one. C-) mov esi, OFFSET [target - 2] mov edi, OFFSET [source + SIZEOF source + 1] Correct! D-) mov esi, OFFSET [target - 2] mov edi, OFFSET [source + SIZEOF source] B-) mov esi, OFFSET [target - 1] mov edi, OFFSET [source + SIZEOF source] A-) mov esi, OFFSET [target - 1] mov edi, OFFSET [source + SIZEOF source + 1]

D-) mov esi, OFFSET [target - 2] mov edi, OFFSET [source + SIZEOF source]

Which register is used to keep track of loop iterations? -------------------- ESI ECX EDI EDX

ECX

Which register is used to store the address of the next instruction that will be executed? -------------------- EDI EIP EBP ESI

EIP


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

Chapter 6- Professional Organizations

View Set

PSYCH 1XX3 - Quiz Questions and Answers

View Set

Sociology - Real World - Ch 12: Family Issues

View Set

Vocabulary Workshop Level D Unit 12

View Set

Physical Assessment Midterm Review

View Set