Professional Documents
Culture Documents
Question 1: (08)
1. Write a single instruction (other than NOT) that reverses all the bits in EAX.
XOR EAX, 0FFFFFFFFH
2. (Yes/No): Will the following code jump to the label named Target?
mov ax,8109h
cmp ax,26h
jg Target
Yes
3. Write instructions that first clear bits 0 and 1 in AL. Then, if the destination operand is
equal to zero, the code should jump to label L3. Otherwise, it should jump to label L4.
and al,11111100b
jz L3
jmp L4
4. Write the INCLUDE directive that is required when using the Irvine32 library.
Include Irvine32.inc
6. (True/False) Only 16-bit values should be pushed on the stack when using the Irvine16
library.
False
7. Suppose there were no PUSH instruction. Write a sequence of two other instructions that
would accomplish the same as PUSH EAX.
sub esp,4
mov [esp],eax
8. (True/False): The USES operator lets you name all registers that are modified within a
procedure.
True
Question 2: What will EAX contain after the following instructions execute? (04)
.data
dVal DWORD ?
.code
mov dVal,12345678h
mov ax,WORD PTR dVal+2 EAX = 12341237
add ax,3
12341237
mov WORD PTR dVal,ax
mov eax,dVal
Question 3: (08)
Fill in the requested register values on the right side of the following instruction
sequence:
myBytes BYTE 40h, 30h, 20h, 10h
myWords WORD 8Ah, 3Bh, 72h, 44h, 66h
myDoubles DWORD 1, 2, 3, 4, 5
myPointer DWORD myDoubles
Question 4: (04)
Write down the output of the following assembly language code, also mention in case if
there is no output or any error in the program.
INCLUDE Irvine32.inc
.386
.model flat, stdcall
.stack 4096
.data
msg BYTE "when things go wrong don’t go with them",0
array1 BYTE SIZEOF msg DUP(0)
.code
main proc
mov esi, 0
mov ecx, 8h
L1: mov al, msg[esi+4]
mov array1[esi], al OUTPUT: things
inc esi
LOOP L1
mov edx, offset array1
call writeString
exit
main endp
end main
Question 5: (06)
In the following instruction sequence, show the values of the Carry, Zero, and Sign flags
where indicated:
mov al,00001111b
test al,00000010b ; a. CF = 0 ZF = 0 SF = 0
mov al,00000110b
cmp al,00000101b ; b. CF = 0 ZF = 0 SF = 0
mov al,00000101b
cmp al,00000111b ; c. CF = 1 ZF = 0 SF = 1
Question 6: Write down the output of the following assembly language code, also mention in
case if there is no output or any error in the program. (06)
INCLUDE Irvine32.inc
.386
.model flat, stdcall
.stack 4096
.data
msg BYTE "a feeling of deep admiration for someone or something
elicited by their abilities, qualities, or achievements",0
array1 BYTE SIZEOF msg DUP(0)
.code
main proc
mov esi, 0
mov ecx, 0Ah
L1: mov al, msg[esi+18]
Output: Admiration
mov array1[esi], al
inc esi
LOOP L1
mov edx, offset array1
call writeString
exit
main endp
end main
Question 7: (04)
In the following instruction sequence, show the resulting value of AL where indicated, in
hexadecimal:
mov al,7Ah
not al ; a. 85h
mov al,3Dh
and al,74h ; b. 34h
mov al,9Bh
or al,35h ; c. BFh
mov al,72h
xor al,0DCh ; d. AEh