You are on page 1of 4

Roll No.

N098 Name: VEDASHREE SHETYE


Program : MBA.TECH CE Division: E
Batch: E2 Date of Experiment:25/01/2023
Date of Submission: 01/02/2023 Grade :

EXP. 5

AIM : Write a program to find the largest number and smallest number in
a list of 5 numbers.

Apparatus: Tasm software

Theory: To find the largest number in any given array, the contents of the array must be
compared with an arbitrary biggest number. The first number of the array is taken in a register
AL. The second number of the array is compared with the first one. If the first one is greater
than the second one, it is left unchanged. However if the second one is greater than the first,
the second number replaces the first one in the AL register. The procedure is repeated for every
number in the array and thus it requires n iterations. At the end of nth iteration the largest
number will reside in the register AL.

To find the smallest number in any given array, the contents of the array must be compared
with an arbitrary biggest number. The first number of the array is taken in a register BL. The
second number of the array is compared with the first one. If the first one is smaller than the
second one, it is left unchanged. However, if the second one is smaller than the first, the second
number replaces the first one in the BL register. The procedure is repeated for every number in
the array and thus it requires n iterations. At the end of nth iteration, the largest number will
reside in the register BL.

Procedure:
Steps to be followed to execute 8086 program in tasm software
 Write Assembly language program in notepad.
 Save this program file in tasm /bin folder with .asm extension
 Go to window start then select run
 Type command cmd (command window will pop up for dos prompt).
 Change the directory (cd\)
 Select path c:cd tasm/bin
 Write command tasm/zi file name .asm
 Write command tlink/v file name .obj
 Write command td file name .exe
 Program Window will appear
 Select view tab then select cpu
 Press F8 to execute program in single step mode
 Select view tab then select variable to see the result.
Program:
a) Largest Number from given list:
data segment
blk db 10h,19h,20h, 24h,02h
counter db 3
result db ?
data ends

code segment
start: assume ds: data, cs: code
mov ax,data
mov ds,ax
lea SI,blk
mov cl,counter

cld
mov al,[SI]
up: inc SI
cmp al,[SI]
jnc down
mov al,[SI]
down: dec cl
jnz up
mov result,al
mov ax,4c00h
int 21h
code ends
end start

b) Smallest Number from the given list:

Data segment
String1 db 06h, 19h, 26h, 56h, 44h
res db ?
data ends

code segment
start: assume cs: code , ds: data
mov ax, data
mov ds, ax
mov cx, 0004h
mov bl, [SI]
lea SI, String1
up:
mov al, [SI+1]
cmp bl, al
jb nxt
mov bl, al
nxt: inc SI
loop up

mov res, bl
mov ax,4c00h
int 21h
code ends
end start

Result:
a) Largest Number from the given list:
b) Smallest Number from the given list:

CONCLUSION: - Therefore, after successfully completing this


experiment, we are able to program and find largest and smallest
number from given list.

You might also like