提仔陪供一个类似的程序给你参考。
从键盘输入时间初始值后,用固定时间产生0.1s定时中断,触发时钟记数器记数,并将数值实时送显示器显示。
ORG 0030H
CHK00: MOV SP,#60H
LCALL LEDP
MOV DPTR,#CLOCK
MOV R0,DPL
MOV R1,DPH
MOV DPTR,#000BH
MOV A,#02H
MOVX @DPTR,郑旁A
INC DPTR
MOV A,R1
MOVX @DPTR,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
LCK0: LCALL LCK0
LCALL PTDS0
MOV TMOD,#01H
ORL IE,#82H
MOV TL0,#0B7H
MOV TH0,#3CH
MOV 23H,#00H
SETB TR0
L005: LCALL DIS
LCALL PTDS0
SJMP L005
PTDS0: MOV R0,#79H
MOV A,念丛蠢22H
ACALL PTDS
MOV A,21H
ACALL PTDS
MOV A,20H
ACALL PTDS
RET
PTDS: MOV R1,A
ACALL PTDS1
MOV A,R1
SWAP A
PTDS1: ANL A,#0FH
MOV @R0,A
INC R0
RET
LOCK: MOV TL0,#0B7H
MOV TH0,#3CH
PUSH PSW
PUSH ACC
SETB 0D3H
INC 23H
MOV A,23H
CJNE A,#0AH,DONE
MOV 23H,#00H
MOV A,22H
INC A
DA A
MOV 22H,A
CJNE A,#60H,DONE
MOV 22H,#00H
MOV A,21H
INC A
DA A
MOV 21H,A
CJNE A,#60H,DONE
MOV 21H,#00H
MOV A,20H
INC A
DA A
MOV 20H,A
CJNE A,#24H,DONE
MOV 20H,#00H
DONE: POP ACC
POP PSW
RETI
ORG 0D59H
SSEE: SETB RS1
MOV R5,#05H
SSE2: MOV 30H,#20H
MOV 31H,#7EH
MOV R7,#06H
SSE1: MOV R1,#0DDH
MOV A,30H
MOVX @R1,A
MOV R0,31H
MOV A,@R0
MOV DPTR,#0DDFFH
MOVC A,@A+DPTR
MOV R1,#0DCH
MOVX @R1,A
MOV A,30H
RR A
MOV 30H,A
DEC 31H
MOV A,#0FFH
MOVX @R1,A
DJNZ R7,SSE1
DJNZ R5,SSE2
CLR RS1
RET
DDFF: DB 0C0H,0F9H,0A4H,0B0H,99H,92H
DB 82H,0F8H,80H,90H,0F8H,80H,90H
DB 88H,83H,bC6H,0A1H,86H,8EH
DB 0FFH,0CH,89H,0DEH
ORG 038EH
X3: MOV R4,A
MOV R0,#50H
MOV A,@R0
MOV R1,A
MOV A,R4
MOV @R1,A
CLR A
POP DPH
POP DPL
MOVC A,@A+DPTR
INC DPTR
CJNE A,01H,X30
DEC R1
CLR A
MOVC A,@A+DPTR
X31: MOV @R0,A
INC DPTR
PUSH DPL
PUSH DPH
RET
X30: DEC R1
MOV A,R1
SJMP X31
X2: MOV R6,#50H
X0: ACALL XLE
JNB ACC,5,XX0
DJNZ R6,X0
MOV R6,#20H
MOV R0,#50H
MOV A,@R0
MOV R0,A
MOV A,@R0
MOV R7,A
MOV A,#10H
MOV @R0,A
X1: ACALL XLE
JNB ACC,5,XX1
DJNZ R6,X1
MOV A,R7
MOV @R0,A
SJMP X2
XX1: MOV R6,A
MOV A,R7
MOV @R0,A
MOV A,R6
XX0: RET
XLE: ACALL DIS
ACALL KEY
MOV R4,A
MOV R1,#48H
MOV A,@R1
MOV R2,A
INC R1
MOV A,@R1
MOV R3,A
MOV A,R4
XRL A,R3
MOV R3,04H
MOV R4,02H
JZ X10
MOV R2,#88H
MOV R4,#88H
X10: DEC R4
MOV A,R4
XRL A,#82H
JZ X11
MOV A,R4
XRL A,#0EH
JZ X11
MOV A,R4
JZ X12
MOV R4,#20H
DEC R2
SJMP X13
X12: MOV R4,#0FH
X11: MOV R2,04H
MOV R4,03H
X13: MOV R1,#48H
MOV A,R2
MOV @R1,A
INC R1
MOV A,R3
MOV @R1,A
MOV A,R4
JB ACC,5,X113
JB ACC,4,X113
MOV DPTR,#LS3
MOVC A,@A十DPTR
X113: RET
LS3: DB 07H,04H,08H,05H,09H,06H,0AH
DB 0BH,01H,00H,02H,0FH,03H,0EH
DB 0CH,0DH
DIS: PUSH DPH
PUSH DPL
SETB RS1
MOV R0,#7EH
MOV R2,#20H
MOV R3,#00H
MOV DPTR,#LS0 ,
LS2: MOVA,@R0
MOVC A,@A+DPTR
MOV R1,#0DCH
MOVX @R1,A
MOV A,R2
INC R1
MOVX @R1,A
LS1: DJNZ R3,LS1
CLR C
RRC A
MOV R2,A
DEC R0
JNZ LS2
MOVX @R0,A
DEC R0
CPL A
MOVX @R0,A
CLR RS1
POP DPL
POP DPH
RET
LS0: DB 0C0H,0F9H,0A4H,0B0H,99H,92H
DB 82H,0F8H,80H,90H,88H,83H,0C6H
DB 0A1H,86H,8EH,0FFH,0CH,89H
DB 7FH,0BFH
KEY: SETB RS1
MOV R2,#0FEH
MOV R3,#08H
MOV R0,#00H
LP1: MOV R1,#0DDH
MOV A,R2
MOVX @R1,A
RL A
MOV R2,A
INC R1
MOVX A,@R1
CPL A
ANL A,#0FH
JNZ LP0
INC R0
DJNZ R3,LP1
XP33: MOV A,#20H
XP3: MOV R2,A
CLR A
MOV R1,#0DDH
MOVX @R1,A
MOV A,R2
CLR RS1
RET
LP0: CPL A
JB ACC.0,XP0
MOV A,#00H
SJMP LPP
XP0: JB ACC.1,XP1
MOV A,#08H
SJMP LPP
XP1: JB ACC,2,XP2
MOV A,#10H
SJMP LPP
XP2: JB ACC.3,XP33
MOV A,#18H
LPP: ADD A,R0
SMP XP3
LEDP: MOV 50H,#7EH
MOV A,#10H
MOV R0,#79H
1EDS: MOV @R0,A
INC R0
CJNE R0,#7EH,1EDS
INC A
MOV @R0,A
MOV A,#20H
MOV 48H,A
MOV 49H,A
RET
END