Saturday, September 12, 2009

Find the largest of given numbers(8085)


Statement:Find the largest number in a block of data. The length of the block is in memory location 2200H and the block itself starts from memory location 2201H.
Store the maximum number in memory location 2300H. Assume that the numbers in the block are all 8 bit unsigned binary numbers


Sample problem
(2200H) = 04
(2201H) = 34H
(2202H) = A9H
(2203H) = 78H
(2204H) =56H
Result = (2202H) = A9H
Source program
LDA 2200H
MOV C, A : Initialize counter
XRA A : Maximum = Minimum possible value = 0
LXI H, 2201H : Initialize pointer
BACK: CMP M : Is number> maximum
JNC SKIP : Yes, replace maximum
MOV A, M
SKIP: INX H
DCR C
JNZ BACK
STA 2300H : Store maximum number
HLT : Terminate program execution

2 comments: