Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Final Term Exam / Fall 2020 (Paper Duration 24 hours)

To be filled by Teacher

Course No.: CS-530 Course Title: Computer Organization and Computer Language
Total Marks:30 Date of Exam: 09-02-2021
rd
Degree: BSCS Semester:3 Section: B
Marks
Q. No. 1 2 3 4 5 6 7 8 9 10 Obtained/
Total Marks
Marks
Obtaine
d
Total Marks in Words:
Name of the teacher: Saadia Sultana
Who taught the course: Signature of Teacher / Examiner:

To be filled by Student

Registration No.: 19-ARID-5127 Name: Abdullah Shakeel

Answer the following questions.

Question no# 1
Can we subroutine executed without stack? Justify your answer with valid arguments. [2]

Answer:-
Subroutine cannot execute without stack. Because when subroutine is called, the
address is saved on the stack. Data needed by a subroutine is pushed on the stack
immediately before the subroutine call.

Question no# 3
(a) How bitwise logical operators are used in bit masking?

Answer:-
Bitwise manipulation performs a logical operation on each individual bit of a binary number.
The logical bitwise operators AND, OR, and XOR can be used as masks that can affect
specific bits. The AND logical operation can be used to turn off certain bits of a binary
number, because: 1 AND 0 is 0.Moslty we can use AND, OR,NOT logical bitwise operators.
For Example:-

[org 0x100]

jmp start

num1: dw 30

set: or ax, 0xf0

ret

clear: and ax, 0xf0

ret

invert: not ax

ret

start:mov ax,[num1]

call set

mov ax,[num1]

call clear

mov ax,[num1]

call invert

mov ax, 0x4c00

int 0x21

(b) write a program that perform multiple functions in a single segment.

 Print 8 bit number with 4 LSB zero


 Print 8 bit number with 4 MSB one
 Print 8 bit number in revers ( i.e 0 to 1, 1 to 0)

Answer:-
[org 0x100]

mov ax,[num1]

clear: and ax, 0xf0

set: or ax, 0xf0

inverse: not ax

mov ax, 0x4c00

int 0x21
num1 : dw 30

Question no #4 
Write a program that prints any shape (e.g. square, circle, rectangle etc.) with
black back ground and blinking property. Show the character formation of the
given pattern

Code:-
[ORG 0x0100]

mov ax,0xb800

mov es, ax

mov di,0

mov word[es:1154],0x855f

mov word[es:1156],0x855f

mov word[es:1158],0x855f

mov word[es:1160],0x855f

mov word[es:1162],0x855f

mov word[es:1164],0x855f

mov word[es:1166],0x855f

mov word[es:1168],0x855f

mov word[es:1170],0x855f

mov word[es:1172],0x855f

mov word[es:1174],0x855f

mov word[es:1176],0x855f

mov word[es:1178],0x855f

mov word[es:1180],0x855f

mov word[es:1182],0x855f

mov word[es:1184],0x855f

mov word[es:1186],0x855f

mov word[es:1188],0x855f

mov word[es:1190],0x855f
mov word[es:1192],0x855f

mov word[es:1194],0x855f

mov word[es:1196],0x855f

mov word[es:1314],0x85b3

mov word[es:1356],0x85b3

mov word[es:1474],0x85b3

mov word[es:1516],0x85b3

mov word[es:1634],0x85b3

mov word[es:1676],0x85b3

mov word[es:1794],0x85c4

mov word[es:1796],0x85c4

mov word[es:1798],0x85c4

mov word[es:1800],0x85c4

mov word[es:1802],0x85c4

mov word[es:1804],0x85c4

mov word[es:1806],0x85c4

mov word[es:1808],0x85c4

mov word[es:1810],0x85c4

mov word[es:1812],0x85c4

mov word[es:1814],0x85c4

mov word[es:1816],0x85c4

mov word[es:1818],0x85c4

mov word[es:1820],0x85c4

mov word[es:1822],0x85c4

mov word[es:1824],0x85c4

mov word[es:1826],0x85c4

mov word[es:1828],0x85c4

mov word[es:1830],0x85c4

mov word[es:1832],0x85c4
mov word[es:1834],0x85c4

mov word[es:1836],0x85c4

mov ax,0x04c00

int 0x21

Output:

Question no # 5 
Write an assembly program to find the geometric series of first 7 numbers and then show the
sum of all the numbers by using sub routine. Run the program and attach screenshot. 

Code:-
[org 0x100]

Jmp start

ser:

Mov bx,2

Mov cx,0

loop1:

mov dx,2

mul dx
Mov [num1+bx],ax

add bx,2

add cx,1

cmp cx,6

Jne loop1

Ret

sum:

Mov ax,[num1]

Mov bx,2

Mov cx,0

loop2:

add ax,[num1+bx]

add bx,2

add cx,1

cmp cx,6

Jne loop2

Ret

start:

mov ax,[num1]

Call ser

call sum

Mov [num2],ax

mov ax, 0x4c00

int 0x21

num1:dw 2

num2:dw 0
Output:-

Question no # 7 
Write a program to find out maximum and minimum number from your arid number in a
single program. Attach screenshot of the output. 

Code:
[orgx100]

jmp start

num: dw 5,1,2,7

start: mov bx, [num]

mov ax, [num]

mov si,2

abc: cmp [num+si], bx

jnc skip
mov bx,[num+si]

skip: add si,2

cmp si,8

jnz abc

mov si,2

xyz: cmp ax,[num+si]

jnc skip1

mov ax,[num+si]

skip1: add si,2

cmp si,8

jnz xyz

mov ax, 0x4c00

int 0x21

Output:

Question no # 6
 Write a program to multiply two numbers without using MUL function (both numbers
should be odd). Also make dry run and attach screenshot of output in AFD
Code:
[org 0x100]

mov ax,[multiplier]

mov bx,[multiplicand]

mov cx,2

loop1:

shr ax,1

jnc loop2

add [ans],bx

loop2:

shl bx,1

dec cx

jnz loop1

mov ax, 0x4c00

int 0x21

multiplier: dw 3

multiplicand:dw 3

ans: dw 0

Output:-
Dry Run:-

 Question no # 2
 Write an assembly program that has two functions, in first function shows the number in
reverse order (number should be your arid number) and in second function, evaluate any
expression (e.g 1+2*2) using stack.  
Code:-
[org 0x100]

jmp start

f1:

mov ax,[num1]

mov [num2+6],ax

mov ax,[num1+2]

mov [num2+4],ax

mov ax,[num1+4]

mov [num2+2],ax

mov ax,[num1+6]

mov [num2],ax

ret

f2:

mov ax,1

push ax

mov bx,2

mov dx,2

add ax,bx

mul dx

pop ax

ret

start:

call f1

call f2

mov ax, 0x4c00


int 0x21

num1:dw 5,1,2,7

num2:dw 0,0,0,0

You might also like