Module 3 Quiz Questions Flashcards
(True/False) In debugging mode, the values of watched variables/registers may only be viewed in hexadecimal format.
false, you can toggle between hex and decimal view
In debugging mode, what is the keyboard shortcut to continue execution to the next breakpoint (or to the end of the program if no more breakpoints exist)?
F5
In debugging mode, which of the following (when typed into the memory window’s address bar) will directly jump to the first memory address of variable userName?
&userName
The MASM assembler is used for locating ________ errors, but the debugging system is used for locating _____, ________, or _____ errors.
syntax,
Logic, runtime, or execution
Conditional jumps check flags in which register before jumping?
status register
When branching in MASM, you will normally jump to ___________ .
a code label (representing an address in the code segment)
Correctly match the status flags to their description.
- The carry flag
- the overflow flag
- the sign flag
- the zero flag
- the parity flag
- The carry flag - Used in unsigned arithmetic: Set if an arithmetic operation generates a carry or a borrow out of the most significant bit of the result; cleared otherwise. It is also used in multiple-precision arithmetic.
- the overflow flag - Used in signed-integer (two’s complement) arithmetic: Set if the integer result is too large a positive number or too small a negative number (excluding the sign-bit) to fit in the destination operand; cleared otherwise. This flag indicates an overflow condition.
- the sign flag - Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.)
- the zero flag - Set if the result is zero; cleared otherwise.
- the parity flag - Set if the least-significant byte of the result contains an even number of 1 bits; cleared otherwise.
Match the Conditional Jump instruction to its operation.
JA
JG
JNZ
JE
JC
JECXZ
JA - JUMP IF LEFTOP > RIGHTOP (UNSIGNED)
JG - JUMP IF LEFTOP > RIGHTOP (SIGNED)
JNZ - JUMP IF RESULT IS NON-ZERO
JE - JUMP IF RESULT IS ZERO, SAME AS JZ
JC - JUMP IF CARRY FLAG IS SET, ONLY VALID FOR UNSIGNED INTEGERS
JECXZ - JUMP IF 32-BIT, ECX COUNTER REGISTER IS ZERO
Please select the appropriate description of the LOOP instruction.
Decrement ECX, then Jump if ECX is nonzero
If the LOOP instruction sets ECX to zero, a jump to the destination label does take place.
False
Given the following data declarations and code (within main), what is printed to the console window?
(Do not include “quotations” or “Press any key to continue”, simply write anything printed with WriteString)
.data
yes BYTE “Yes”,0
no BYTE “No”,0
.code
MOV EAX, 10
CMP EAX, 11
JE _printYes
MOV EDX, OFFSET no
JMP _finished
_printYes:
MOV EDX, OFFSET yes
_finished:
CALL WriteString
No
Given the following data declarations and code (within main), what is printed to the console window?
(Do not include “quotations” or “Press any key to continue”, simply write anything printed with WriteString)
.data
yes BYTE “Yes”,0
no BYTE “No”,0
maybe BYTE “Maybe: “,0
.code
MOV EAX, 20
CMP EAX, 10
JG _printMaybe
_printNo:
MOV EDX, OFFSET no
JMP _finished
_printYes:
MOV EDX, OFFSET yes
JMP _finished
_printMaybe:
MOV EDX, OFFSET maybe
CALL WriteString
CMP EAX, 15
JL _printYes
JMP _printNo
_finished:
CALL WriteString
Maybe: No
Given the following data declarations and code (within main), what is printed to the console window?
(Do not include “quotations” or “Press any key to continue”, simply write anything printed with WriteString)
.data
yes BYTE “Yes”,0
no BYTE “No”,0
.code
MOV EAX, 10
CMP EAX, 5
JG _printYes
MOV EDX, OFFSET no
JMP _finished
_printYes:
MOV EDX, OFFSET yes
_finished:
CALL WriteString
Yes
Suppose that result is declared as DWORD, and the following MASM code is executed:
MOV EAX, 17
MOV EBX, 2
MOV ECX, 6
_label5:
ADD EAX, EBX
ADD EBX, 2
LOOP _label5
MOV result, EAX
What is the value stored in the memory location named result?
59
Select the pseudo-code that corresponds to the following assembly code. Assume that the variables a, b, c, and d are initialized elsewhere in the program.
You may want to review the usage of EAX, AH, and AL (IA32 registers).
Also recall that the inequality a > b is equivalent to b < a.
i.e. If A is greater than B, that’s equivalent to saying that B is less than A
.data
; General purpose variables
a SDWORD ?
b SDWORD ?
c SBYTE ?
d SBYTE ?
upperLevel SDWORD 18
lowerLevel SDWORD 3
; Strings
yes BYTE “Yes”,0
no BYTE “No”,0
maybe BYTE “Maybe”,0
.code
main PROC
MOV EAX, 1
CMP AH, c
JG option1
JMP option3
option1:
MOV EDX, OFFSET yes
CALL WriteString
JMP endOfProgram
option2:
MOV EDX, OFFSET no
CALL WriteString
JMP endOfProgram
option3:
MOV EDX, OFFSET maybe
CALL WriteString
endOfProgram:
exit
main ENDP
END main
if (c < 0):
print (yes)
else:
print (maybe)
In debugging mode, a ________ is a point in the program where execution will be paused.
breakpoint
(True/False) In debugging mode, the contents of internal memory and registers can be viewed when a breakpoint is encountered.
True
When branching, which register’s value changes? (Enter the three-letter register abbreviation only)
EIP
What is printed to the console window
.data
yes BYTE “Yes”,0
no BYTE “No”,0
.code
MOV EAX, 10
CMP EAX, 15
JS _printYes
MOV EDX, OFFSET no
JMP _finished
_printYes:
MOV EDX, OFFSET yes
_finished:
CALL WriteString
Yes because The CMP instruction performs a subtraction (e.g. CMP x, y does x – y) and updates the flags based on the result. In signed terms, if the left operand is smaller than the right (so the subtraction is negative), the most significant bit of the result will be 1, and thus SF is set.
What is printed to the console window
.data
yes BYTE “Yes”,0
no BYTE “No”,0
maybe BYTE “Maybe: “,0
.code
MOV EAX, 5
CMP EAX, 10
JG _printMaybe
_printNo:
MOV EDX, OFFSET no
JMP _finished
_printYes:
MOV EDX, OFFSET yes
JMP _finished
_printMaybe:
MOV EDX, OFFSET maybe
CALL WriteString
CMP EAX, 15
JL _printYes
JMP _printNo
_finished:
CALL WriteString
No
When using the LOOP instruction, one should be wary of which common issues/problems? (Check all that apply)
Initializing ECX to a value greater than zero.
Modifying ECX directly within the loop body.
Overwriting ECX’s original value in a nested loop body without preserving its outer loop counter value.
ECX not decrementing properly in the LOOP instruction itself.
Initializing ECX to a value less than or equal to zero.
Too many instructions in the loop body
Modifying ECX directly within the loop body.
Overwriting ECX’s original value in a nested loop body without preserving its outer loop counter value.
Initializing ECX to a value less than or equal to zero.
Too many instructions in the loop body
What is comparable high language code to the following:
.data
; General purpose variables
a SDWORD ?
b SDWORD ?
c SBYTE ?
d SBYTE ?
upperLevel SDWORD 18
lowerLevel SDWORD 3
; Strings
yes BYTE “Yes”,0
no BYTE “No”,0
maybe BYTE “Maybe”,0
.code
main PROC
MOV EAX, 0
MOV EBX, a
startLoop:
CMP EAX, EBX
JGE endOfProgram
MOV EDX, OFFSET no
CALL WriteString
INC EAX
JMP startLoop
MOV EDX, OFFSET maybe
CALL WriteString
endOfProgram:
exit
main ENDP
END main
for k in range (0, a):
print (no)