MAX EQU 30H
MOV DPTR,#2000H
MOV MAX,#00H
MOV R5,#40H
LOOP:
MOVX A,@DPTR ;1
CALL MMA ;2
INC DPTR
DJNZ R5,LOOP ;3
SJMP $
MMA:
CLR C
SUBB A,MAX
JC NEXT ;4
ADD A,MAX
MOV MAX,A ;5
NEXT: RET