Largest Number
Largest Number
Algorithm:
Step 6 : Check for Carry. If carry doesn’t exist, larger number will be in Accumulator. Hence go to
step No8 .
Step 9 : Check whether count is Zero or not. If count is non-zero go to step No. 5.
Compare the
next Number
Is
there any
Carry?
Decrement
Count
Is
Count
Zero?
A
Program:
Address Machine Label Mnemon Operands Comment
Codes ics
2000 3E MVI A, 00H Initialize Accumulator with smallest
number 00H
2001 00
2002 21 LXI H, 2500H Initialize HL pair with the address Count
2003 00
2004 25
2005 4E MOV C,M Move count into Reg C.
2006 23 BACK INX H Increment HL pair for address of next No/.
2007 BE CMP M Compare the numbers
2008 D2 JNC AHEAD Jump if carry doesn’t exist
2009 0C
200A 20
200B 7E MOV A,M Move the number into Accumulator
200C 0D AHEAD DCR C Decrement Count
200D C2 JNZ BACK Jump if Count is non-Zero
200E 06
200F 20
2010 32 STA 24FF Store largest number in Memory
2011 FF
2012 24
2013 76 HLT Halt