Find the largest element in a block of data. The length of block is 0A H. Store the maximum value in memory location result. Use an Assembly Language Program for Intel 8086.

Find the largest element in a block of data. The length of block is 0A H. Store the maximum value in memory location result. Use an Assembly Language Program for Intel 8086.

 
title largest element in a block of data
dosseg
.model small
.stack 100H
.code
main proc
mov ax, @data ; initialize ds register
mov ds, ax
 
mov cx, OA H ; counter = 10
mov al, 00H ; assume the largest number is 00H
mov SI, offset array ; SI initialization
BACK:    cmp al, [SI] ; is next number > maximum
jnc AHEAD ; NC = 0
mov al, [SI] ; yes, replace maximum
AHEAD: inc SI
loop BACK
mov result, al ; move final result to al
 
mov ax, 4C00H ; return to DOS
int 21H
main endp
.data
array db 12, 13, 80, 14, ….. ; total 0A h variables
result db ?
end main
 

Ekendra Lamsal: An Engineer, Technocrat, ICT4D Advocate & Web analyst. Blogging since 2001 (on this site from 2004) in various weblogs. Also, in love with Clouds, Internet of Things, Knowledge Management, Web Inclusion & BI.