Comsc 260 Quizess

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

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

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

What is the SIGNED binary number 10000000 converted to decimal?

-128

What is the SIGNED hexadecimal number 80 converted to decimal?

-128

What is the smallest SIGNED number that can be represented with 8 binary bits?

-128

Suppose the top of the runtime stack is currently memory address 0000000A (i.e., this address is stored in ESP). Then suppose the following instruction is executed: pop eax What will be the new memory address that is at the top of the stack (i.e., the new address stored in ESP)?

0000000E

X DWORD 87654321h How is X stored in memory?

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

X WORD 1A2Bh, 3C4Dh, 5E6Fh How is X stored in memory?

0000: 2B0001: 1A0002: 4D0003: 3C0004: 6F0005: 5E

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?

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

1. The or instruction can be used to force specific bit's to be 0. 2. The xor instruction can be used to force specific bit's to be 1.

1. False 2. False

1. Suppose a program has the following three push instructions: push eax push ebx push ecx The corresponding sequence of pop instructions to remove these three values from the stack should be: pop eax pop ebx pop ecx 2. Register ESP stores the memory address of the location on the stack that is the top of the stack.

1. False 2. True

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 07C. 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,

1. False 2. True

What are the three steps of the instruction execution cycle in the correct order?

1. Fetch2. Decode3. Execute

1. The instruction xor al, al will always set the sign flag (SF) to 0. 2. The instruction xor al, al will always set the zero flag (ZF) to 0. NOTE: SF = 1 if the number has a 1 in the MSB, otherwise SF = 0 if the number has a 0 in the MSB

1. True 2. False

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. True 2. True

1. The runtime stack grows _ 2. From _ memory addresses to _ memory addresses.

1. downward 2. higher, lower

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: .datasource BYTE "COMSC 260", 0target BYTE SIZEOF source dup (?) .codemain proc mov ecx, LENGTHOF source-1 mov esi, OFFSET sourcemov eax, 0 L1: 1 ________ 2 ________add esi, TYPE source loop L1 mov esi, OFFSET targetmov ecx, LENGTHOF target-1 L2: 3 ________4 ________add esi, TYPE targetloop L2 mov BYTE PTR [esi], 0 invoke ExitProcess,0main endpend main Which of the options below contains the correct instructions to insert at lines 1 - 4 in the code shown above?

1. mov al, [esi]2. push eax 3. pop eax4. mov [esi], al

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

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? What you put down in the column is calculated by the formula: _ Carry a 1 over to the next column HINT: 1 + 1 = 10 1 + 1 + 1 = 11

1. sum = sum mod 2

Which of the options below is the smallest SIGNED binary number that you can make with six (6) bits?

100000

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?

1000001

What is the largest SIGNED number that can be represented with 8 binary bits?

127

What is the UNsigned hexadecimal number 80 converted to decimal?

128

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?

16n - 1

AB + CD What is the sum of the hexadecimal numbers shown above?

178

Suppose n = number of bits. Which of the options below is the correct formula that will give you the largest UNsigned binary number that you can represent for a given number of bits?

2n - 1

What is the largest UNsigned number that you can make with five (5) bits?

31

X DWORD 12000000h, 34000000h, 56000000h, 78000000h, 9A000000h, 0B000000h, 0C000000h, 0D000000h, 0E000000h, 0F000000h How many bits is X?

320

var1 BYTE 7 dup("COMSC 260") How many bytes is var1?

63

Which of the options below is the largest SIGNED hexadecimal number that you can make with two (2) hexadecimal symbols

7F

How many bits are in a byte?

8

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

80

what is the status of the runtime stack after sub3 has been called (but before sub3 has returned)?

A)

Which of the options below will: 1) store 6 in eax 2) store 3 in ebx

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

What is the logic behind the loop instruction?

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

mov al, -127 sub al, 1 What will OF (overflow flag) and PF (parity flag) be after executing these instructions?

A-) OF = 0 PF = 0

if( EAX <= EBX ) X = 5; else X = 10; Which of the options below is equivalent to the code shown above?

A-) cmp EAX, EBX ja L1 mov X, 5 jmp L2 L1: mov X, 10 L2:

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?

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

Which of the options below is equivalent to push EAX?

A-) sub ESP, 4 mov [ESP], EAX

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

A-) 0000 0005

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?

A-) mov eax, DWORD PTR [arrB+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).

A-) mov ecx, 0L1:mov eax, ecxinc ecxloop L1

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?

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

All of the following are part of the CPU (Central Processing Unit) EXCEPT:

Address Bus

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. -1282. +127

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?

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

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?

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

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?

B-) mov al, [valA+3]

Suppose the following SIGNED values are compared: mov al, -3 cmp al, +9 What are the values of SF (sign flag) and OF (overflow flag)?

B-)SF = 1OF = 0

cmp al, bl ja YES jmp NO Which of the options below is equivalent to the code shown above?

B-)cmp al, bljz NOjc NOjmp YES

1. LENGTHOF is equivalent to SIZEOF * TYPE 2. LENGTHOF returns the number of bytes in a data declaration.

C-) 1. False 2. False

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?

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

Suppose a program starts with the following instructions: mov eax, 0 mov al, 11111111b The first instruction clears eax, and the second instruction moves the 8-bit binary number 11111111 into al (the lowest byte of eax). From here, the program is supposed to shift the number 11111111 from al (the lowest byte of eax) to the highest byte of eax. How many add eax, eax instructions are needed to do this?

C-) 24

Suppose a program is supposed to convert an ASCII decimal digit (48 - 57) to its equivalent binary number (0 - 9). For example, the character '0' has ASCII code 48, which would be converted to the number 0. The character '1' has ASCII code 49, which would be converted to the number 1, and so on. Which of the options below is the correct implementation of this program?

C-) and al, 11001111b

The _ instruction does the following: Pushes the offset (address) of the next instruction onto the runtime stack Copies the address of the procedure that control has been transferred to into EIP

C-) call

L1: mov EAX, 1 loop L1 The code shown below is equivalent to the loop shown above: mov ECX, 5 L1: mov EAX, 1 dec ECX cmp ECX, 0 1 __________ Which jump instruction should be inserted at line 1 in the code shown above?

C-) jne L1

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:

C-) mov al, SIZEOF val1

if( EBX <= ECX AND EBX <= EDX) OR ( EDX <= EAX ) X = 75; else X = 99; Part of the equivalent assembly language program is shown below: cmp EBX, ECX 1 __________ cmp EBX, EDX 2 __________ jmp L2 L1: cmp EDX, EAX 3 _____________ L2: 4 _______ jmp next L3: 5 _______ next: Which of the options below contains the correct instructions that can be inserted at lines 1-5 in the code above?

C-)1 ja L12 ja L13 ja L34 mov X, 755 mov X, 99

The _ bus is used for synchronization

Control

_ RAM is known as main memory

D

For which of the options below will the jump to AllSet be taken only when bits 5, 6, and 7 are all set for the number in bl? jz: jump if zero flag (ZF) = 1* jnz: jump if zero flag (ZF) = 0** *This is the same as saying "jump if the zero flag is set" **This is the same as saying "jump if the zero flag is clear" or "jump if the zero flag is NOT set"

D-) and bl, 11100000b cmp bl, 11100000b jz AllSet

if( val1 > ECX ) AND ( ECX > EDX ) X = 1; else X = 2; Which of the options below is equivalent to the code shown above?

D-) cmp val1, ECXjbe L1cmp ECX, EDXjbe L1mov X, 1jmp nextL1:mov X, 2next:

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?

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

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

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?

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

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:

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

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?

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

For which of the options below will the jump to OddParity be taken only when the parity of the number in al is odd?

D-) and al, al jnp OddParity

Which instruction would cause the runtime stack and register EIP to change from the initial state shown above to the final state shown above?

D-) ret

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?

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

Which register is the frame pointer?

EBP

Which register is used to keep track of loop iterations?

ECX

What is the two's complement of the hexadecimal number 101101?

EFEEFF

When a loop instruction is encountered, and the jump is taken, which register is affected by the jump?

EIP

Which register is used to store the address of the next instruction that will be executed?

EIP

Which of the options below is the largest UNsigned hexadecimal number that you can make with two (2) hexadecimal symbols

FF

Which of the following is the correct SIGNED hexadecimal representation of -6?

FFA

ExitProcess, 0 notifies the operating system that the program has successfully finished in a 32-bit mode program.

INVOKE

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

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

Which of the following options below is the correct way to end a string with the null terminator character?

Text BYTE "Hello World", 0

Which of the following options below represents a 16 bit unsigned integer?

WORD

For which of the options below will the jump to L1 only be taken when the number in al is negative?

and al, 10000000b jnz L1

For which of the options below will the jump to the label evennumber be taken only when the number in al is even?

and al,00000001b jz evennumber

cmp al, bl jl YES jmp NO Which of the options below is equivalent to the code shown above?

cmp al, bl js CHECK jo YES jmp NO CHECK: jno YES jmp NO

Which of the following options below is an accurate visual representation of a runtime stack?

d) runtime stack

What are the two steps to get the two's complement of a binary number? For each binary bit i, perform: _ _

flipped_bit[i] = 1 - bit[i] Add 1

What are the two steps to get the two's complement of a hexadecimal number? For each hexadecimal symbol i, perform: _ _

flipped_hex[i] = 15 - hex[i] Add 1

Which of the following options below is the correct way to do a line return (new line) in x86 assembly language?

line_return BYTE 0Dh, 0Ah

Which of the options below is equivalent to the instruction pop EAX?

mov EAX, [ESP] add ESP, 4

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

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, 255 mov bl, 1 add al, bl

add al, 0 js YES jmp NO Which of the options below is equivalent to the code shown above?

mov bl, al and bl, 80h jnz YES jmp NO

mov al, 00000000b Which of the options below contains a set of instructions that will cause the final value in al to be 00000000b?

not al add al, 1

Given the ASCII code table shown above, suppose that we move the Space character into register al. Which of the options below would convert the Space character in al to the DEL character?

or al, 5Fh

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

quotient quotient

Suppose the goal of the program is as follows: set the parity flag (PF) to 1 ONLY if the original number in al has an even number of 1's, and otherwise set PF to 0 (it's OK if we change al's value, but we must set the flag correctly). All of the options below will correctly do this EXCEPT:

xor al, al


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

SDLC Model images, SDLC Models, Software Development Life Cycle (SDLC)

View Set

Chapter 7 - The cell cycle and cell division

View Set

Chapter 4 quiz/ Study guide ( Energy and Matter)

View Set

history 111 chapter 23, Hst 111 Ch 24, Hst 111 ch 25

View Set

English- Perseus; the hero’s journey

View Set

Prep-U Safety and Infection Control

View Set

English 4 CP Quarterly 2 Study Guide

View Set

(Chem-1010) Introductory to Chemistry. "Final Exam."

View Set

SEC+ 601- Mastering Security Basics

View Set