单片机--电子时钟(汇编)
;有些地方用十进制比较方便,并不是汇编里面都要用十六进制?
;author:helloword
;CLRSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++++
;CALLDELAY;延时------->消隐
;SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
SMG_OEBITP1.3
SMG_DLBITP1.4
SMG_WLBITP1.5
SECONDEQU40H
MINUTEEQU41H
HOUREQU42H
FLAGEQU43H
ORG0000H
JMPSTART
ORG000BH
JMPINT_T0
ORG0040H
START:
MOVSECOND,#0
MOVMINUTE,#0
MOVHOUR,#0
MOVFLAG,#14H;14H就是十进制的20,20*50000=1s
MOVDPTR,#DUAN
MOVTMOD,#01H
MOVTH0,#03CH
MOVTL0,#0B0H
SETBTR0
SETBET0
SETBEA
S1:CALLDISPLAY
;-----------接下来的程序是控制时分秒的上限值------
C1:MOVA,SECOND
CJNEA,#60,C2;3CH就是十进制的60
MOVSECOND,#0
INCMINUTE
C2:MOVA,MINUTE
CJNEA,#60,C3;3CH就是十进制的60
MOVMINUTE,#0
MOVSECOND,#0
INCHOUR
C3:MOVA,HOUR
CJNEA,#24,L;18H就是十进制的24
MOVHOUR,#0
MOVMINUTE,#0
MOVSECOND,#0
;-----------判断结束----------------------
L:LJMPS1
DISPLAY:;数码管显示子程序
D1:;***********显示秒的两个数码管********************
SETBSMG_WL;P1.5数码管的位选
MOVP0,#0BFH;
CLRSMG_WL;
;-----------显示秒的高位
SETBSMG_DL;P1.4数码管的段选
MOVA,SECOND
MOVB,#10
divAB;A/B,除完之后商存在A中,余数存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------显示秒的低位
SETBSMG_WL
MOVP0,#7FH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********秒的显示到此结束********************
D2:;***********显示分的两个数码管******************
SETBSMG_WL;P1.5数码管的位选
MOVP0,#0F7H;
CLRSMG_WL;
;-----------显示分的高位
SETBSMG_DL;P1.4数码管的段选
MOVA,MINUTE
MOVB,#10
divAB;A/B,除完之后商存在A中,余数存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------显示分的低位
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
SETBSMG_WL
MOVP0,#0EFH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********分的显示到此结束********************
D3:;***********显示小时的两个数码管****************
SETBSMG_WL;P1.5数码管的位选
MOVP0,#0FEH;
CLRSMG_WL;
;-----------显示小时的高位
SETBSMG_DL;P1.4数码管的段选
MOVA,HOUR
MOVB,#10
divAB;A/B,除完之后商存在A中,余数存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------显示小时的低位
SETBSMG_WL
MOVP0,#0FDH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时------->消隐
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********小时的显示到此结束********************
;***********间隔符的显示********************
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
SETBSMG_WL;P1.5数码管的位选
MOVP0,#0DBH;DBH=11011011点亮相应的间隔符共阴,0点亮
CLRSMG_WL;
SETBSMG_DL;P1.4数码管的段选
MOVA,#40H;40H=01000000显示数码管g这一段共阴,0点亮
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延时
RET
INT_T0:
MOVTH0,#03CH;(65536-50000)/256=60=3C
MOVTL0,#0B0H;(65536-50000)%6=176=B0
DJNZFLAG,RETURN
INCSECOND
MOVFLAG,#7H;#14H是十进制的2020*50000=1s
RETURN:RETI
DELAY:MOVR1,#20;延时子程序
DELAY1:MOVR2,#20
DJNZR2,$
DJNZR1,DELAY1
RET
WEI:DB7FH,0BFH,0DFH,0EFH,0F7H,0FBH,0
单片机电子时钟汇 相关文章:
- 用单片机实现电子时钟(汇编)(11-18)
- 单片机 电子时钟(汇编)(11-18)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)