Following is the code for finding the minimum and maximum of array elements in assembly language , compiled using tasm. But the issue is it is running for only single digit sized array , like it is only numbers till 9 not more than that. I want to run the code for for array size=99. I dont know how to handle two digit sized array. Also it should accept double digit sized elements like 34 , 22 etc. Right now it is only accepting elements 0-9.
.model small
.386p
.stack
.data
ARRAY db 10 dup(?)
msg0 db 13,10,"ENTER NO.:$"
msg1 db 13,10,"ENTER NUMBER OF ELEMENTS:$"
msg2 db 13,10,"MAX:$"
msg3 db 13,10,"MIN:$"
n db ?
max db 00H
min db 00H
first db 01H
.code
start:
mov eax,@data
mov ds,eax
mov dx,offset msg1
mov ah, 09H
int 21H
mov ah,01H
int 21H
mov n,al
sub n,30H
mov cl,n
INPUT:
mov dx,offset msg0
mov ah,09H
int 21H
mov ah,01H
int 21H
mov bl,first
cmp bl,01H
jnz minset
mov first,00h
mov min,al
minset:
sub al,30H
mov bl,max
cmp bl,al
ja nomax
mov max,al
nomax:
mov bl,min
cmp bl,al
jb nomin
mov min,al
nomin:
mov ARRAY[si],al
inc si
LOOP INPUT
mov si,0
mov cl,n
print:
mov dx,offset msg2
mov ah, 09H
int 21H
mov dl,max
add dl,30H
mov ah,02H
int 21H
mov dx,offset msg3
mov ah, 09H
int 21H
mov dl,min
add dl,30H
mov ah,02H
int 21H
EXIT:
end start
end