COAL Final - Fall 2018 - FAST LHR
COAL Final - Fall 2018 - FAST LHR
Question1. Answer the following multiple choice questions. NO cutting or Over Writing. [2x10 Marks]
For this question, please put your answers in the following table. No answer will be marked other than this table.
i. vi.
ii. vii.
iii. viii.
iv. ix.
v. x.
i. Assume the initial values for registers/flags are: DF=0, SI=0x100, DI=0x200. And the following are the initial
memory values at given memory address:
Memory Address 0 1 2
0x0100 0x10 0x15 0x22 …
0x0200 0x20 0x25 0x21 …
After executing the movsb instruction, the updated values of registers and relevant memory address will be:
a. 0x100 contains 0x20, 0x200 contains 0x20, DI=0x201, and SI=0x101
b. 0x100 contains 0x20, 0x200 contains 0x20, DI=0x202, and SI=0x102
c. 0x100 contains 0x10, 0x200 contains 0x10, DI=0x201, and SI=0x101
d. 0x100 contains 0x10, 0x200 contains 0x10, DI=0x1FF, and SI=0x1FF
iii. The video display memory is divided into 25 rows and 80 columns. Assuming that the rows are numbered
from 0 to 24 and columns are numbered from 0 to 79 and es has 0xb800, the instruction “mov word [es:1700],
0x0735” puts the number 5 at which of the following location:
a. Row=10, Column=50
b. Row=9, Column=50
c. Row=10, Column=49
d. Row=9, Column=49
iv. Imagine a sub-routine being called from the main program. The main program passes one argument
(parameter) to the sub-routine. How exactly will the subroutine access this parameter?
a. [bp-2]
b. [bp]
c. [bp+2]
d. [bp+4]
v. The instruction that is used as prefix to a string instruction to execute it repeatedly until the CX register
becomes zero is:
a. SCAS
b. CMPS
c. REP
d. REPN
vi. Suppose AL=11001011, CL=2 and CF=1. Give the new contents of AL after executing “sar al, cl”.
a. AL=11100101, CF=1
b. AL=10010010, CF=1
c. AL=11110010, CF=1
d. AL=00110010, CF=1
vii. Suppose AL=11001011, CL=3 and CF=1. Give the new contents of AL after executing “rcl al, cl”.
a. AL=10010111, CF=1
b. AL=00101111, CF=1
c. AL=01011111, CF=0
d. AL=01011111, CF=1
viii. Imagine a sub-routine being called from the main program. The sub-routine declares a local variable to store
and process some data. How exactly will the subroutine access this local variable?
a. [bp-2]
b. [bp]
c. [bp+2]
d. [bp+4]
x. Imagine that the DL register contains a number between 0 and 9. The instruction "OR DL,0x30" results in DL to
contain:
a. The original number
b. The original number with sign bit reversed
c. Corresponding character between'0' and '9'
d. The original number multiplied with 3
Question2. Write the output of the following short programs. [4x7 Marks]
For this question, please put your answers in the following table. No answer will be marked other than this table.
S.No Answer
ii.
Value of [num1]: ____________________
iii.
Final Value of DX: ___________________
iv.
Updated Value of Str2: ____________________
Reason: ____________________________________________________________________
___________________________________________________________________________
i. Write the updated contents of ‘array’ (in decimal only) after execution of the following code.
ii. What’s the final value of the num1 memory location? Answer in hex or decimal.
[org 0x0100]
mov dx, 0x0730
mov cx, 10
xor bx, bx
loop1: dec cx
mov ax, cx
add dx, ax
and dl, 0x0F
add bl, dl
mov dx, 0x0730
or cx, cx
jnz loop1
mov word [num1], bx
mov ax, 0x4c00
int 0x21
num1: dw 0
iii. What is the final value of DX register (in hex) after executing the following code?
[org 0x0100]
mov si, str1
mov di, str2
push ds
pop es
cld
mov cx, [len]
xor dx, dx
again: jcxz done
repne cmpsb
jne done
inc dx
jmp again
done: mov ax, 0x4c00
int 0x21
len: dw 8
str1: db 'Ukraine.'
str2: db 'Romania.'
len: dw 17
str1: db 'Never odd or even'
str2: db 'Final Examination'
v. Suppose that AX = 0x1234, BX = 0x5678, and CX = 0x9ABC, and SP=0x0100. Give the contents of AX, BX, CX,
and SP after executing the following instructions:
push ax
push bx
xchg ax, cx
pop cx
push ax
pop bx
vi. How does the following code snippet update the value of DL register? Assume that the initial value of DL
register is 11011100.
mov cx, 8
tag1: shl dl,1
rcr bl,1
loop tag1
mov dl,bl
vii. Given the following piece of code, what will be the value of ‘seconds’ if we keep space bar pressed for 7
seconds? Assume that keyboard and timer ISR are correctly hooked in the ‘main’. Give reason for your answer
in maximum two lines.
pop ax
iret
Question3. Write an isr for software interrupt 0x17, which calculates the run time of any subroutine that the isr
invokes/executes in behalf of the user. The label of the subroutine is passed in bx register to the isr. Also ntoe that
the time resolution for calculating run time is 1 ms (i.e. the run time will be reported in multiples of 1 ms, which
means 1 ms, 2 ms, 3 ms and so on.) You are also required to provide the main /start subroutine. [25 Marks]
iii. Suppose that in the multitasking problem of 10.2, each pcb keeps a track of the number of times it goes into
execution in one second. What changes will you make in the code to keep a track of this? [9 Marks]
mov cx, 5
rep stosb
mov ax, 0x4c00
int 21h
Best of luck