Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Which answer choice shows the correct values of the Carry, Zero, and Sign fla

ID: 3531445 • Letter: 1

Question



1. Which answer choice shows the correct values of the Carry, Zero, and Sign flags after the following instructions execute?
mov al,00110011b
test al,2
Choose one answer.
a. CF= 0, ZF = 1, SF = 0
b. CF= 1, ZF = 0, SF = 1
c. CF= 0, ZF = 0, SF = 0
d. CF= 1, ZF = 0, SF = - 1


2. Which answer choice shows the correct values of the Carry, Zero, and Sign flags after the following instructions execute?

A. and dl,0Eh
cmp dl,0Eh
jnz L4

B. test dl,0Eh
jnz L4

C. and dl,07h
cmp dl,07h
je L4

D. and dl,0Eh
cmp dl,0Eh
je L4
Choose one answer.
a. A and B
b. D
c. A
d. A, and D

3. Which choices contain correct implementations of the following pseudocode? (Assume that all values are unsigned):
if( eax > ebx )
mov dl,5;
else
mov dl,6;
a.
cmp eax,ebx
ja L1
mov dl,6
jmp L2
L1: mov dl,5
L2:
------------------------------
b.
cmp eax,ebx
ja L1
mov dl,5
jmp L2
L1: mov dl,6
L2:
-------------------------------
c.
cmp eax,ebx
jbe L2
mov dl,5
jmp L2
L1: mov dl,6
L2:
-----------------------------
d.
cmp eax,ebx
jna L1
mov dl,5
jmp L2
L1: mov dl,6
L2:
Choose one answer.
a. a and b
b. d and c
c. a and d
d. c and a

4. Use the following data for the next question . All values are signed:
.data
val1 SDWORD ?
val2 SDWORD ?

Which selection is the correct implementation of the following pseudocode?
if( val1 > val2 || val2 > eax )
mov ebx,1;
else
mov ebx,2;

a.
mov val1, ebx
cmp ebx, val2
jng L1
cmp val2,eax
jg L1
mov ebx,2
jmp L2
L1: mov ebx,1
L2:
------------------------------
b.
mov val1,ebx
cmp ebx,val2
jg L1
cmp val2,eax
jg L1
mov ebx,2
jmp L2
L1: mov ebx,1
L2:
---------------------------------------
c.
mov val1,ebx
cmp val2,ebx
jg L1
cmp val2,eax
jg L2
mov ebx,2
jmp L2
L1: mov ebx,1
L2:
-----------------------------------
d.
mov val1,ebx
cmp ebx,val2
jle L1
cmp val2,eax
jle L1
mov ebx,1
jmp L2
L1: mov ebx,2
L2:
Choose one answer.
a. c and d
b. a, and b
c. a
d. b

5. What will be the final values of CX and DX when the following code executes?
.data
array SWORD 8,2,3,5,-4,6,0,4
.code
mov cx,1
mov esi,2
mov ax,array[esi]
mov bx,array[esi+4]
cmp ax,3
jae L2
cmp bx,4
jb L1
jmp L3
L1: mov cx,4
L2: mov dx,5
jmp L4
L3: mov dx,6
L4:
Choose one answer.
a. CX = 4, DX = 5
b. CX = 1, DX = 5
c. CX = 4, DX = 6
d. CX = 1, DX = 6

6. In Protected mode (flat model), which of the following CALL instructions executes an indirect call to a procedure whose address is stored in a memory location pointed to by EBX?

(You can use boxed text on page 209 of your text book for this question)
Choose one answer.
a. call DWORD PTR [ebx]
b. call NEAR PTR [ebx]
c. call FAR [ebx]
d. call [ebx]
7. What is the binary value of AL after the following instructions have executed?

mov al,10000101b
clc
rcr al,1


Choose one answer.
a. 0100 0010
b. 1100 0010
c. 0100 0011
d. 0100 1010

8. What is the binary value of AL after the following instructions have executed?
mov al,01101011b
stc
rcl al,2
Choose one answer.
a. 1011 0111
b. 0111 0011
c. 1010 1110
d. 1110 0001

9. What is the binary value of AX after the following instructions have executed?
mov ax,0000000010011101b
mov bx,1010101010001011b
shrd ax, bx, 2
Choose one answer.
a. 1100 1111 0010 0111
b. 1101 0000 0010 0111
c. 1100 0000 0011 0111
d. 1100 0000 0010 0111


10. What will be the value of the Overflow flag after the following instructions have executed?
mov dx,-16
mov ax,2
imul dx
Choose one answer.
a. DX=FEFFh, AX=FFE0h
b. DX=FFF0h, AX=FFE0h
c. DX=FFFFh, AX=FFE0h


11. What will be the hexadecimal values of DX and AX after the following instructions have executed?

mov dx,000Fh
mov ax,6342h
mov bx,100h
div bx


Choose one answer.
a. DX=0042h AX=0F63h
b. DX=0F42h AX=0F63h
c. DX=0042h AX=0042h
d. DX=0E42h AX=0F62h


12. Following are series of instructions that will multiply EAX by 18, using a combination of shift, MOV, and ADD instructions. (TRUE / FALSE)

mov ebx,eax ; make copy
shl eax,4 ; eax * 16
shl ebx,1 ; ebx * 2
add eax,ebx
Answer:
True False


13. Write a sequence of two instructions that copies the integer in bits 4-7 from the AL register into bits 0-3 of the BL register. The upper 4 bits of AL will be cleared, as will the upper 4 bits of BL
Choose one answer.
a. shr a2, 4 then mov b1, a1
b. shr a1, 4 then mov b1, a2
c. shr a1, 3 then mov b1, a1
d. shr a1, 4 then mov b1, a1


14. Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged.
Choose one answer.
a. mov b1, a2 then b1, 00111111b
b. mov b1, a1 then b1, 001111110
c. mov b2, a1 then b1, 00111111b
d. mov b1, a1 then b1, 00111111b


15. Write a sequence of instructions that divide -16 by 5, using the IDIV instruction. Use the EBX register as the divisor. (True/False)



mov eax,-16
cdq ; very important!
mov ebx,5
idiv ebx

Answer: True/False

16. Suppose we want to copy the value of the Carry flaginto bit 7 of AL, and shift all existing bitsin AL oneposition to the right. Which of the following instructions will work?
Choose one answer.
a. rcr al,1
b. shr al,1
c. ror al,1
d. sar al,1


17. Select correct answer for each question
a.) Which of the following instructions will multiply the integer in EBX by 32?
b.) Given that EAX contains FFFF80C0h, which of the following would be true after executing the CWD instruction?
c.) Which of the following instructions will divide the unsigned integer in EBX by 8

answer bank (DX=FFFFh, AX=80C0h / shl ebx, 3 / shl ebx, 5)


18. What will be the hexadecimal values of DX and AX after the following instructions have executed?
mov ax, 3456h
mov dx, 12h
mov bx, 10h
div bx
Choose one answer.
a. DX=0006h, AX=2345h
b. DX=1234h, AX=0056h
c. DX=0056h, AX=1234h
d. cannot be determined


19. Which of the following blocks of instructions will multiply the contents of the EDX register by 36?
a.
mov ebx,edx
shl edx,5
shl ebx,2
add ebx,edx
-----------------------------
b.
mov ebx,edx
shl edx,5
shl ebx,2
add edx,ebx
-----------------------------
c.
mov ebx,4
add edx,ebx
shl edx,2
shl ebx,5
add edx,ebx
-----------------------------
d.
mov ebx,edx
shl ebx,5
shl edx,2
add edx,ebx
Choose one answer.
a. b, and d
b. b, and c
c. d, and c
d. a and b


20. Given the following two assignments to AX and DX, which block of instructions will cause DX to equal 4025h and AX to equal 1AD2h?
mov ax,6B49h
mov dx,0095h


a

shr ax,1
rcr dx,1
shr ax,1
rcr dx,1


c

shl ax,2
shr dx,1
rcl dx,1

b

shr ax,2
rcr dx,1
shl ax,1


d

shr ax,1
rcl dx,2
rcr ax,1
shl dx,1

Choose one answer.
a. b, and c
b. a and c
c. d and c
d. a


22. Following procedure named UseThree that has three unsigned integer stack parameters: a byte, a word, and a doubleword

UseThree PROC,
one:BYTE, two:WORD, three:DWORD

ret
UseThree ENDP

Answer:
True False


23. Add a local variable named var1 of type DWORD to the UseThree procedure .

UseThree PROC,
one:BYTE, two:WORD, three:DWORD
LOCAL var1:DWORD
ret
UseThree ENDP

Answer:
True False


24. Show the entry code generated by the assembler for the UseThree procedure (in the previous question).

push ebp
mov ebp, esp
add esp, 0FFFFFFFCh ; alternative: sub esp,4

Answer:
True False


25. Suppose we define the following procedure:

Example2 PROC,
one:DWORD, two:DWORD
mov eax,one
mov ebx,[ebp+12]
call DumpRegs
ret
Example2 ENDP

If we called Example2 using the following statement, what values would be displayed in EAX and EBX?

INVOKE Example2, 10h, 20h
Choose one answer.
a. EAX=00000020h, EBX=00000010h
b. EAX=00000010h, EBX=00000010h
c. EAX=00000010h, EBX=00000020h
d. EAX=00000020h, EBX=00000020h


26. Suppose we were to call a procedure named ProcOne, passing it two value parameters. The procedure adds the two parameters and returns their sum in EAX:

push 5
push 10
call ProcOne ; EAX = sum

To create the implementation of ProcOne, using explicit stack parameters (such as [ebp+n]). Follow other common conventions regarding the saving and restoring of registers. Restore the stack pointer using the STDCALL calling convention, and assume a 32-bit memory model. Following code is (TRUE / FALSE)
ProcOne PROC
push ebp
mov ebp,esp
mov eax,[ebp+8]
add eax,[ebp+12]
pop ebp
ret 8
ProcOne ENDP

Answer:
True False

27. Which of the following are true regarding local variables?
a. They make efficient use of memory because their storage space can be released.
b. They can be accessed from anywhere inside the same source code module.
c. They are usually created in the data segment
d. The same variable name can appear in two different procedures
Choose one answer.
a. a and b
b. c and d
c. a and d
d. b and c


28. How are static variables distinguished from global variables?


a. Global variables are visible from all procedures in the source code file.
b. Static variables have a shorter lifetime than global variables.
c. The lifetime of a static variable is the same as the lifetime of its program.
d. Static variables are created on the stack, using the ESP and EBP registers.
Choose one answer.
a. a and d
b. a and c
c. a and b
d. b and d

29. Let assume we have Example 2: The Accum Procedure
main PROC
mov eax,0
push 8
call Accum
call DumpRegs
exit

main ENDP
Accum PROC
push ebp
mov ebp,esp
mov ebx,[ebp+8]
cmp ebx,2
je L1
add eax,ebx
sub ebx,2
push ebx
call Accum
L1: pop ebp
ret 4
Accum ENDP
a.) Refer to Example 2. How many times will the ADD EAX,EBX statement execute?
b.) Refer to Example 2. What will be the value of EAX when DumpRegs is called?
c.) Refer to Example 2. Suppose we changed the last statement in the Accum procedure to the following: ret 8 What would happen when running the program?
d.) Refer to Example 2. What will be the value of EBX when DumpRegs is called?
e.) Refer to Example 2. How many stack bytes are used by each call to Accum?

answer bank (12h / 3 / The program would halt with a run time error / 2 / 12 bytes)









Explanation / Answer

1.

The contents of al is 0011 0011b, by performing test instruction the result will be 0000 0010.

Therefore, no flag will be set.

Hence, the correct answer is option (c).

2.

Test instruction is used to test the carry zero and sign flags.

Hence, the correct answer is option (b).

3.

Ja instruction is used to jump when the contents of eax are greater than ebx.

Hence, the correct answer is option (a).

4.

Correct answer is option (c).

5.

Correct answer is option (a).

6.

In protected mode, call [ebx] instruction executes an indirect call to a procedure whose address is stored in a memory location pointed by EBX.

Hence, the correct answer is option (c).

7.

RCR (Rotate Right through Carry) instruction shifts the bits towards right and place the carry bit at MSB (Carry flag holds the last bit rotated out and the shifted bit is placed at MSB side).

Initially al is loaded with 1000 0101

After executing rcr with count 1, al becomes 1100 0010.

Hence, the correct answer is option (a).

8.

RCL (Rotate Left through Carry) instruction shifts the bits towards left and place the carry bit at LSB (Carry flag holds the last bit rotated out and the shifted bit is placed at LSB side).

Initially al is loaded with 0110 1011

After executing rcr with count 2, al becomes 1010 1110.

Hence, the correct answer is option (c).

10.

imul is an instruction used to perform signed multiplication. The values of dx and ax after the execution are shown as follows:

Dx = -16h (the sign is negative, therefore convert the number into 2’s complement form)

2’s complement of 16 = FFEAh

Ax = 0002h

After executing imul instruction DX = FFFFh and AX = FFE0h.

Hence, the correct answer is option (c).

11.

The hexadecimal value of DX is 0042h and AX is 0F63 after executing the div instruction.

Hence, the correct answer is option (a).

12.

The series of instructions given below will not multiplies the EAX by 18 using the shift, mov and ADD instructions.

For example consider EAX = 2h

Copy the contents of eax to ebx;

By perform shift left by count 4, eax will be 0. Now, multiply eax with 16 will give 0.

By perform shift left by count 1, ebx will be 0001h. Now, multiply ebx with 2 will give 2

Addition of eax and ebx will gives 2.

Hence, the given statement is FALSE.

13.

By performing shift right with count 4 and then move the contents from a1 to b1 will copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Since, the upper 4 bits of AL and BL will be cleared.

Hence, the correct answer is option (d).

15.

The sequence instructions given below divide the numbers -16 by 5 using IDIV instruction.

Hence, the given statement is TRUE.

16.

Shift right al by 1 will gives the copy of the carry flag into bit 7 of AL and shift all existing bits in AL one position to the right.

Example:

AX = 0100 0011 (MSB bit is the carry bit that is 0 in the example), now by perform right shift by 1, carry flag bit moves right towards 1 position (carry flag moves into 7th bit of AL).

Hence, the correct answer is option (b).

18.

By executing the div instruction the value of DX is 0056h and AX is 1234h.

Hence, the correct answer is option (C).

20.

Initially ax is loaded with 6B49h and dx with 0095h. Convert ax and dx into binary format which is shown below:

ax = 6B49h = 0110 1011 0100 1001

dx = 0095h = 0000 0000 1001 0101

By executing the first instruction ax is 0011 0101 1010 0100

By executing the second instruction dx is 1000 0000 0100 1010

By executing the third instruction ax is 0001 1010 1101 0010 which is equal to 1AD2 in hexadecimal.

By executing the fourth instruction dx is 0100 0000 0010 0101 which is equal to 4025 in hexadecimal.

Hence, the correct answer is option (a).

22.

The following procedure UseThree has three unsigned integer stack parameters which are bye, word and double word.

Hence, the given statement is TRUE.

23.

From the following procedure, a local variable named as var1 is added to the type DWORD.

Hence, the given statement is TRUE.

27.

Local variables can make efficient use of memory because their storage space can be released and also a same variable name can appear in two different procedures.

Hence, the correct answer is option (c).

28.

Global variables are visible from all procedures in the source code file and the lifetime of a static variable is the same as the lifetime of its program.

Hence, the correct answer is option (b).