ORG 0030H
MAIN:MOV DPTR,#0CFA3H
MOV A,#80H
MOVX @DPTR,A
MOV 20H,#1H
MOV 21H,#2H
MOV 22H,#3H
MOV 23H,#4H
MOV 24H,#5H
MOV 25H,#6H
MOV 51H,#0
MOV R3,#0
LOOP1:MOV P1,#01111111B
JNB P1.5, K0
JNB P1.4, K1
JNB P1.3, K2
JNB P1.2, K3
JNB P1.1, K4
JNB P1.0, K5
LOOP2:MOV P1,#10111111B
JNB P1.5, K6
JNB P1.4, K7
JNB P1.3, K8
JNB P1.2, K9
JNB P1.1, KA
JNB P1.0, KB
SJMP LOOP1
K0:MOV A,#0
SJMP DISP
K1:MOV A,#1
SJMP DISP
K2:MOV A,#2
SJMP DISP
K3:MOV A,#3
SJMP DISP
K4:MOV A,#4
SJMP DISP
K5:MOV A,#5
SJMP DISP
K6:MOV A,#6
SJMP DISP
K7:MOV A,#7
SJMP DISP
K8:MOV A,#8
SJMP DISP
K9:MOV A,#9
SJMP DISP
KA:MOV A,#10
SJMP COMP
KB:MOV A,#8
SJMP LOOP1
K12:MOV A,#0
SJMP LOOP1
K13:MOV A,#1
SJMP LOOP1
K14:MOV A,#4
SJMP LOOP1
K15:MOV A,#7
SJMP LOOP1
DISP:MOV R4,A
MOV A,R3
ADD A,#26H
MOV R1,A
MOV A,R4
MOV @R1,A
MOV R0,#50
MOV DPTR,#TABLE
DI1: SETB CY
MOV R1,#26H
MOV R2,#0FEH
MOV R5,#6
DI0: MOV A,@R1
MOVC A,@A+DPTR
MOV DPTR,#0CFA1H
MOVX @DPTR,A
MOV A,R2
MOV DPTR,#0CFA2H
MOVX @DPTR,A
RLC A
MOV R2,A
INC R1
ACALL DLY10MS
MOV A,#0FFH
MOV DPTR,#0CFA2H
MOVX @DPTR,A
DJNZ R5,DI0
DJNZ R0,DI1
INC R3
MOV A,R3
CJNE A,#6,DI2
LJMP LOOP1
DI2: LJMP LOOP1
DLY10MS:MOV R7,#5
D1: MOV R6,#248
DJNZ R6,$
DJNZ R7,D1
RET
COMP: MOV A,26H
CJNE A,20H,CUO
MOV A,27H
CJNE A,21H,CUO
MOV A,28H
CJNE A,22H,CUO
MOV A,29H
CJNE A,23H,CUO
MOV A,2AH
CJNE A,24H,CUO
MOV A,2BH
CJNE A,25H,CUO
MOV DPTR,#0CFA1H
CLR ACC.2
MOVX @DPTR,A
SJMP $
CUO: INC 51H
MOV A,51H
CJNE A,#3,C1
SJMP ALARM
C1:MOV 26H,#0H
MOV 27H,#0H
MOV 28H,#0H
MOV 29H,#0H
MOV 2AH,#0H
MOV 2BH,#0H
MOV R3,#0
LJMP LOOP1
ALARM:
MOV DPTR,#0CFA1H
CPL ACC.0
MOVX @DPTR,A
ACALL DLY10MS
SJMP ALARM
TABLE: DB 3FH,06H,5BH,4FH
DB 66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH
DB 39H,5EH,79H,71H
END
MAIN:MOV DPTR,#0CFA3H
MOV A,#80H
MOVX @DPTR,A
MOV 20H,#1H
MOV 21H,#2H
MOV 22H,#3H
MOV 23H,#4H
MOV 24H,#5H
MOV 25H,#6H
MOV 51H,#0
MOV R3,#0
LOOP1:MOV P1,#01111111B
JNB P1.5, K0
JNB P1.4, K1
JNB P1.3, K2
JNB P1.2, K3
JNB P1.1, K4
JNB P1.0, K5
LOOP2:MOV P1,#10111111B
JNB P1.5, K6
JNB P1.4, K7
JNB P1.3, K8
JNB P1.2, K9
JNB P1.1, KA
JNB P1.0, KB
SJMP LOOP1
K0:MOV A,#0
SJMP DISP
K1:MOV A,#1
SJMP DISP
K2:MOV A,#2
SJMP DISP
K3:MOV A,#3
SJMP DISP
K4:MOV A,#4
SJMP DISP
K5:MOV A,#5
SJMP DISP
K6:MOV A,#6
SJMP DISP
K7:MOV A,#7
SJMP DISP
K8:MOV A,#8
SJMP DISP
K9:MOV A,#9
SJMP DISP
KA:MOV A,#10
SJMP COMP
KB:MOV A,#8
SJMP LOOP1
K12:MOV A,#0
SJMP LOOP1
K13:MOV A,#1
SJMP LOOP1
K14:MOV A,#4
SJMP LOOP1
K15:MOV A,#7
SJMP LOOP1
DISP:MOV R4,A
MOV A,R3
ADD A,#26H
MOV R1,A
MOV A,R4
MOV @R1,A
MOV R0,#50
MOV DPTR,#TABLE
DI1: SETB CY
MOV R1,#26H
MOV R2,#0FEH
MOV R5,#6
DI0: MOV A,@R1
MOVC A,@A+DPTR
MOV DPTR,#0CFA1H
MOVX @DPTR,A
MOV A,R2
MOV DPTR,#0CFA2H
MOVX @DPTR,A
RLC A
MOV R2,A
INC R1
ACALL DLY10MS
MOV A,#0FFH
MOV DPTR,#0CFA2H
MOVX @DPTR,A
DJNZ R5,DI0
DJNZ R0,DI1
INC R3
MOV A,R3
CJNE A,#6,DI2
LJMP LOOP1
DI2: LJMP LOOP1
DLY10MS:MOV R7,#5
D1: MOV R6,#248
DJNZ R6,$
DJNZ R7,D1
RET
COMP: MOV A,26H
CJNE A,20H,CUO
MOV A,27H
CJNE A,21H,CUO
MOV A,28H
CJNE A,22H,CUO
MOV A,29H
CJNE A,23H,CUO
MOV A,2AH
CJNE A,24H,CUO
MOV A,2BH
CJNE A,25H,CUO
MOV DPTR,#0CFA1H
CLR ACC.2
MOVX @DPTR,A
SJMP $
CUO: INC 51H
MOV A,51H
CJNE A,#3,C1
SJMP ALARM
C1:MOV 26H,#0H
MOV 27H,#0H
MOV 28H,#0H
MOV 29H,#0H
MOV 2AH,#0H
MOV 2BH,#0H
MOV R3,#0
LJMP LOOP1
ALARM:
MOV DPTR,#0CFA1H
CPL ACC.0
MOVX @DPTR,A
ACALL DLY10MS
SJMP ALARM
TABLE: DB 3FH,06H,5BH,4FH
DB 66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH
DB 39H,5EH,79H,71H
END