- Suppose, there is an array or block of ten 8-bit data stored from memory address 2030h. And, we have to find out the greatest number among them.
- What we are going to do here is that we compare every two data from the first location. If the data of first location is greater than that of second location, the latter will be replaced by the former.
- In this way, for 10 data, we run this logic 9 times and finally, the maximum number will be at the last location i.e, 2039h.
LXI H, 2030h
MVI C, 09h
AGAIN: MOV A, M
INX H
CMP M
JC SKIP
MOV M, A
SKIP: DCR C
JNZ AGAIN
HLT
Output:
No comments:
Post a Comment