ORG 00H
MOV R5,R5:[#00H]
MOV R7,#00H
DJNZ R7,$
MOV R7,R7:[#10H]
MOV R6,#06H
MOV R1,#35H
L1: MOV A,R7
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV @R1,A
DEC R1
INC R7
DJNZ R6,L1
START: ORL P2,#0FFH
MOV R4,#06H
MOV R0,#40H
CLEAR: MOV @R0,#00H
INC R0
DJNZ R4,CLEAR
L2: MOV R3,#0F7H
MOV R1,#00H
L3: MOV A,R3
MOV P1,A
MOV A,P1
MOV R4,A
SETB C
MOV R5,#04H
L4: RLC A
JNC KEYIN
INC R1
DJNZ R5,L4
CALL DISP
MOV A,R3
SETB C
RRC A
MOV R3,A
JC L3
JMP L2
KEYIN: MOV A,R1
XRL A,#0BH
JZ X3
MOV A,R1
XRL A,#0FH
JZ X4
MOV R7,#10
D1: MOV R6,#24
DJNZ R6,$
DJNZ R7,D1
D2: MOV A,P1
XRL A,R4
JZ D2
MOV A,R1
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV R7,A
XRL A,#0AH
JZ SET0
MOV A,R7
XRL A,#0BH
JZ START
MOV A,R7
XRL A,#0CH
JZ L2
MOV A,R7
XRL A,#0DH
JZ L2
MOV A,R7
XCH A,40H
XCH A,41H
XCH A,42H
XCH A,43H
XCH A,44H
XCH A,45H
CALL DISP
JMP L2
X3: JMP DISP2
X4: JMP COMP
DISP:MOV R0,#45H
DISP1: MOV A,@R0
ADD A,#50H
MOV P0,A
CALL DELAY
DEC R0
MOV A,@R0
ADD A,#40H
MOV P0,A
CALL DELAY
DEC R0
MOV A,@R0
ADD A,#30H
MOV P0,A
CALL DELAY
DEC R0
MOV A,@R0
ADD A,#20H
MOV P0,A
CALL DELAY
DEC R0
MOV A,@R0
ADD A,#10H
MOV P0,A
CALL DELAY
DEC R0
MOV A,@R0
ADD A,#00H
MOV P0,A
CALL DELAY
RET
SET0: MOV R2,#06H
MOV R0,#40H
MOV R1,#30H
E1: MOV A,@R0
XCH A,@R1
INC R0
INC R1
DJNZ R2,E1
CALL DELAY
E2: JMP START
COMP: MOV R1,#45H
MOV R0,#35H
MOV R2,#06H
C1: MOV A,@R1
XRL A,@R0
JNZ C3
DEC R1
DEC R0
DJNZ R2,C1
CLR P2.0
MOV R2,#200
C2: MOV R6,#248
DJNZ R6,$
DJNZ R2,C2
C3: INC R5
MOV A,R5
MOV R5,A
CJNE R5 ,#03H,C4
CLR P2.1
MOV R5,#00H
C4: JMP START
DISP2: MOV R0,#35H
CALL DISP
MOV A,P1
XRL A,R4
JZ DISP2
CALL DELAY
JMP START
DELAY: MOV R7,#C3
D3: MOV R6,#248
DJNZ R7,D3
RET
ORG 300H
TABLE: DB 01H 02H 03H 0CH
DB 04H 05H 06H 0DH
DB 07H 08H 09H 0EH
DB 0AH 00H 0BH 0FH
DB 01H 02H 03H 04H 05H 06H
END
|