ORG 0000H
MOV R1, #0AH ; Initialize Byte Counter
MOV R0, #40H ; Initialize source pointer R0 to 40H
DEC R1 ; decrement counter by one
MOV 60H, @R0 ;Read First Byte
UP: INC R0 ; Increment the contents of R0
MOV A, @R0 ; Read second number
CJNE A, 60H, DN ;compare the first two numbers, if not equal go to DN
AJMP LARGE ;else go to LARGE
DN: JC LARGE ;check carry
MOV 60H, A ;Store largest number to 60H
LARGE: DJNZ R1, UP ;decrement the counter by one, if count ≠ 0, then go to UP
END
Largest No. is saved in memory 60H. Assume any location to store the result.
OR
MOV R1, #0AH ; initialize the counter
MOV R0, #40H ; initialize the memory pointer
DEC R1 ; decrement counter by one
MOV A,@R0 ; load number in accumulator
MOV B, A ; move that number to register B
UP: INC R0 ; increment the memory pointer
MOV A,@R0 ; read the next number in A
CJNE A, B, DOWN ; compare the first two numbers, if not equal go to DOWN
AJMP NEXT ; else go to NEXT
DOWN: JC NEXT ; if number in A is greater then go to NEXT
MOV B, A ; else move the number in register B
NEXT: DJNZ R1, UP ; decrement the counter by one, if count ≠ 0, then go to UP
INC R0 ; increment the memory pointer
MOV A,B
MOV 50H, A ; store result at memory location 50H(Assume any location)
HERE: SJMP HERE