单片机汇编语言实现20秒倒计时程序,要求用动态显示,跪求大神!!!!!

2022-03-09 社会 177阅读
ORG   0000H
JMP   BEGIN
ORG 000BH
LJMP T0INT
ORG 001BH
LJMP T1INT
LEDD EQU 30H
LEDC EQU 36H
SECC EQU 37H
TCNT EQU 3AH
ORG 0030H
;---------------------------------------
TABLE:      ; 共阴极数码管显示代码表
DB 0FCH ;"0" 00H
DB 60H ;"1" 01H
DB 0DAH ;"2" 02H
DB 0F2H ;"3" 03H
DB 66H ;"4" 04H
DB 0B6H ;"5" 05H
DB 0BEH ;"6" 06H
DB 0E0H ;"7" 07H
DB 0FEH ;"8" 08H
DB 0F6H ;"9" 09H
DB 0EEH ;"A" 0AH
DB 3EH ;"B" 0BH
DB 9CH ;"C" 0CH
DB 7AH ;"D" 0DH
DB 9EH ;"E" 0EH
DB 8EH ;"F" 0FH
DB 00H ;" " 10H
;          DB    3FH,06H,5BH,4FH,66H ;12345
;          DB    6DH,7DH,07H,7FH,     ;6789
;---------------------------------------
DELAY:  
MOV   R6,#25
DLY01:  
MOV   R7,#100
DJNZ  R7,$
DJNZ  R6,DLY01
RET
;---------------------------------------
BEGIN:  
MOV SP,#5FH
MOV TMOD,#11H
MOV TH0,#3CH
MOV TL0,#0B0H
MOV TH1,#0F4H
MOV TL1,#48H
MOV LEDC,#6
MOV R0,#LEDD
CLR A
INIT:
MOV @R0,A
INC R0
DJNZ LEDC,INIT
SETB ET1
SETB TR1
MOV P2,#0
MOV TCNT,#0
MOV SECC,#0
SETB ET0
SETB EA
MOV SECC,#20
LCALL DISSEC
SETB TR0
SETB TR1
LOOP:
SJMP $
;---------------------------------------
T1INT:
PUSH ACC
CLR TR1
MOV TH1,#0F4H
MOV TL1,#48H
SETB TR1
MOV DPTR,#TABLE
MOV R0,#LEDD
MOV A,LEDC
T1INT0:
JNZ T1INT1
MOV P2,#01H
MOV A,@R0
MOVC A,@A+DPTR
CPL A
MOV P0,A
SJMP T1INTD
T1INT1:
MOV P2,#02H
INC R0
MOV A,@R0
MOVC A,@A+DPTR
CPL A
MOV P0,A
T1INTD:
INC LEDC
MOV A,LEDC
CJNE A,#2,T1INT6
T1INT6:
JC T1INTE
MOV LEDC,#0
T1INTE:
POP ACC
RETI
;---------------------------------------
HBCD:
MOV B,#10
DIV AB 
SWAP A 
ORL A,B
RET 
;---------------------------------------
T0INT:
PUSH ACC
CLR TR0
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
INC TCNT
MOV A,TCNT
CJNE A,#20,T0INT1
T0INT1:
JC T0INTE
MOV TCNT,#0
MOV A,SECC
DEC A
MOV SECC,A
JNZ T0INT2
MOV SECC,#60
T0INT2:
LCALL DISSEC
T0INTE:
POP ACC
RETI
;---------------------------------------
DISSEC:
MOV A,SECC
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 30H,A
POP ACC
SWAP A
ANL A,#0FH
MOV 31H,A
RET
;---------------------------------------
END
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com