The program to find out the largest number from an unordered array of sixteen 8 bit numbers stored sequentially in the memory locations starting at offset 0500H in the segment 2000H
Logic: The 1st number of the array is taken in a register, say AL. The 2nd number of array is then compared with the 1st one. If the 1st one is greater than 2nd one, it is left unchanged. However, if the 2nd one is greater than 1st, 2nd number replaces the 1st one in the AL register. The procedure is repeated for every number in array and thus requires 15 iterations.
MOV CX, 0FH; Initialize counter for no. of iterations
MOV AX, 2000H; Initialize data segment
MOV DS, AX;
MOV SI, 0500H; Initialize source pointer
MOV AL, [SI]; Take 1st number in AL
BACK: INC SI;
CMP AL,[SI];
INC SI;
CMP AL,[SI];
JNC NEXT;
MOV AL,[SI];
NEXT: LOOP BACK; Repeat the procedure 15 times
HLT
You might be also interested in:
:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language
:: Data transfer instructions of 8086 microprocessor
2 comments:
thnnxx :)
can u please tell me where to feed the data? and how the output will be
Post a Comment