ORG 0000H
LJMP START
ORG 0003H
RETI
ORG 000BH
RETI
ORG 0013H
RETI
ORG 001BH
RETI
ORG 0023H
RETI
ORG 002BH
RETI
CLEARMEN: MOV A,#0FFH
MOV P1,A
MOV P2,A
MOV P3,A
MOV P0,A
MOV DPTR,#TAB
CLR A
MOV R3,A
MOV R1,#50H
MOV R2,#20H
CLLOOP: MOVC A,@A+DPTR
MOV @R1,A
MOV A,R3
INC A
MOV R3,A
INC R1
DJNZ R2,CLLOOP
RET
START: LCALL CLEARMEN
START1: LCALL KEYWORK
AJMP START1
KEYWORK: MOV P1,#0FFH
JNB P3.2,KEY1
JNB P3.3,KEY2
JNB P3.5,KEY3
KEYRET: RET
KEY1: LCALL DL10MS
JB P3.2,KEYRET
WAIT: JNB P3.2,WAIT
LCALL CLEARMEN
MOV 30H,#80H
MOV 31H,#08H
LJMP DISP1
KEY2: LCALL DL10MS
JB P3.3,KEYRET
WAIT1: JNB P3.3,WAIT1
LCALL CLEARMEN
MOV 30H,#14H
MOV 31H,#01H
LJMP DISP1
KEY3: LCALL DL10MS
JB P3.5,KEYRET
WAIT2: JNB P3.5,WAIT2
LCALL CLEARMEN
LJMP DISP2
DISP1: MOV B,#50H
MOV R4,30H
MOV R5,31H
LOOP: LCALL DISPLAY
DJNZ R4,LOOP
MOV R4,30H
MOV A,B
CJNE A,#68H,CONT
AJMP DISP1
CONT: ADD A,R5
MOV B,A
AJMP LOOP
DISPLAY: MOV A,#0FFH
MOV P2,A
MOV P0,A
MOV R6,#0FEH
MOV R0,B
MOV R7,#08H
DISLOOP: MOV A,@R0
MOV P2,A
MOV P0,R6
LCALL DL1MS
INC R0
MOV A,R6
RL A
MOV R6,A
DJNZ R7,DISLOOP
RET
DISP2: LCALL DISPP
LCALL MOVH
LCALL MOVH1
AJMP DISP2
DISPP: MOV B,#50H
MOV R4,#24H
LCALL DISPLAY
DJNZ R4,DISPP
RET
MOVH: MOV R1,#20H
MOV R0,#50H
MOV R2,#08H
MOV1: MOV A,@R0
CLR C
RLC A
MOV @R0,A
MOV A,@R1
RRC A
MOV @R1,A
INC R0
DJNZ R2,MOV1
MOV R2,#08H
INC R1
MOV A,R1
SUBB A,#24H
JZ OUT
AJMP MOV1
OUT: RET
MOVH1: MOV A,20H
XCH A,23H
XCH A,22H
XCH A,21H
MOV 20H,A
MOV R1,#20H
MOV R0,#50H
MOV2: MOV A,@R0
RR A
MOV @R0,A
MOV A,@R1
CLR C
RRC A
MOV A,@R0
RLC A
MOV @R0,A
INC R0
DJNZ R2,MOV2
MOV R2,#08H
INC R1
MOV A,R1
SUBB A,#24H
JZ OUT
AJMP MOV2
;
DL1MS: MOV R3,#64H ;100*(8+2)us
LOOPK: LCALL KEYWORK
DJNZ R3,LOOPK
RET
DL512: MOV R2,#0FFH
LOOP1: DJNZ R2,LOOP1
RET
DL10MS: MOV R3,#14H
LOOP2: LCALL DL512
DJNZ R3,LOOP2
RET
TAB: DB 0EFH,83H,0ABH,83H,0ABH,83H,0EEH,0E0H ; 电
DB 0FFH,0C7H,0EFH,83H,0EFH,0EFH,0CFH,0EFH ; 子
DB 0B1H,0B5H,04H,0BFH,0B1H,0B5H,9BH,0A4H ; 设
DB 0BBH,0BBH,1BH,0A0H,0BBH,0BBH,9BH,0BBH ; 计
DB 00H,00H,00H,00H
END