您的位置 首页 模拟

单片机–电子时钟(汇编)

;消隐的汇编程序简单的电子时钟,;有些地方用十进制比较方便,并不是汇编里面都要用十六进制​;author:helloword;CLRSMG_OE;++++++++++++++

;消隐的汇编程序简略的电子时钟

;有些当地用十进制比较便利,并不是汇编里边都要用十六进制​

;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,0FDH,0FEH

DUAN:DB03FH,06H,05BH,4FH,66H,6DH,07DH,07H,07FH,06FH

ENDSTART

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/zhishi/moni/261691.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部