Professional Documents
Culture Documents
M Faizan Jamshed 19-Arid-5209 Bscs 3B Finalterm Assignment (Fall 2020) Submitted To: Prof. Ms Saadia Sultana Coal Dated:2/9/2021
M Faizan Jamshed 19-Arid-5209 Bscs 3B Finalterm Assignment (Fall 2020) Submitted To: Prof. Ms Saadia Sultana Coal Dated:2/9/2021
19-ARID-5209
BSCS 3B
FinalTerm Assignment (Fall 2020)
SUBMITTED TO: Prof. Ms Saadia Sultana
COAL
Dated:2/9/2021
Q. No. 1 Can we execute a subroutine without stack? Justify your answer with valid
arguments. [2 Marks]
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
Q. 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. [5 Marks]
[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,2,0,9
num2:dw 0,0,0,0
Q. No. 3 (a) How bitwise logical operators are used in bit masking? [2+3 Marks]
[ORG 0X100]
jmp start
multiplicant: dw 29
multiplier: dw 21
display: dw 0
start:
mov cx,6
mov bx,[multiplicant]
mov dx,[multiplier]
chkbit:
shr dx,1
jnc skip
add [display],bx
skip:
shl bx,1
sub cx,1
jnz chkbit
mov ax,0x4c00
int 0x21
Q. 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.
[5 Marks]
[ORG 0x0100]
mov ax,0xb800
mov es, ax
mov di,0
mov word[es:1154],0x8116
mov word[es:1156],0x8116
mov word[es:1158],0x8116
mov word[es:1160],0x8116
mov word[es:1162],0x8116
mov word[es:1164],0x8116
mov word[es:1166],0x8116
mov word[es:1168],0x8116
mov word[es:1170],0x8116
mov word[es:1172],0x8116
mov word[es:1174],0x8116
mov word[es:1176],0x8116
mov word[es:1178],0x8116
mov word[es:1180],0x8116
mov word[es:1182],0x8116
mov word[es:1184],0x8116
mov word[es:1186],0x8116
mov word[es:1188],0x8116
mov word[es:1190],0x8116
mov word[es:1192],0x8116
mov word[es:1194],0x8116
mov word[es:1196],0x8116
mov word[es:1314],0x81fe
mov word[es:1356],0x81fe
mov word[es:1474],0x81fe
mov word[es:1516],0x81fe
mov word[es:1634],0x81fe
mov word[es:1676],0x81fe
mov word[es:1794],0x8116
mov word[es:1796],0x8116
mov word[es:1798],0x8116
mov word[es:1800],0x8116
mov word[es:1802],0x8116
mov word[es:1804],0x8116
mov word[es:1806],0x8116
mov word[es:1808],0x8116
mov word[es:1810],0x8116
mov word[es:1812],0x8116
mov word[es:1814],0x8116
mov word[es:1816],0x8116
mov word[es:1818],0x8116
mov word[es:1820],0x8116
mov word[es:1822],0x8116
mov word[es:1824],0x8116
mov word[es:1826],0x8116
mov word[es:1828],0x8116
mov word[es:1830],0x8116
mov word[es:1832],0x8116
mov word[es:1834],0x8116
mov word[es:1836],0x8116
mov ax,0x04c00
int 0x21
Q. 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. [5 Marks]
[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
Q. 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.
[5 Marks]
[ORG 0X100]
jmp start
multiplicant: dw 29
multiplier: dw 21
display: dw 0
start:
mov cx,6
mov bx,[multiplicant]
mov dx,[multiplier]
chkbit:
shr dx,1
jnc skip
add [display],bx
skip:
shl bx,1
sub cx,1
jnz chkbit
mov ax,0x4c00
int 0x21
Q. 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. [3 Marks]
[org 0x100]
Jmp start
max:
Mov bx,0
Mov cx,0
Mov si,[num1]
loop1:
Mov ax,[num1+bx]
cmp ax,si
jl lp1
mov si,ax
mov [num2],si
lp1:
add bx,2
add cx,1
cmp cx,4
Jne loop1
Ret
min:
Mov bx,0
Mov cx,0
Mov si,[num1]
loop2:
Mov ax,[num1+bx]
cmp ax,si
jg lp2
mov si,ax
mov [num2+2],si
lp2:
add bx,2
add cx,1
cmp cx,4
Jne loop2
Ret
start:
Call max
call min
mov ax, 0x4c00
int 0x21
num1:dw 5,2,0,9
num2:dw 0,0