Week Two Flashcards

1
Q

For compound conditions using AND, should each condition jump to a falseBlock or a trueBlock?

A
  • check condition1 using CMP
  • if condition1 is false, jump to falseBlock
  • check condition2 using CMP
  • if condition2 is false, jump to falseBlock
  • code for TRUE block
  • jump to endBlock
  • falseBlock:
  • code for FALSE block
  • endBlock
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

For compound conditions using OR, should each condition jump to a falseBlock or a trueBlock?

A
  • check condition1 using CMP
  • if condition1 is true, jump to trueBlock
  • check condition2 using CMP
  • if condition2 is true, jump to trueBlock
  • code for FALSE block
  • jump to endBlock
  • trueBlock:
  • code for TRUE block
  • endBlock
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For an if statement, where should the condition jump to?

A
  • check condition using CMP
  • if condition is false, jump to end
  • code for TRUE block
  • end:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

For an if - else statement, should the condition jump to a falseBlock or a trueBlock?

A
Method One
• check condition using CMP
• if condition is false, jump to falseBlock
• code for TRUE block
• jump to end
• falseBlock:
• code for FALSE block
• end:
Method Two
• check condition using CMP
• if condition is true, jump to trueBlock
• code for FALSE block
• jump to end
• trueBlock:
• code for TRUE block
• end:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

For an if - else: if - else statement, should the condition jump to a falseBlock or a trueBlock?

A
  • check condition1 using CMP
  • if condition1 is true, jump to trueBlock1
  • check condition2 using CMP
  • if condition2 is true, jump to trueBlock2
  • code for FALSE block
  • jump to endBlock
  • trueBlock1:
  • code for TRUE block1
  • jump to endBlock
  • trueBlock2:
  • code for TRUE block2
  • endBlock:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
J(conditional) instructions:
JE
JL
JG
JLE
JGE
JNE
A
• JE jump if destination = source
• JL jump if destination < source
• JG jump if destination > source
• JLE jump if destination <= source
• JGE jump if destination >= source
• JNE jump if destination not = source
• NOTE: These conditions are for signed integers
– OK to compare negative to non-negative, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the PUSH instruction do?

A

The PUSH instruction first decrements ESP and then copies a source operand into the stack. A 16-bit operand causes ESP to be decremented by 2. A 32-bit operand causes ESP to be decremented by 4.

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

What does the POP instruction do?

A

The POP instruction first copies the contents of the stack element pointed to by ESP into a 16- or 32-bit destination operand and then increments ESP. If the operand is 16 bits, ESP is incremented by 2; if the operand is 32 bits, ESP is incremented by 4.

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

Define a MASM constant for your name as a z-byte terminated string.

A

MY_NAME EQU

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

What is the size of the string in the following MASM data segment declaration?
.data
stones BYTE ”You Can’t Always Get What You Want.”, 10, 13, 0

A

35 for the text + 1 for each number following = 38

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

What is the purpose of a breakpoint during a program debugging session?

A

It pauses execution, so the programmer can view the contents of memory, registers, etc.

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

Which function key is used to execute a library procedure, without going into the details of the
procedure?
F ______

A

F10: step over

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
When execution is paused at a breakpoint, which function key is used to continue execution to the
next breakpoint (or to the end of the program if no more breakpoints exist)?
F \_\_\_\_\_\_
A

F5: continue

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

The MASM assembler is used for locating __________ errors, but the debugging system is used for
locating _________ errors.

A

a. syntax

b. logic, run-time, or execution

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

What is a pre-test loop?

A

A while loop. Comparison is made before each iteration.

; initialize accumulator
     mov eax, x
dblLoop:               
                            ; Double x while x <= 1000
     cmp eax, 1000
     jg endLoop 
                      ; if condition false, jump to end
     add eax, eax
     jmp dblLoop

endLoop:
mov x, eax

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

What is a post-test loop?

A

A do-while or repeat until loop. Comparison is made after each iteration.

; initialize accumulator
     mov eax, x
dblLoop:                 
                              ; Double x while x <= 1000
     add eax, eax
     cmp eax, 1000
     jle dblLoop        ; If condition true, jump top
     mov x, eax
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is a counted loop?

A

A for loop.

; initialize accumulator, first number, and loop control
mov eax, 0
mov ecx, 10
sumLoop: ; add integers from 10 to 1
add eax, ecx
loop sumLoop ; subtract 1 from ecx, if ecx ≠ 0,
; go to sumLoop
; Print result
call WriteDec ; displays 55

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

How do you convert hex to:

a. signed binary
b. signed decimal
c. unsigned binary
d. unsigned decimal

A

a. Simply convert to binary
b. Find the two’s complement of hex number and then convert to decimal, placing a negative sign in front of the decimal number
c. Simply convert to binary
d. Simply convert to decimal

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

How do you convert decimal to:

a. signed binary
b. signed hex

A

a. Convert the positive integer to binary. Then find the two’s complement by flipping the bits and adding one.
b. Either find the hex equivalent of the binary two’s complement, or convert the positive integer to binary. Then find the two’s complement by subtracting each hex digit from 15 and adding one.

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

How do you convert decimal to:

a. unsigned binary
b. unsigned hex

A
a. Divide the number by 2 and turn the remainders into binary from bottom to top.
Decimal 28 to binary:
28/2 = 14 R 0
14/2 =   7 R 0 
7/2 =    3 R 1
3/2 =    1 R 1
1/2 =     0 R 1
Binary = 0001 1100

b. Convert to binary, then convert each nibble to a hex digit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
The following data segment starts at memory address 0x3000 (hexadecimal)
0 .data
1 printString BYTE "Assembly is fun",0
2 moreBytes BYTE 19 DUP(0)
3 dateIssued DWORD ?
4 dueDate DWORD ?
5 elapsedTime WORD ?

What is the hexadecimal address of dueDate?

A

Line 1 = 0x3000 + 16d = 0x3010
Line 2 = 0x3010 + 19d = 0x3023
Line 3 = 0x3023 + 4d = 0x3027

Thus line 4’s hexadecimal address starts at 0x3027

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

The following data segment starts at memory address 0x2300 (hexadecimal)
.data
printString BYTE “Do not add decimal to hex”,0
someBytes WORD 42 DUP(0)
moreBytes BYTE 10, 20, 30, 40, 50, 60, 70, 80, 90
questionAddr DWORD ?
ignoreMe WORD ?

What is the hexadecimal address of questionAddr?

A

Line 1 = 0x2300 + 26d = 0x231A
Line 2 = 0x231A + 2*42 = 0x236E
Line 3 = 0x236E + 9 = 0x2377

Thus line 4’s hexadecimal address starts at 0x2377

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
After the following MASM code is executed:
    mov    eax,57
    mov    ebx,50
    mov    ecx,50
    add    eax,ebx
    sub    eax,ecx

What is the value in the eax register (in decimal)?
What is the value in the ebx register (in decimal)?
What is the value in the ecx register (in decimal)?

A

a. 57
b. 50
c. 50

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q
After the following MASM code is executed:
    mov    eax,111
    mov    ebx,11
    mov    edx,0
    div    ebx

What is the value in the eax register (in decimal)?
What is the value in the ebx register (in decimal)?
What is the value in the edx register (in decimal)?

A

a. 10
b. 11
c. 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the Instruction Execution steps? | Step 1-6
Step 1: The control unit fetches the next instruction from the instruction queue. Step 2: The control unit increments the instruction pointer. Step 3: The control unit decodes the instruction's function to determine what the function will do. Step 4: If the instruction uses an input operand located in memory, the control unit uses a read operation to retrieve the operand. Sometimes this involves address calculations. Step 5: the ALU executes the instruction, using the named registers and internal registers as operands. It also updates a few status flags. Step 6: If the output operand is in memory, the control unit uses a write operation to store the data.
26
What is the pseudo-code that corresponds to the following assembly code. ``` .data a DWORD ? b DWORD ? c BYTE ? d BYTE ? ``` ``` .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);
27
What is the pseudo-code that corresponds to the following assembly code. ``` .data a DWORD ? b DWORD ? c BYTE ? d BYTE ? ``` ``` .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 = 0; k < a; k++) | print (no);
28
The MOVZX instruction is only used with unsigned integers.
True
29
The MOVSX instruction is only used with unsigned integers.
False
30
What does the CARRY flag do?
Indicates unsigned integer overflow.
31
What does the OVERFLOW flag do?
Indicates the result of a signed arithmetic operation is too large or too small to fit into the destination.
32
What does the ZERO flag do?
Indicates that an operation produced zero.
33
What does the SIGN flag do?
Indicates that an operation produced a negative result.
34
What does the PARITY flag do?
Indicates whether or not an even number of 1 bits occurs in the least significant byte of the destination operand.
35
What does the AUXILIARY CARRY flag do?
The Auxiliary flag is set (to 1) if during an "add" operation there is a carry from the low nibble (lowest four bits) to the high nibble (upper four bits), or a borrow from the high nibble to the low nibble, in the low-order 8-bit portion, during a subtraction.
36
The MOVSX instruction sign-extends an integer into a larger operand.
True
37
What code best implements the following expression. Do not permit dword1, ECX, or EDX to be modified: eax = -dword1 + (edx - ecx) + 1
``` mov eax,dword1 neg eax mov ebx,edx sub ebx,ecx add eax,ebx inc eax ```
38
The following instructions will set: a. the Carry flag b. the Sign flag mov al,0FEh sub al,2
a. False | b. True
39
If the LOOP instruction sets ECX to zero, a jump to the destination label will take place.
False
40
Which of the following affect the Carry flag? inc dec neg
Neg only
41
What will be the value of EAX when the following sequence of instructions has executed? push 5 push 10 push 20 pop eax
20
42
Which library procedure sets the Zero flag if the AL register contains the ASCII code for a decimal digit (0–9)?
IsDigit
43
Which library procedure locates the cursor at a specific row and column on the screen?
Gotoxy
44
Which I/O device is used for standard input?
Keyboard
45
What does the PUSH instruction do?
It decrements the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer.
46
Which CALL instruction writes the contents of EAX to standard output as a signed decimal integer?
WriteInt
47
Which library procedure displays the CPU flags and 32-bit registers?
DumpRegs
48
The linker combines object files into an executable file.
True
49
By default, labels are visible only within the procedure in which they are declared.
True
50
``` Which of the following code sequences assigns the value 0x10 to EBX? (select all that are correct) a. mov edx,20h push edx mov ecx,10h push ecx pop ebx pop edx ``` ``` b. mov ecx,10h mov edx,20h push ecx push edx pop ebx pop edx ``` ``` c. mov edx,20h push edx mov ecx,10h push ecx pop ebx pop edx ``` ``` d. push 20h mov ecx,10h push ecx pop eax pop ebx ```
A and C
51
The instructions used to manipulate the ESP regieter are?
CALL, PUSH, POP, RET
52
Mechanically speaking, the CALL instruction pushes its return address on the stack and copies the called procedure’s address into the instruction pointer.
True
53
Adding 5 to 0FBh in an 8-bit register sets the Zero flag.
True
54
What are the valid uses of the XCHG instruction?
XCHG mem,reg XCHG reg,reg XCHG reg,mem
55
Adding 0FFh and 05h in an 8-bit register sets the Overflow flag.
False
56
The ________ procedure advances the cursor to the beginning of the next line in the console window.
Crlf
57
The USES operator, coupled with the PROC directive, lets you list the names of all registers modified within a procedure.
True
58
ESP always points to the ______
last value to be added to, or pushed on, the top of stack.
59
Which register contains an integer before calling WriteDec?
EAX
60
Which library procedure writes an unsigned 32-bit integer to standard output in hexadecimal format?
WriteHex
61
Which library procedure reads a 32-bit signed decimal integer from standard input?
ReadInt