©BRIGHSTARS 2024/2025 ALL RIGHTS RESERVED.
COMSC 260 Test 2 Exam Questions With
Correct Answers.
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*
-------------------------
B-)
mov eax, 0
1|Page
, ©BRIGHSTARS 2024/2025 ALL RIGHTS RESERVED.
mov ecx, 5
jmp L2
L1:
add eax, eax
L2:
loop L1
-------------------------
A-)
mov eax, 0
mov ecx, 5
jmp L1
L1:
add eax, eax
L2:
loop L1
-------------------------
C-)
mov eax, 0
mov ecx, 6
jmp L1
L1:
2|Page
, ©BRIGHSTARS 2024/2025 ALL RIGHTS RESERVED.
add eax, eax
L2:
loop L1 - Answer✔*D-)*
*mov eax, 0*
*mov ecx, 6*
*jmp L2*
*L1:*
* add eax, eax*
*L2:*
* 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?
D-) mov [arr+SIZEOF arr - (SIZEOF arr -2)], 99
*B-) mov [arr+SIZEOF arr - (SIZEOF arr -1)], 99 *
3|Page
, ©BRIGHSTARS 2024/2025 ALL RIGHTS RESERVED.
C-) mov [arr+SIZEOF arr - SIZEOF arr -2], 99
A-) mov [arr+SIZEOF arr - SIZEOF arr -1], 99 - Answer✔*B-) mov [arr+SIZEOF arr -
(SIZEOF arr -1)], 99 *
When a loop instruction is encountered, and the jump is taken, which register is affected by the
jump?
*B-) EIP *
A-) ESI
C-) ESP
D-) EBP - Answer✔*B-) EIP *
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
4|Page