Here is a sample program in assembly language for the Emu8086 Microprocessor Emulator that finds the largest number from an array and saves it in a variable named LRGST:
ORG 100h
DATA SEGMENT
ARR DB 5, 3, 9, 2, 6 ; example array of numbers
LRGST DB ? ; variable to hold the largest number
DATA ENDS
CODE SEGMENT
START:
MOV AX, @DATA ; initialize data segment
MOV DS, AX
MOV BL, ARR ; load the first number in array into BL
MOV BH, ARR+1 ; load the second number in array into BH
COMPARE:
CMP BL, BH ; compare the two numbers in BL and BH
JGE UPDATE ; jump to UPDATE if BL is greater than or equal to BH
MOV BL, BH ; otherwise, move BH to BL
INC BH ; increment index to move to next number in array
CMP BH, 5 ; compare index to array length (assuming length is 5)
JG DISPLAY ; if index is greater than array length, display largest number
JMP COMPARE ; otherwise, compare the next two numbers
UPDATE:
MOV BH, ARR+1 ; move the next number in array to BH
INC BH ; increment index to move to next number in array
CMP BH, 5 ; compare index to array length (assuming length is 5)
JG DISPLAY ; if index is greater than array length, display largest number
JMP COMPARE ; otherwise, continue comparing numbers in array
DISPLAY:
MOV LRGST, BL ; move largest number (in BL) to LRGST variable
INT 3H ; exit program
CODE ENDS
END START
You can modify the "ARR DB" line to include any array of numbers and the program will find the largest number. After the program is run, the largest number will be stored in the LRGST variable.