CSCI321 - Unit 3 exam with 100% correct answers
Which of the following statements shifts each bit in EBX one position to the left, and copies the highest bit into both the Carry flag and the lowest bit position? RCR RCL SHL ROL - correct answer ROL Which of the following statements shifts each bit in EAX one position to the right, filling the high order bit with a zero and copying the low order bit into the Carry flag? ROR eax, 1 None of the other answers are correct RCR eax,1 SHR eax,1 - correct answer SHR eax,1 Which answer choice contains the hexadecimal value in AX after these instructions execute? mov ax,36B5h ror ax,4 6B53 B536 563B 536B - correct answer 536B Which answer choice contains the hexadecimal value in AX after these instructions execute? mov ax,36B5h shr ax,3 0C2B 07D7 0A6B 06D6 - correct answer 06D6 Which instruction performs the following operation, where CF denotes the Carry flag? Before: CF,AL = After: CF,AL = RCR ROL ROR RCL - correct answer RCL Which answer choice contains the hexadecimal value in AX after these instructions execute? mov ax,36B5h shl ax,3 D5B4 D6A2 B6A4 B5A8 - correct answer B5A8 Which answer choice contains the hexadecimal value in AX after these instructions execute? mov ax,36B5h ror ax,3 0AB6 0D6B A6D6 AD6B - correct answer A6D6 Suppose you wish to write assembly language instructions that multiply EAX by 24 using binary multiplication. Which of the following code sequences would accomplish this task? mov ebx,eax shl eax,5 shl ebx,2 add eax,ebx mov ebx,eax shl eax,4 shl ebx,3 add eax,ebx mov ebx,eax shr eax,4 shr ebx,3 add eax,ebx mov ebx,eax shl eax,4 shl ebx,1 add eax,ebx - correct answer mov ebx,eax shl eax,4 shl ebx,3 add eax,ebx Suppose you wish to assembly language instructions that multiply EAX by 21 using binary multiplication. If we express the value as (EAX * 16) + (EAX * 4) + EAX, the following code is missing two lines: mov ebx,eax mov ecx,eax shl eax,4 __________________ __________________ add eax,ecx Which of the following choices correctly supplies the missing lines? shl ebx,3 add eax,eax shl ebx,4 add ebx,eax shl ebx,4 add eax,ebx shl ebx,2 add eax,ebx - correct answer shl ebx,2 add eax,ebx Suppose the time stamp field of a file directory entry uses bits 0 through 4 for the seconds, bits 5 through 10 for the minutes, and bits 11 through 15 for the hours. Assuming DX already contains time stamp data, which of the following instruction sequences correctly extracts the minutes and copies the value to a byte variable named bMinutes? Sequence : shr dx,5 and dl,b mov bMinutes,dl Sequence : shr dx,4 and dl,b mov bMinutes,dl Sequence : shr dx,4 or dl,b mov bMinutes,dl Sequence : shr dx,5 and dl,b mov bMinutes,dl - correct answer Sequence : shr dx,5 and dl,b mov bMinutes,dl Overflow can occur when the MUL and one-operand IMUL instructions execute. true false - correct answer false //overflow cannot occur when MUL executes When the product fits completely within the lower register of the product, IMUL sign-extends the product into the upper product register. MUL, on the other hand, zero-extends the product. true false - correct answer true When the IMUL instruction executes, the Carry and Overflow flags are set only when the upper half of the product is not a sign extension of the lower half of the product. true false - correct answer true When EBX is the operand in a DIV instruction, which register (or combination of registers) holds the quotient? EDX:EAX EDX EAX AX - correct answer EAX When BX is the operand in a DIV instruction, which register holds the quotient? AX EAX DX AL - correct answer AX When BL is the operand in a MUL instruction, which registers hold the product? DX:AX EAX AX EDX - correct answer AX What is the final decimal value in AX when this code executes? .data dividend WORD -5678 divisor WORD 10 .code mov ax,dividend cwd mov bx,divisor idiv bx −678 -567 567 +567 - correct answer −567 The ADC instruction adds both a source operand and the Carry flag to a destination operand. true false - correct answer true The SBB instruction subtracts both a source operand and the Carry flag from a destination operand. true false - correct answer true What will be the values of EDX and EAX after the following instructions execute? mov edx,10h mov eax,0A0000000h add eax,h adc edx,0 EAX = h, EDX = h EAX = C0000000h, EDX = h EAX = 1C0000000h, EDX = h EAX = C0000000h, EDX = h - correct answer EAX = C0000000h, EDX = h What will be the values of EDX and EAX after the following instructions execute? mov edx,100h mov eax,h sub eax,h sbb edx,0 EAX = h, EDX = 100000FFh EAX = F0000000h, EDX = 000000FFh EAX = h, EDX = F00000FFh EAX = F0000001h, EDX = 000000F0h - correct answer EAX = F0000000h, EDX = 000000FFh What will be the contents of DX after the following instructions execute? (Note: STC sets the Carry flag.) mov dx,5 stc mov ax,10h adc dx,ax DX = 0015h DX = 0115h DX = 0160h DX = 0016h - correct answer DX = 0016h Which of the following instructions converts a two-digit unpacked decimal integer in AX to ASCII decimal? or ax,0F0F0h and ax,0F0Fh or ax,3030h or ax,3000h - correct answer or ax,3030h Which of the following instructions converts a two-digit ASCII decimal integer in AX to unpacked decimal format? xor ax,3030h or ax,0303h and ax,0F0Fh and ax,0F0F0h - correct answer and ax,0F0Fh Which of the following is a two-instruction sequence that converts a two-digit ASCII decimal number in AX to binary? or ax,0303h aad or ax,3030h aad and ax,0F0Fh aad or ax,0F0Fh aad - correct answer and ax,0F0Fh aad Which of the following instructions converts an unsigned binary integer in AX to unpacked decimal? aam aaa aas aad - correct answer aam The DAA instruction sets the Carry flag when the sum of a packed decimal addition is greater than 99. true false - correct answer true The DAS instruction sets the Carry flag when a smaller packed decimal integer is subtracted from a larger one. true false - correct answer false When adding two packed decimal integers of length n bytes, how many storage bytes must be reserved for the sum? n − 1 bytes n + 1 bytes n bytes - correct answer n + 1 bytes What will be the value of AL and the Carry flag after the following instructions execute? mov al,56h add al,92h daa AL = E8h, CF = 1 AL = 48h, CF = 1 AL = E8h, CF = 0 AL = 08h, CF = 1 - correct answer AL = 48h, CF = 1 What will be the value of AL and the Carry flag after the following instructions execute? mov al,56h sub al,92h das AL = 64h, CF = 1 AL = 64h, CF = 0 AL = C4h, CF = 1 AL = C4h, CF = 0 - correct answer AL = 64h, CF = 1 Which instruction shifts each bit in an operand to the left and copies the highest bit into both the Carry flag and the lowest bit position? ROL RCL ROR RCR - correct answer ROL Which instruction performs the following operation (CF = Carry Flag)? Before: CF, AL = After: CF, AL = RCR ROL ROR RCL - correct answer RCL Which of the following will set the Carry Flag? mov al, b SHR al, 2 mov al, b SHR al, 1 mov al, b SHR al, 3 mov al, b SHR al, 4 - correct answer mov al, b SHR al, 1 mov al, b SHR al, 3 mov al, b SHR al, 4 Which of the following is equivalent to the following instruction? shld bx, ax, 1 rcl bx, 1 shl ax, 1 sal ax, 1 rcr bx, 1 shl ax, 1 rcl bx, 1 rcl bx, 1 sal ax, 1 - correct answer shl ax, 1 rcl bx, 1 What will be the value in eax if eax has value 2 before? mov ebx, eax shl eax, 4 shl ebx, 3 add eax, ebx 2 24 48 none of these - correct answer 48 Suppose that I want to extract bits 2-6 from a value stored in AX and save it to variable named myValue. Which of the following does the job correctly? shl ax, 2 and al, b mov myValue, al shr ax, 6 and al, b mov myValue, al shr ax, 2 and al, b mov myValue, al shl ax, 6 and al, b mov myValue, al - correct answer shr ax, 2 and al, b mov myValue, al Which of the following are true? When product completely fits in the lower register of the product, MUL will do sign extension for the product The overflow may occur when the MUL instruction execute When product completely fits in the lower register of the product, IMUL will do sign extension for the product The overflow will never occur when the IMUL instruction execute - correct answer When product completely fits in the lower register of the product, IMUL will do sign extension for the product The overflow will never occur when the IMUL instruction execute When BL is the operand in a MUL instruction, which register holds the product? AX EAX AL AH - correct answer AX Before calling IDIV, we do signed extension with a 16 bit-operand. What instruction missed in following code segment? mov ax, dividenLow _______________ ; what missed here? mov bx, divisor idiv bx RCR nothing CWD ROR - correct answer CWD What will be the contents of DX after the following instructions execute (STC sets the Carry flag)? mov dx, 5 stc mov ax, 10h adc dx, ax 0006h 0016h 0011h 0015h - correct answer 0016h What will be the value of EDX:EAX after the following instructions execute? mov edx, 100h mov eax, h sub eax, h sbb edx, 0 EAX = 0h EDX = 000000FFh EAX = 0F0000000h EDX = h EAX = 0F0000000h EDX = 000000FFh EAX = 0FFFFFFFFh EDX = h - correct answer EAX = 0F0000000h EDX = 000000FFh Write a single instruction that converts a two-digit ASCII decimal integer in AX to unpacked decimal and ax, 0F0F0h or ax, 0F0F0h and ax, 0F0Fh or ax, 0F0Fh - correct answer and ax, 0F0Fh Write a single instruction that converts an unsigned binary integer in AX to unpacked decimal aad aam aaa aas - correct answer aam Which of the following will result AL to be 0A9h? mov al, 0D4h rol al, 1 mov al, 0D4h sar al, 4 mov al, 0D4h shr al, 1 mov al, 0D4h sar al, 1 - correct answer mov al, 0D4h rol al, 1 Which of the following will result Al to be 0A9h? mov al, 0D4h ror al, 3 mov al, 0D4h rol al, 7 stc mov al, 0D4h rcl al, 1 stc mov al, 0D4h rcr al, 3 - correct answer stc mov al, 0D4h rcl al, 1 Which of the following state the result correctly after executes the given code segment.? Code Segment: mov eax, 123400h mov edx, 0 mov ebx, 10h div ebx Result: EDX = 0 and EAX = h Code Segment mov ax, 63h mov b1, 10h div b1 Result: AX = 0306 code segment: mov ax, 4000h mov dx, 500h mov bx, 10h div bx Result: dx = 0500h and ax = 0400h Code segment: mov dx, 0 mov ax, 222h mov cx, 100h mul cx Result: AX = 0002h and DX = 2200h - correct answer Code Segment: mov eax, 123400h mov edx, 0 mov ebx, 10h div ebx Result: EDX = 0 and EAX = h Code Segment mov ax, 63h mov b1, 10h div b1 Result: AX = 0306 A subroutine's stack frame always contains the caller's return address and the subroutine's local variables. true false - correct answer true Arrays are passed by reference to avoid copying them onto the stack. true false - correct answer true A subroutine's prologue code always pushes EBP on the stack. true false - correct answer true Local variables are created by adding a positive value to the stack pointer. true false - correct answer false In 32-bit mode, the last argument to be pushed on the stack in a subroutine call is stored at location EBP + 8. true false - correct answer true Passing by reference means that an argument's address is stored on the runtime stack. true false - correct answer true What are the two common types of stack parameters? local parameters and global parameters value parameters and reference parameters stack frame and activation record parameters pointer parameters and reference parameters - correct answer value parameters and reference parameters Consider a C language function named MySub: void MySub( int a, int b ) { ... } Suppose you were to implement the equivalent procedure in assembly language, beginning with these lines: MySub PROC push ebp mov ebp,esp How many 32-bit doublewords would be stored on the runtime stack after the MOV instruction? - correct answer 4 Given the same task to accomplish, a recursive subroutine usually uses less memory than an equivalent nonrecursive one. true false - correct answer false In the Factorial function, assuming no runtime error occurs, what condition terminates the recursion? When n equals 0 When n equals 1 When n equals 5 factorial When the stack is empty - correct answer When n equals 0 Which of the following answer choices lists all the instructions in the assembly language Factorial procedure that execute after each recursive call has finished? L2: pop ebp ; return EAX ret 4 ; clean up stack mul ebx ; EDX:EAX = EAX * EBX L2: pop ebp ; return EAX ret 4 ; clean up stack mov ebx,[ebp+8] ; get n mul ebx ; EDX:EAX = EAX * EBX L2: pop ebp ; return EAX ret 4 ; clean up stack - correct answer mov ebx,[ebp+8] ; get n mul ebx ; EDX:EAX = EAX * EBX L2: pop ebp ; return EAX ret 4 ; clean up stack What would happen to the Factorial program's output if you tried to calculate 13 factorial? The calculated value would appear as zero (0). The calculated value would appear as . The calculated value would exceed the range of an unsigned doubleword, so its output cannot be easily determined. - correct answer The calculated value would exceed the range of an unsigned doubleword, so its output cannot be easily determined. Which of the following formulas can be used to calculate the number of bytes of stack space used by the Factorial procedure when calculating n factorial? (n + 1) × 8 (n × 8) (n − 1) × 12 (n + 1) × 12 - correct answer (n + 1) × 12 The CALL instruction cannot include procedure arguments. true false - correct answer true The INVOKE directive can include up to a maximum of three arguments. true false - correct answer false The INVOKE directive can only pass memory operands, but not register values. true false - correct answer false The PROC directive can contain a USES operator, but the PROTO directive cannot. true false - correct answer true Linking OBJ modules is much faster than assembling ASM source files. true false - correct answer true Separating a large program into short modules makes a program more difficult to maintain. true false - correct answer false In a multimodule program, an END statement with a label occurs only once in the startup module. true false - correct answer true In order to avoid a syntax error, you must be careful not to include a PROTO directive for a procedure unless the procedure is actually called. true false - correct answer false The primary advantage to using INVOKE with PROC is that you can match up argument lists passed by INVOKE to corresponding parameter lists declared by PROC. true false - correct answer true Which of the following are true? Local variables are created by adding a positive value to the stack pointer A subroutine's prologue code always pushes EBP on the stack Arrays are passed by value to avoid copying them onto the stack A subroutine's stack frame always contains the caller's return address ad the subroutine's local variables - correct answer A subroutine's prologue code always pushes EBP on the stack A subroutine's stack frame always contains the caller's return address ad the subroutine's local variables Given the same task to accomplish, a recursive subroutine usually uses less memory than a nonrecursive one True False - correct answer False Refer to Factorial PROC from textbook. What condition terminates the recursion? n 0 n equals 1 n 1 n equals 0 - correct answer n equals 0 Which of the following are true? The INVODE directive can only pass memory operands not register values The Call instructionn cannot include procedure argume The PROC directive can contain a USES operator but the PROTO directive cannot The INVOKE directive can include maximum three arguments - correct answer The Call instructionn cannot include procedure argume The PROC directive can contain a USES operator but the PROTO directive cannot Which of the following are true? Separating a large program into short modules makes a program easier to maintain Link OBJ modules is much faster than assembling ASM source fies In a multimodule program, an END statement with a label occurs only once in the startup module. PROTO directives use up memory, so you must be careful not to include a PROTO directive for a procedure unless the procedure is actually called - correct answer Separating a large program into short modules makes a program easier to maintain Link OBJ modules is much faster than assembling ASM source fies In a multimodule program, an END statement with a label occurs only once in the startup module. Which statements belong to procedure's epilogue when the procedure has stack parameters and local variables mov ebp,esp pop ebp mov esp,ebp pop ebp mov ebs,edi pop ebp mov eax,ebp pop ebp - correct answer mov ebp,esp pop ebp //answer is actually mov esp,ebp pop ebp Which of the following are true? When a C function returns a 32-bit integer, the return value stored in EAX. A C function, how much stack space is used by a variable of type int? Answer: 4 bytes. If you pass a variable containing the offset of an array of bytes to a procedure that expects a pointer to an array of words, the assembler will flag this as an error. When use the PROC directives, all parameters must be listed on the same line. - correct answer When a C function returns a 32-bit integer, the return value stored in EAX. A C function, how much stack space is used by a variable of type int? Answer: 4 bytes Which of the following are true? LEA instruction is less powerful than OFFSET operator To use the STDCALL calling convention clean up the stack after a procedure call, It passes an integer constant to the RET instruction. This constant is added to the stack pointer right after the RET instruction has popped the procedure's return address off the stack. If you pass an immediate value to a procedure that expects a reference parameter, yo can generate a general-protecton fault. The C caling convention has adavantage over the STDCALL calling convention because the C calling convention allows for variable-length parameter lists. - correct answer To use the STDCALL calling convention clean up the stack after a procedure call, It passes an integer constant to the RET instruction. This constant is added to the stack pointer right after the RET instruction has popped the procedure's return address off the stack. If you pass an immediate value to a procedure that expects a reference parameter, yo can generate a general-protecton fault. The C caling convention has adavantage over the STDCALL calling convention because the C calling convention allows for variable-length parameter lists. In reference to string primitives, which 32-bit register is known as the accumulator? EAX AX AL EDX - correct answer EAX Which instruction compares a 32-bit integer in the accumulator to the contents of memory, pointed to by EDI? SCASW SCASD STRCMP CMP - correct answer SCASD Which index register is used by the STOSD instruction? EDX EBX EDI ESI - correct answer EDI Which instruction copies data from the memory location addressed by ESI into AX? MOVSW MOVSD LODSW STOSW - correct answer LODSW When REPZ appears before the CMPSB instruction, the instruction repeats until either the Zero flag is set or ECX = 0. false true - correct answer false The LODSD instruction always increments EDI because it is not affected by the Direction flag. false true - correct answer false //it increments ESI You would usually follow a CMPSD instruction with a JA instruction in order to verify that the operand pointed to by ESI is greater than the operand pointed to by EDI. true false - correct answer true In a base-index operand, ESI must always appear before EDI, and the registers must be surrounded by square brackets. true false - correct answer false The 32-bit Str_compare procedure stops when the null terminator of the longer string is reached. true false - correct answer false The 32-bit Str_compare procedure does not need to use ESI and EDI to access memory. false true - correct answer true The 32-bit Str_length procedure uses SCASB to find the null terminator at the end of the string. false true - correct answer false The 32-bit Str_copy procedure prevents a string from being copied into too small a memory area. true false - correct answer false The 32-bit Str_copy procedure does not preserve the caller's values of EAX and ECX when it returns. true false - correct answer false The 32-bit Str_trim procedure always removes leading and trailing spaces from a given string. false true - correct answer false The 64-bit Str_copy procedure has two input parameters: RSI points to the source string, and RDI points to the location where the copied string will be stored. false true - correct answer true In 32-bit mode, which registers can be used in a base-index operand? ESI and EDI only ESI, EDX, and EBX All general-purpose 32-bit registers - correct answer All general-purpose 32-bit registers Suppose a two-dimensional array of doublewords has three logical rows and four logical columns. If ESI is used as the row index, what value is added to ESI to move from one row to the next? 8 4 32 16 - correct answer 16 In 32-bit mode, it is common to use EBP to address an array. True False - correct answer False In a two-dimensional array using row-major order, the first column appears at the beginning of the memory block. The last element in the first column is followed in memory by the first element of the second column. True False - correct answer False When accumulating a large two-dimensional array of bytes, suppose EAX is the accumulator, ESI points to the current row, and EBX points to the current column. Which of the following code sequences should be used when adding each array element to EAX? add eax,DWORD PTR[ebx + esi] movzx edx,BYTE PTR[ebx + esi] add eax,edx add eax,BYTE PTR[ebx + esi] add eax,[ebx + esi] - correct answer movzx edx,BYTE PTR[ebx + esi] add eax,edx If an array were already in sequential order, how many times would the outer loop of the BubbleSort procedure in Section 9.5.1 execute? n − 1 times n times 1 time n + 1 times - correct answer n - 1 times In the BubbleSort procedure, how many times does the inner loop execute on the first pass through the array? n − 1 times 1 time n + 1 times n times - correct answer n - 1 times In the BubbleSort procedure, the number of inner loop iterations decreases by 1 each time the outer loop executes. True False - correct answer True The following statement correctly calls the BubbleSort procedure: INVOKE BubbleSort, array, ARRAY_SIZE true false - correct answer false //array needs: ADDR array Which of the following are true The instruction LODSW copies data from the memory location addressed by ESI into AX In reference to string primitives, the EAX register is known as the accumulator STOSD instruction uses register EDI The instruction SCASD, which compares a 32-bit integer in the accumulator to the contents of memory, is pointed by EPI - correct answer The instruction LODSW copies data from the memory location addressed by ESI into AX In reference to string primitives, the EAX register is known as the accumulator STOSD instruction uses register EDI Which of the following are true? The 32-bit Str_compare procedure does not need to use ESI and EDI to access memory The str_copy procedure prevents a string from being copied into too small memory area The 32-bit Str_length procedure uses SCASB to find the null terminator at the end of the string The Str_compare procedure stops when the null terminator of the shorter string is reached - correct answer The 32-bit Str_compare procedure does not need to use ESI and EDI to access memory The Str_compare procedure stops when the null terminator of the shorter string is reached Which of the following are true? If it were found that an array of 500 integers could be sorted in 0.5 seconds using BubbleSort, then it takes 50 seconds to sort an array of 5000 integers. In the BubbleSort procedure, how many times does the inner looop execute on the first pass through the array? Assume array size is n. Answer: n-1 In the BubbleSort procedure, the inner loop always execute the same number of times If an array were already in sequential order, how many times would the outer loop of the BubbleSort procedure in textbook execute? Assume array size is n. Answer: n - correct answer If it were found that an array of 500 integers could be sorted in 0.5 seconds using BubbleSort, then it takes 50 seconds to sort an array of 5000 integers. In the BubbleSort procedure, how many times does the inner looop execute on the first pass through the array? Assume array size is n. Answer: n-1 Which of the following are true? In 32-bit mode, you shall NOT use EBP to address an array Suppose a two-dimensional array of doublewords has three logical rows and four logical columns. If ESI is used as the row index, then 16 is added to ESI to move from one row to the next. In 32-bit mode, any 32-bit general purpose registers can be used as base-index operand Suppose a two-dimensional array of doublewords has three logical rows and four logical columns. If ESI is used as the row index, then 12 is added to ESI to move from one row to the next. - correct answer In 32-bit mode, you shall NOT use EBP to address an array Suppose a two-dimensional array of doublewords has three logical rows and four logical columns. If ESI is used as the row index, then 16 is added to ESI to move from one row to the next. In 32-bit mode, any 32-bit general purpose registers can be used as base-index operand Which of the following are true? When Direction flag is set (1), it causes index registers to move backward through memory when executing string primitives. Regardless of which operands are used, CMPS still compares the contents of memory pointed to by ESI to the memory pointed to by EDI. When the directon flag is clear and SCASB has found a matching character, the EDI points to 2 bytes beyond the matching character. When a repeat prefix is used with STOSW, 4 is added to the index register. - correct answer When Direction flag is set (1), it causes index registers to move backward through memory when executing string primitives. Regardless of which operands are used, CMPS still compares the contents of memory pointed to by ESI to the memory pointed to by EDI. Which of the following are true? When scan an array for the first occurrence of a particular character, REPNE (REPNZ) is the best repeat prefix, In book's Str_trim procedure, JNE is used to exit the loop and insert a null byte into the string when no more characters are to be trimmed. For Str_trim procedure, Direction flag is clear. If Str_length use SCASB, we shall use REPNE (REPNZ) repeat prefix - correct answer When scan an array for the first occurrence of a particular character, REPNE (REPNZ) is the best repeat prefix, In book's Str_trim procedure, JNE is used to exit the loop and insert a null byte into the string when no more characters are to be trimmed. If Str_length use SCASB, we shall use REPNE (REPNZ) repeat prefix Which of the following are true? If the Direction flag were set, EDI would decrement and move backwards through the array. The Direction flag is cleared so that the STOSD instruction will automatically increment the EDI register. In Str_ucase procedure, if the target string contains a digit, then the digit is unchanged. The maximum number of comparison needed when using binary search to search an array contains 1024 elements is 12. (Hint: 1024 is 2^10) - correct answer If the Direction flag were set, EDI would decrement and move backwards through the array. The Direction flag is cleared so that the STOSD instruction will automatically increment the EDI register. In Str_ucase procedure, if the target string contains a digit, then the digit is unchanged.
Written for
- Institution
- SBB
- Course
- SBB
Document information
- Uploaded on
- April 27, 2024
- Number of pages
- 43
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
csci321 unit 3 exam with 100 correct answers
Also available in package deal