ORG 0000H
AJMP MAIN
ORG 000BH
AJMP KEYIN
ORG 001B
AJMP INP1
MAIN: MOV R2,#09
MOV 40H,#00
MOV 41H,#00
MOV 42H,#00
MOV 43H,#00
MOV TMOD,#11H ; 计时器T0,工作方式1
MOV TL0,#0F0H ; 初值
MOV TH0,#0D8H
MOV TL1,#0E0H
MOV TH1,#0B1H
MOV SCON,#00H
MOV 20H,#00
CLR 21H.0
CLR 21H.0
SETB F0
SETB TR0
SETB TR1 ;开计时器
SETB EA ;开中断
SETB ET0
SETB ET1
EXT1: CJNE R1,#00,LP0
ETT0: MOV R7,#00
MOV R6,#08
HI0: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB1
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HI0
MOV R7,#08
MOV R6,#00
HI1: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HI1
JB F0, ETT0
SETB F0
AJMP EXT1
LP0: CJNE R1,#01,LP1
ETT: MOV R6,#00
MOV R7,#08
HL2: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB2
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL2
MOV R7,#08
MOV R6,#00
HL3: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL3
JB F0,ETT
SETB F0
AJMP EXT1
LP1: CJNE R1,#02,LP2
ETT2: MOV R6,#00
MOV R7,#08
HL6: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB3
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL6
MOV R7,#08
MOV R6,#00
HL7: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL7
JB F0 ,ETT2
SETB F0
AJMP EXT1
LP2: CJNE R1,#03,PP1
ET2: MOV R6,#00
MOV R7,#08
HL8: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB4
MOVC A,@A+DPTR
MOV P0,A
INC R6
ACALL DEL
DJNZ R7,HL8
MOV R7,#08
MOV R6,#00
HL9: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL9
JB F0,ET2
SETB F0
AJMP EXT1
PP1: CJNE R1,#04,LPO3
ET3: MOV R6,#00
MOV R7,#08
HL10: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB5
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL10
MOV R7,#08
MOV R6,#00
HL11: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL11
JB F0, ET3
SETB F0
AJMP EXT1
LPO3: CJNE R1,#05,LPO2
ET4: MOV R6,#00
MOV R7,#08
HL12: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB6
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL12
MOV R7,#08
MOV R6,#00
HL13: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL13
JB F0, ET4
SETB F0
AJMP EXT1
LPO2: CJNE R1,#06,LPO1
ET5: MOV R6,#00
MOV R7,#08
HL14: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB6
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL12
MOV R7,#08
MOV R6,#00
HL15: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL13
JB F0, ET5
SETB F0
AJMP EXT1
LPO1: CJNE R1,#07,LPO0
ET6: MOV R6,#00
MOV R7,#08
HL16: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL14
MOV R7,#08
MOV R6,#00
HL17: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL15
JB F0, ET6
SETB F0
AJMP EXT1
LPO0: CJNE R1,#08,PL0
ET7: MOV R6,#00
MOV R7,#08
HL18: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB9
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL18
MOV R7,#08
MOV R6,#00
HL19: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL19
JB F0, ET7
SETB F0
AJMP EXT1
PL0: CJNE R1,#09,PL1
ET8: MOV R6,#00
MOV R7,#08
HL20: MOV A,R6
MOV P1,#0FFH
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,HL20
MOV R7,#08
MOV R6,#00
HL21: MOV P0,#0FFH
MOV A,R6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,HL21
JB F0, ET8
SETB F0
AJMP EXT1
PL1: CJNE R3,#01,LPO4
LPO4: AJMP EXT1
LLP1: MOV R5,#09
MOV R7,#08
MOV R6,#00
MOV P1,#0FFH
LPP1: MOV A,R6
MOV DPTR,#TAB1
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP1
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP2: MOV A,R6
MOV DPTR,#TAB1
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP2
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP3: MOV A,R6
MOV DPTR,#TAB2
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP3
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP4: MOV A,R6
MOV DPTR,#TAB2
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP4
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP5: MOV A,R6
MOV DPTR,#TAB3
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP5
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP6: MOV A,R6
MOV DPTR,#TAB3
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP6
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP7: MOV A,R6
MOV DPTR,#TAB4
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP7
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP8: MOV A,R6
MOV DPTR,#TAB4
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP8
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP9: MOV A,R6
MOV DPTR,#TAB5
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP9
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP10: MOV A,R6
MOV DPTR,#TAB5
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP10
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP11: MOV A,R6
MOV DPTR,#TAB6
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP11
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP12: MOV A,R6
MOV DPTR,#TAB6
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP12
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP13: MOV A,R6
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP13
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP14: MOV A,R6
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP14
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP15: MOV A,R6
MOV DPTR,#TAB8
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP15
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP16: MOV A,R6
MOV DPTR,#TAB8
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP16
MOV R6,#00
MOV R7,#08
MOV P1,#0FFH
LPP17: MOV A,R6
MOV DPTR,#TAB9
MOVC A,@A+DPTR
MOV P0,A
ACALL DEL
INC R6
DJNZ R7,LPP17
MOV R7,#08
MOV R6,#00
MOV P0,#0FFH
LPP18: MOV A,R6
MOV DPTR,#TAB9
MOVC A,@A+DPTR
MOV P1,A
ACALL DEL
INC R6
DJNZ R7,LPP18
DJNZ R5,OPP
OPP: AJMP LLP1
LPPO4: AJMP PP1
DEL: CJNE R2,#09,LMP1
JNB 21H.1, $
CLR 21H.1
AJMP CQ
LMP1: CJNE R2,#08,LMP2
JNB 21H.0, $
CLR 21H.0
AJMP CQ
LMP2: CJNE R2,#07,LMP3
JNB 20H.7,$
CLR 20H.7
AJMP CQ
LMP3: CJNE R2,#06,LMP4
JNB 20H.6,$
CLR 20H.6
AJMP CQ
LMP4: CJNE R2,#05,LMP5
JNB 20H.5,$
CLR 21H.5
AJMP CQ
LMP5: CJNE R2,#04,LMP6
JNB 20H.4,$
CLR 21H.4
AJMP CQ
LMP6: CJNE R2,#03,LMP7
JNB 20H.3,$
CLR 21H.3
AJMP CQ
LMP7: CJNE R2,#02,LMP8
JNB 20H.2,$
CLR 21H.2
AJMP CQ
LMP8: CJNE R2,#01,LMP9
JNB 20H.1,$
CLR 21H.1
AJMP CQ
LMP9: CJNE R2,#00,CQ
JNB 20H.0,$
CLR 21H.0
CQ: RET
INP1: MOV TL0, #0E0H
MOV TH1, #0B1H ;
CJNE R2,#09,JM0
SETB 21H.1
AJMP TM0
JM0: CJNE R2,#08,JM1
SETB 21H.0
AJMP TM0
JM1: CJNE R2,#07,JM2
SETB 20H.7
AJMP TM0
JM2: CJNE R2,#06,JM3
SETB 20H.6
AJMP TM0
JM3: CJNE R2,#05,JM4
SETB 20H.5
AJMP TM0
JM4: CJNE R2,#04,JM5
SETB 20H.4
AJMP TM0
JM5: CJNE R2,#03,JM6
SETB 20H.3
AJMP TM0
JM6: CJNE R2,#02,JM7
SETB 20H.2
AJMP TM0
JM7: CJNE R2,#01,JM8
SETB 20H.1
AJMP TM0
JM8: CJNE R2,#00,TM0
SETB 20H.0
MOV R2,#09
AJMP TM0
TM0: RETI
KEYIN: MOV TL0,#0F0H
MOV TH0,#0D8H
JNB P3.4, JY0
JNB P3.5, JY1
JNB P3.7, JY2
ACALL XIANSHI
AJMP EXT
JY0: JB P3.4,ZS0
ACALL XIANSHI
AJMP EXT
ZS0: INC 40H
MOV R1,40H
CLR F0
CJNE R1,#10,CL0
MOV 40H,#00
AJMP EXT
JY1: JB P3.5,ZS1
ACALL XIANSHI
AJMP EXT
ZS1: DEC R2
SETB F0
CJNE R2,#00H,CL1
MOV 41H,#09
ACALL XIANSHI
AJMP EXT
JY2: JB P3.7,ZS2
ACALL XIANSHI
AJMP EXT
ZS2: INC 42H
SETB F0
MOV R3,42H
CJNE R3,#02,CL2
MOV 42H,#00
ACALL XIANSHI
AJMP EXT
CL0: ACALL XIANSHI
AJMP EXT
CL1: ACALL XIANSHI
AJMP EXT
CL2: ACALL XIANSHI
AJMP EXT
EXT: RETI
XIANSHI:
MOV 41H,R2
MOV 30H,#04
HL1: MOV R0,#40H
MOV P2,#7FH
HL: MOV A,@R0
MOV DPTR,#TAB10
MOVC A,@A+DPTR
MOV SBUF,A
JNB TI,$
CLR TI
MOV A,P2
RL A
MOV P2,A
INC R0
DJNZ 30H,HL
RET
TAB1: DB 18H,24H,42H,81H,18H,24H,42H,81H
TAB2: DB 10H,10H,10H,00H,00H,00H,00H,00H
TAB3: DB 10H,10H,10H,01H,00H,00H,00H,00H
TAB4: DB 08H,10H,10H,00H,08H,00H,00H,00H
TAB5: DB 06H,10H,10H,00H,00H,00H,00H,00H
TAB6: DB 04H,10H,10H,00H,00H,00H,00H,00H
TAB7: DB 02H,10H,10H,00H,00H,00H,00H,00H
TAB8: DB 18H,24H,42H,81H,18H,24H,42H,81H
TAB9: DB 18H,24H,42H,81H,18H,24H,42H,81H
TAB10: DB 0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H,0FEH,0F6H
END
|