單片機(jī)--電子時(shí)鐘(匯編)
;有些地方用十進(jìn)制比較方便,并不是匯編里面都要用十六進(jìn)制?
本文引用地址:http://m.butianyuan.cn/article/201611/319589.htm;author:helloword
;CLRSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++++
;CALLDELAY;延時(shí)------->消隱
;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就是十進(jìn)制的20,20*50000=1s
MOVDPTR,#DUAN
MOVTMOD,#01H
MOVTH0,#03CH
MOVTL0,#0B0H
SETBTR0
SETBET0
SETBEA
S1:CALLDISPLAY
;-----------接下來的程序是控制時(shí)分秒的上限值------
C1:MOVA,SECOND
CJNEA,#60,C2;3CH就是十進(jìn)制的60
MOVSECOND,#0
INCMINUTE
C2:MOVA,MINUTE
CJNEA,#60,C3;3CH就是十進(jìn)制的60
MOVMINUTE,#0
MOVSECOND,#0
INCHOUR
C3:MOVA,HOUR
CJNEA,#24,L;18H就是十進(jìn)制的24
MOVHOUR,#0
MOVMINUTE,#0
MOVSECOND,#0
;-----------判斷結(jié)束----------------------
L:LJMPS1
DISPLAY:;數(shù)碼管顯示子程序
D1:;***********顯示秒的兩個(gè)數(shù)碼管********************
SETBSMG_WL;P1.5數(shù)碼管的位選
MOVP0,#0BFH;
CLRSMG_WL;
;-----------顯示秒的高位
SETBSMG_DL;P1.4數(shù)碼管的段選
MOVA,SECOND
MOVB,#10
DIVAB;A/B,除完之后商存在A中,余數(shù)存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------顯示秒的低位
SETBSMG_WL
MOVP0,#7FH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********秒的顯示到此結(jié)束********************
D2:;***********顯示分的兩個(gè)數(shù)碼管******************
SETBSMG_WL;P1.5數(shù)碼管的位選
MOVP0,#0F7H;
CLRSMG_WL;
;-----------顯示分的高位
SETBSMG_DL;P1.4數(shù)碼管的段選
MOVA,MINUTE
MOVB,#10
DIVAB;A/B,除完之后商存在A中,余數(shù)存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------顯示分的低位
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
SETBSMG_WL
MOVP0,#0EFH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********分的顯示到此結(jié)束********************
D3:;***********顯示小時(shí)的兩個(gè)數(shù)碼管****************
SETBSMG_WL;P1.5數(shù)碼管的位選
MOVP0,#0FEH;
CLRSMG_WL;
;-----------顯示小時(shí)的高位
SETBSMG_DL;P1.4數(shù)碼管的段選
MOVA,HOUR
MOVB,#10
DIVAB;A/B,除完之后商存在A中,余數(shù)存在B中
MOVCA,@A+DPTR;查表指令要使用MOVC
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;-----------顯示小時(shí)的低位
SETBSMG_WL
MOVP0,#0FDH
CLRSMG_WL
SETBSMG_DL
MOVA,B
MOVCA,@A+DPTR
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)------->消隱
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
;***********小時(shí)的顯示到此結(jié)束********************
;***********間隔符的顯示********************
SETBSMG_OE;+++++++++++++++++++++++++++++++++++++++++++++
SETBSMG_WL;P1.5數(shù)碼管的位選
MOVP0,#0DBH;DBH=11011011點(diǎn)亮相應(yīng)的間隔符共陰,0點(diǎn)亮
CLRSMG_WL;
SETBSMG_DL;P1.4數(shù)碼管的段選
MOVA,#40H;40H=01000000顯示數(shù)碼管g這一段共陰,0點(diǎn)亮
MOVP0,A
CLRSMG_DL
CLRSMG_OE;++++++++++++++++++++++++++++++++++++++++++++++
CALLDELAY;延時(shí)
RET
INT_T0:
MOVTH0,#03CH;(65536-50000)/256=60=3C
MOVTL0,#0B0H;(65536-50000)%6=176=B0
DJNZFLAG,RETURN
INCSECOND
MOVFLAG,#7H;#14H是十進(jìn)制的2020*50000=1s
RETURN:RETI
DELAY:MOVR1,#20;延時(shí)子程序
DELAY1:MOVR2,#20
DJNZR2,$
DJNZR1,DELAY1
RET
WEI:DB7FH,0BFH,0DFH,0EFH,0F7H,0FBH,0FDH,0FEH
DUAN:DB03FH,06H,05BH,4FH,66H,6DH,07DH,07H,07FH,06FH
ENDSTART
評(píng)論