ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB ET0
SETB EA
MOV R0,#9
MOV R1,#9
MOV R2,#0
MOV R3,#9
CLR 00H
CLR 01H
LOOP:
JB P1.0,LP01
JNB P1.0,$
SETB TR0
CLR 01H
SJMP LOOP0
LP01:
JB P1.1,LP02
JNB P1.1,$
SETB 01H
SJMP LOOP0
LP02:
JB P1.2,LOOP0
JNB P1.1,$
CLR TR0
MOV P3,#0FDH
MOV P2,#0
MOV P3,#0FEH
MOV P2,#0
SJMP MAIN
LOOP0:
JB 00H,LOOP1
MOV A,R0
SJMP LOOP2
LOOP1:
MOV A,R1
LOOP2:
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV R3,A
SJMP LOOP
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-10000)
MOV TL0,#LOW(65536-10000)
SETB TR0
JB 01H,T0C
INC R2
T0C:
CPL 00H
MOV A,R3
JB 00H,T001
MOV P3,#0FDH
MOV P2,A
SJMP T002
T001:
MOV P3,#0FEH
MOV P2,A
T002:
MOV A,R2
CJNE A,#100,T0E
MOV R2,#0
MOV A,R0
JZ T003
DEC R0
SJMP T0E
T003:
MOV A,R1
JZ T004
DEC R1
MOV R0,#9
T0E:
RETI
T004:
CLR TR0
RETI
TABLE: ; 共阴极数码管显示代码表
DB 3FH,06H,5BH,4FH,66H ;01234
DB 6DH,7DH,07H,7FH,6FH ;56789
END