CS401 Assembly Language
Mid Term Examination – Spring 2006
Time Allowed: 90 Minutes
Please read the following instructions carefully before attempting any
1. This examination is open books, open handouts and quiet
2. Answer all questions.
a. There is no choice.
b. You will have to answer correctly all questions in this
examination to get the maximum possible marks.
3. Do not ask any questions about the contents of this examination
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve
4. You have been provided with all assembly tools so you can use
assembly tools also.
5. Your paper contains 4 questions.
All Coding questions should be answered using the Assembly language
Question No. 1
What is wrong with each of the following instructions?
Marks : 10
MOV BL, CX
MOV ES, SS
MOV [BX], [DI]
MOV [BYTEVAR], 20
v. MOV , [ 92]
Question No. 2
Marks : 10
Find errors in the code given below and write error description against each erroneous
var1 dw 34, 21, 25, 20, 23, 21, 29, 14, 42, 10
var2 dw 0
var3 dw 0
mov 5, 0
mov bx, 0
cmp ax, 20
mov bh, ax
mov [var2], bx
mov cx, [var1+ bx]
add ax, [bx-si]
add bx, 2
cmp bx, [bx+bp]
cmp [si+di], cx
mov [var2+bx], [var1+bx]
mov [var3 ], cx
mov bx, [index1]
mov ax, 0x4d00
Question No. 3
Marks : 10
Answer the following Questions.
Which registers are changed by the CMP instructions?
Write a instruction to change the sign bit of AX.
What is the difference between a TEST and AND instruction?
What is the difference between little endian and big endian formats?
What is the function of segment override prefix and what changes it brings to the
Question No. 4
MSG: db ‘this is a message’
Write code to replace each lowercase letter in the following string by its upper case
equivalent. Use index address mode.
b) Write valid instruction(s) to perform each function specified below.
Marks : 20
Provide instruction to read a value from port number 0x312
Provide instruction to move the value at the top of the stack in IP register
Provide instruction to move value of flag register in AX.
Provide instruction to divide value of AX by 8.