Assembly Language Test
Assembly Language Test
Assembly Language Test
6.
The MOV instruction does not permit an immediate value to be moved to a segment register.
a. true
6.
The MOVSX instruction sign-extends an integer into a larger operand.
a. true
7.
The DS register can be the destination operand of a MOV instruction.
b. false
8.
The ES register can the source operand of a MOV instruction.
a. true
9.
Adding 7Fh and 05h in an 8-bit register sets the Overflow flag.]
a. true
10. Adding 0FFh and 05h in an 8-bit register sets the Overflow flag. b. false
11. The following instructions will set the Carry flag:
mov al,0FEh
sub al,2 b. false
12. The following instructions will set the Sign flag:
mov al,0FEh
sub al,2 a. true
13. Where marked by a letter (a, b, c, d), indicate the hexadecimal value of the destination operand:
1.
2.
3.
4.
7.
mov ax,word1
inc ax
a. AX = 0000h
dec ax
b. AX = FFFFh
mov ax,word3
neg ax
c. AX = 8001h
add ax,0C2A5h
d. AX = 42A6h
14. Where marked by a letter (a, b, c, d), indicate the hexadecimal value of the destination operand:
mov al,7Fh
add al,2
a: ZF,CF,SF,OF= 0,0,1,1
sub al,5
b: ZF,CF,SF,OF= 0,0,0,1
mov al,80h
add al,80h
c: ZF,CF,SF,OF= 1,1,0,1
neg al
d: ZF,CF,SF,OF= 1,0,0,0
Write an instruction that moves the lower 16 bits of dword1 into the BX register (hint: use PTR).
mov bx,WORD PTR dword1
Write an instruction that moves the lower 8 bits of word2 into the AL register.
mov al,BYTE PTR word2
Write an instruction that moves EBX to location word1:
mov DWORD PTR word1, ebx
15. Implement the following expression in assembly language, using 32-bit integers (you may modify any registers you wish):
eax = dword1 + ebx - ecx
mov eax,dword1
add eax,ebx
sub eax,ecx
16. Implement the following expression in assembly language, using 32-bit integers (you may modify any registers you wish):
eax = -dword1 + (edx - ecx) + 1
sub edx,ecx
mov eax,dword1
neg eax
; eax = -dword1
add eax,edx
inc eax
Use the following data declarations to write an assembly language loop that copies the string from source to target. Use indexed addresing
with EDI, and use the LOOP instruction.
source BYTE "String to be copied",0
target BYTE SIZEOF source DUP(0),0
mov edi,0
mov ecx,SIZEOF source
L1:
mov al,source[edi]
mov target[edi],al
inc edi
loop L1
17. Which of the following CALL instructions writes the contents of EAX to standard output as a signed decimal integer?
d. call WriteInt
18. Which library procedure reads a string from standard input? ReadString
19. Write code that causes a 500 millisecond delay, using a library procedure.
mov eax,500 call Delay
20. Given the following data definition, write a sequence of statements that display a dump of the data in 32-bit hexadecimal, using the
DumpMem procedure from the link library.
array DWORD 10h,20h,30h,40h
mov esi,OFFSET array
mov ecx,LENGTHOF array
mov ebx,TYPE array
call DumpMem
21. Write a procedure named ShowBinary that displays the following array as a sequence of binary bits, starting with the low-order value
(00000010h). Include the use of the LENGTHOF, OFFSET, and TYPE operators, and call the WriteBin procedure.
array DWORD 10h,20h,30h,40h
ShowBinary PROC
mov ecx,LENGTHOF array
mov esi,OFFSET array
L1: mov eax,[esi]
; any 32-bit indirect register
call WriteBin
add esi,TYPE array
; 4 is ok also
loop L1
ret
ShowBinary ENDP
Write a procedure named Read10 that reads exactly ten characters from standard input into an array of BYTE named myString. Use the
LOOP instruction with indirect addressing, and call the ReadChar procedure from the book's link library. (ReadChar returns its value in AL.)
1 Read10 PROC
2 mov ecx,SIZEOF myString
24. What will be the hexadecimal value of AL after these instructions execute?
mov al,0CFh
and al,2Bh
a. 0Bh
25. What will be the hexadecimal value of AL after these instructions execute?
mov al,3Ch
or al,82h
c. BEh
26. What will be the hexadecimal value of AL after these instructions execute?
mov al,94h
xor al,37h
b. A3h
27. A WHILE loop can be constructed with a CMP instruction at the bottom of the loop, followed by a conditional jump instruction.
F
28. In a finite-state machine, transitions between states usually occur when a new value has been read from input.
T
1.
Code instructions that implement the following pseudocode using conditional jump instructions. Do not use the .IF directive. Assume that
integers are unsigned:
if( eax > ebx )
mov dl,5;
else
mov dl,6;
cmp eax,ebx
also:
cmp eax,ebx
jna L1
ja L1
mov dl,5 mov dl,6
jmp L2
jmp L2
L1:mov dl,6
L1: mov dl,5
L2:
L2: