数字钟程序汇编源程序 第3页
第四章 主程序
ORG 0000H
AJMP MAIN
ORG 000BH
AJMP TIME
ORG 0300H
MAIN:
MOV 20h,#00h
MOV 21H,#00H
MOV 22H,#00H
MOV 23H,#00H
MOV IP,#02H ;IP,IE初始化
MOV IE,#82H
MOV TMOD,#01H ;设定定时器工作方式?
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0 ;启动定时?
MOV SP,#40H ;重设堆栈指针
NEXT: LCALL DISP ;调用显示子程序?
LCALL KEY ;调用按键检测子程序
JZ NEXT ;
LCALL ANKEY ;调用按键处理子程序
SJMP NEXT ;重新循环
NOP
NOP
NOP
;定时中断处理程序:
TIME: PUSH ACC ;保护现场
PUSH PSW
MOV TL0,#0B4H ;赋定时初值
MOV TH0,#3CH
INC 20H ;
MOV A,20H
CJNE A,#20,RETI1
MOV 20H,#00H ;一秒钟时间到
MOV A,21H
ADD A,#01H
DA A
MOV 21H,A
CJNE A,#60H,RETI1
MOV 21H,#00H ;一分钟时间到
MOV A,22H
ADD A,#01H
DA A
MOV 22H,A
CJNE A,#60H,RETI1
MOV 22H,#00H
MOV A,23H
ADD A,#01H
DA A
MOV 23H,A
CJNE A,#24H,RETI1
MOV 23H,#00H
RETI1: POP PSW ;恢复现场
POP ACC
RETI ;中断返回?
NOP
NOP
;显示子程序
DISP: ANL 2FH,#10H ;处理小数点<BR< p>
>MOV A,21H ;处理秒21H-->2DH,2EH
ANL A,#0FH
ORL A,2FH
MOV 2FH,A
MOV A,21H
ANL A,#0F0H
SWAP A
MOV 2EH,A
ANL 2DH,#10H
MOV A,22H ;处理分钟22H-->2CH,2DH
ANL A,#0FH
ORL A,2DH
MOV 2DH,A
MOV A,22H
ANL A,#0F0H
SWAP A
MOV 2CH,A
ANL 2BH,#10H
MOV A,23H
ANL A,#0FH
ORL A,2BH
MOV 2BH,A
MOV A,23H
ANL A,#0F0H
SWAP A
MOV 2AH,A
MOV R0,#2FH ;显示偏移量
MOV R3,#06H
MOV DPTR,#TABLE
MOV A,#0BFH
LOOP1: MOV B,A ;
MOV P2,a
MOV A,@R0
MOVC A,@A+DPTR
MOV P0,a ;送显示
MOV R2,#80H ;延时
DJNZ R2,$
DEC R0
MOV A,B
RR A
DJNZ R3,LOOP1 ;循环显示
RET
TABLE: db 28h,7eh,0a2h,62h,74h,61h,21h ;不带小数点
DB 7ah,20h,60h,00,00,00,00,00,00
DB 8H,5eH,82H,42H,54H,41H,1H,5aH ;带小数点
上一页 [1] [2] [3] [4] [5] 下一页
数字钟程序汇编源程序 第3页下载如图片无法显示或论文不完整,请联系qq752018766