You are on page 1of 6

Part # 1.

Straightforward Questions (65 points)

Question # 1. (5 points)
For each of the following variables, supply its type, length and size.
Variable

TYPE

LENGTH

SIZE

var1 dword 5 dup (3 dup (0))


var2 word 10 dup (0FFFFh)
msg byte hello there, 0

Question # 2. (4 points)
What is the value of table after executing the following statement ?
table

byte 4 dup (3 dup (0), 2 dup (X), 4 dup(5))

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

Question # 5. (20 points)


Use the following data definitions:
byte1
byte2
word1
word2
word3
dword1

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

; _____________________

e. movzx ax, byte1

; _____________________

f. movzx edx, bl

; _____________________

g. movzx word2, al

; _____________________

h. mov

; _____________________

dx, word3

i. movsx eax, byte1

; _____________________

j. movsx

; _____________________

dl, al

Question # 6. (10 points)


The following sequences of instructions implement certain arithmetic expressions. Where indicated,
write down the values of the Carry, Sign, Zero, and Overflow flags after each instruction has
executed:
a. mov

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

Question # 7. (20 points)


Use the following data definitions:
byte1
byte2
word1
word2
word3
dword1

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.

Short Programming and Tracing Questions (25 points)

Question # 8. (5 points)
Use the following data definitions:
dword1

DWORD

10h, 20h, 30h, 40h

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 =

Question # 10. (5 points)


What is the result of the EAX register after executing the following?
.data
array1 word 600h, 700h, 800h, 500h, 400h
count = ($ - array1) / 2
.code
mov eax, 0
mov edi, offset array1
mov ecx, count
L1: add eax, [edi]
add edi, 2
loop L1
SOLUTION:

EAX =

4 of 6

Question # 11. (10 points)


Use the following data definition:
var1
var2

WORD 5000h, 4000h, 3000h, 2000h, 1000h


DWORD 40000h, 30000h, 20000h, 10000h

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.

Programming Question (10 points)

Question # 12. (10 points)


--- use the back

of the page if needed ----

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

You might also like