Module 3 Quiz Questions Flashcards

1
Q

(True/False) In debugging mode, the values of watched variables/registers may only be viewed in hexadecimal format.

A

false, you can toggle between hex and decimal view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

F5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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?

A

&userName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The MASM assembler is used for locating ________ errors, but the debugging system is used for locating _____, ________, or _____ errors.

A

syntax,
Logic, runtime, or execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Conditional jumps check flags in which register before jumping?

A

status register

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When branching in MASM, you will normally jump to ___________ .

A

a code label (representing an address in the code segment)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Correctly match the status flags to their description.
- The carry flag
- the overflow flag
- the sign flag
- the zero flag
- the parity flag

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Match the Conditional Jump instruction to its operation.
JA
JG
JNZ
JE
JC
JECXZ

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Please select the appropriate description of the LOOP instruction.

A

Decrement ECX, then Jump if ECX is nonzero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

If the LOOP instruction sets ECX to zero, a jump to the destination label does take place.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

Maybe: No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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?

A

59

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

if (c < 0):
print (yes)
else:
print (maybe)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In debugging mode, a ________ is a point in the program where execution will be paused.

A

breakpoint

17
Q

(True/False) In debugging mode, the contents of internal memory and registers can be viewed when a breakpoint is encountered.

18
Q

When branching, which register’s value changes? (Enter the three-letter register abbreviation only)

19
Q

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

A

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.

20
Q

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

21
Q

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

A

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

22
Q

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

A

for k in range (0, a):
print (no)