Tuesday 20 November 2012

PROGRAM TO FIND LARGEST NUMBER IN A GIVEN ARRAY OF 8 BIT NUMBERS

mmicroprocessor.blogspot.com
.model small
.data
list db 02h,23h,0A9h,0B8h,17h
m1 db "largest number is $"
.code
.startup
mov bx,0h
mov dl,list[bx]
mov cx,4
inc bx
l1:mov al,dl
cmp al,list[bx]
ja smaller
mov dl,list[bx]
smaller:
inc bx
loop l1
xor bx,bx
mov bl,dl
mov dx,offset m1
mov ah,09h
int 21h
mov dl,bl
mov cl,4
rol dl,cl
and dl,0fh
add dl,30h
cmp dl,'9'
jbe a1
add dl,7h
a1:mov ah,02h
int 21h
mov dl,bl
and dl,0fh
add dl,30h
cmp dl,'9'
jbe a2
add dl,7h
a2:mov ah,02h
int 21h
mov ah,4ch
int 21h
end

Output:
largest  number is B8

No comments:

Post a Comment