ORG 0000H
LJMP MAIN
ORG 0003H
LJMP SUM
ORG 1000H
GW EQU 20H
SW EQU 21H
BW EQU 22H
MAIN:CLR P1.0
MOV BW,#00H
MOV GW,#FFH
MOV SW,#00H
MOV DPTR,#8002H
MOV A,#0FFH
MOVX @DPTR,A
MOV DPTR,#8004H
MOV A,#3FH
MOVX @DPTR,A
SETB IT0
SETB EX0
SETB EA
DIR:
MOV R0,#20H
MOV R1,#01H
MOV A,R1
LDO:
MOV DPTR,#8002H
MOVX @DPTR,A
MOV A,@RO
MOV DPTR,#TABLE
DIRO:MOVC A,@A+DPTR
MOV DPTR,#8004H
MOVX @DPTR,A
ACALL DL
INC R0
MOV A,R1
JB ACC.2,DIR
RL A
MOV R1,A
AJMP LD0
SUM:JB P1.1,JIAN
INC GW
MOV A,GW
CJNE A,#10,QUIT
MOV GW,#00H
INC SW
MOV A,#10,QUIT
MOV SW,#00H
INC BW
MOV A,BW
CJNE A,#2,QUIT
SETB P1.0
AJMP QUIT
JIAN: DEC GW
MOV A,GW
CJNE A,#0FFH,QUIT
MOV GW,#09
DEC SW
MOV A,BW
CJNE A,#1,QUIT
CLR P1.0
QUIT:RET1
DL:MOV R6,#10
DL0:MOV R7,#100
DL1:DJNE R7,#DL1
DJNE R6,DL0
RET
TABLE:
DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
END