0% found this document useful (0 votes)
28 views10 pages

COAL Final - Fall 2018 - FAST LHR

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views10 pages

COAL Final - Fall 2018 - FAST LHR

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

National University of Computer and Emerging Sciences, Lahore Campus

Course Name: Computer Organization and


Assembly Language Course Code: EE213
Program: BS(Computer Science) Semester: Fall 2018
Duration: 180 Minutes Total Marks: 100
Paper Date: 31st December, 2018 Weight 45%
Section: ALL Page(s): 10
Exam Type: FINAL

Student : Name:_____________________________ Roll No.________________ Section:_______

Instruction/Notes: 1. Exam is Open book, Open notes.


2. Properly comment your code.
3. Syntax error will result in negative marking.
4. Write your answer in the space provided. You can take extra sheets BUT they
WONT BE ATTACHED WITH THE QUESTION PAPER OR MARKED.

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.

S.No Answer S.No Answer

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

Department of Computer Science Page 1 of 10


ii. The operation of “push ax” is equivalent to:
a. SP  SP -2
[SP]  AX
b. SP  SP -2
SP  AX
c. [SP]  AX
SP  SP -2
d. SP  SP +2
[SP]  AX

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]

Department of Computer Science Page 2 of 10


ix. Suppose SP=0x0200, and top of stack = 0x012A. What are the contents of IP and SP after "ret 4" where ret
appears in a near procedure.
a. IP = 0x012A, SP=0x206
b. IP = 0x012A, SP=0x1FA
c. IP = 0x0200, SP=0x204
d. IP = 0x012A, SP=0x202

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

Updated Array values after code execution:


i.

ii.
Value of [num1]: ____________________

iii.
Final Value of DX: ___________________

iv.
Updated Value of Str2: ____________________

v. AX= ________________ BX=________________

CX=________________ DX= ________________

vi. Updated value of DL Register: ____________________

vii. Value of Seconds: _______

Reason: ____________________________________________________________________

___________________________________________________________________________

i. Write the updated contents of ‘array’ (in decimal only) after execution of the following code.

Department of Computer Science Page 3 of 10


[org 0x0100]
push ds
pop es
std
mov si, array+8
mov di, array+10
mov cx, 3
rep movsw
mov word [di], 30
mov ax, 0x4c00
int 0x21
array: dw 10, 20, 40, 50, 60, 0

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.'

Department of Computer Science Page 4 of 10


iv. Write the contents of “str2” after executing the following program.
[org 0x0100]
mov si, str1
mov di, str2
mov cx, [len]
add di, cx
dec di
push ds
pop es
cld
next: movsb
sub di, 2
loop next

mov ax, 0x4c00


int 0x21

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.

Department of Computer Science Page 5 of 10


kbisr: push ax
in al, 0x60 ; read char from keyboard port
cmp al, 0x4B ; assume that 0x5B is scancode of ‘space bar’
jne nextcmp
cmp word[cs:timerflag], 1
je exit
mov word[cs:timerflag], 1
jmp exit
nextcmp: cmp al, 0xBB
jne nomatch
mov word[cs:timerflag],0
exit: mov al, 0x20
out 0x20, al
pop ax
iret
; timer ISR
timer: push ax
cmp word[cs:timerflag], 1
jne skipall
inc word[cs:seconds]
push word[cs:seconds]
call printnum ; print tick count
skipall:

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]

Department of Computer Science Page 6 of 10


Question4.
i. Consider the elaborate multitasking example 10.2. In this example, each new task created takes one
parameter on its stack. Suppose we want to change the intipcb such that, it generalizes the creation of mytask.
So if mytask takes one parameter, the stack created for it has one parameter, if it takes zero parameter the

Department of Computer Science Page 7 of 10


stack has zero parameter, if it takes two parameters, the stack created has two parameters and so on. Suggest
all changes that you will make to initipcb code (line 88 to 117) and to main (line 204 to 210). [8 Marks]

Department of Computer Science Page 8 of 10


ii. Which of the following is correct implementation if pcb size is increased by two bytes? [2 Marks]

a. mov cl, 6 b. mov cl, 6 c. mov cl, 6 d. none of these


shl bx, cl shl bx, cl shl bx, cl
sub bx, 2 sub bx, 4 add bx, 2

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]

Department of Computer Science Page 9 of 10


Question 5. [3+2 Marks]
i. How many times int 0x01 will come in the following code?
pushf ; setting TF=1
pop ax Solution:
or ax, 0x100
push ax
popf

mov cx, 5
rep stosb
mov ax, 0x4c00
int 21h

ii. Int 0x03 is responsible for:


(a) Inserting break point
(b) Removing breakpoint
(c) Removing opcode
(d) Restoring opcode

Best of luck 

Department of Computer Science Page 10 of 10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy