Professional Documents
Culture Documents
Question # 1. (5 points)
For each of the following variables, supply its type, length and size.
Variable
TYPE
LENGTH
SIZE
Question # 2. (4 points)
What is the value of table after executing the following statement ?
table
Question # 3. (3 points)
Give 3 examples of Assembly Language instructions: one with no operands, one with a single
operand (other than inc or dec), and one with two operands.
No operands : ____________________________
1-operand
: ____________________________
2-operands
: ____________________________
Question # 4. (3 points)
Write a data declaration directive for a sequence of 300 items, each containing the value 20000h.
1 of 6
BYTE
BYTE
WORD
WORD
SWORD
DWORD
0FFh, 1, 2
14h
0FFFFh, 1, 2
3
7FFFh, 8000h
10h, 20h, 30h, 40h
For each of the following instructions, indicate whether it is legal (L) or illegal (I). If illegal state
why.
a. mov
byte2, 0FFh
; _____________________
b. mov
word1, byte2
; _____________________
c. mov
word2, 10000h
; _____________________
d. mov
si, word1
; _____________________
; _____________________
f. movzx edx, bl
; _____________________
g. movzx word2, al
; _____________________
h. mov
; _____________________
dx, word3
; _____________________
j. movsx
; _____________________
dl, al
ax, 7FF0h
add
al, 10h
; CF =
SF =
ZF =
OF =
add
al, 1
; CF =
SF =
ZF =
OF =
add
ax, 2
; CF =
SF =
ZF =
OF =
b. mov
al, 80h
add
al, 80h
; CF =
SF =
ZF =
OF =
neg
al
; CF =
SF =
ZF =
OF =
2 of 6
BYTE
BYTE
WORD
WORD
SWORD
DWORD
0FFh, 1, 2
14h
0FFFFh, 1, 2
3
7FFFh, 8000h
10h, 20h, 30h, 40h
For the above data definitions, indicate the hexadecimal value of the destination operand. Use
the letter (I) to indicate that a particular instruction is illegal.
a. mov
ax, [word3+2]
; ax =___________________
b. mov
eax, [dword1+4]
; eax =__________________
c. mov
al, [byte1+1]
; al =___________________
d. mov
al, [byte1+1]
; al =___________________
e. mov
ax, word1
; ax =___________________
inc
ax
; ax =___________________
dec
ax
; ax =___________________
mov
ax, word3
; ax =___________________
neg
ax
; ax =___________________
add
ax, 0C2A5h
; ax =___________________
Part # 2.
Question # 8. (5 points)
Use the following data definitions:
dword1
DWORD
Implement the following expression in assembly language, using 32-bit integers (you may modify
any registers you wish). Do not write the entire program just the necessary instructions to
implement the expression.
eax = -dword1 + (edx ecx) + 1
SOLUTION:
3 of 6
Question # 9. (5 points)
What are the contents of EAX and ANSWER after executing the following?
.data
alist word 4000h, 5000h, 6000h
answer dword 0
.code
mov ebx, offset alist
mov eax, [ebx]
add eax, [ebx+4]
sub eax, [ebx+2]
mov [ebx+6], eax
SOLUTION:
EAX =
ANSWER =
EAX =
4 of 6
a. What will be the final value of AX after this code has executed?
mov esi, OFFSET var1
mov ecx, 4
mov eax, 100h
L1: add ax, [esi]
add ax, 8
add esi, TYPE var1
loop L1
SOLUTION:
AX =
b. Suppose we want EAX to contain the sum of the var1 array. Complete the missing
three instructions to be able to do so.
mov
edi, OFFSET var1
mov
ecx, LENGTHOF var1
?
?
?
loop L1
SOLUTION:
5 of 6
Part # 3.
Write an assembly program that first moves the four values: 1000h, 2000h, 3000h, 4000h stored in
Uarray to the EAX, EBX, ECX, and EDX registers respectively and then finds the sum of these
numbers and stores it in a memory location named ANSWER. Use the call DumpRegs to output the
original values and their sum.
GOOD LUCK
6 of 6