电子钟的程序(汇编)_第1页
电子钟的程序(汇编)_第2页
电子钟的程序(汇编)_第3页
电子钟的程序(汇编)_第4页
电子钟的程序(汇编)_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、-下程序是利用c51单片机实现电子钟的实用汇编程序:org0000hbegin:ump initorg0003 h;int0retiorgooobhjointto:umptointsrretiorg0013h;1nt1retiorg001bh;t1 intretiorg0023h;s port intretiorg002bh;t2 intreti org0100h;8032 ram ooh-ffh clear 0init: movb,#offhmovro,#oohmova, #00hcleoffh:incromovr0,adjnzb,cleoffh;set stack area70h-7fhm

2、ovsp,#70h;timer initmovtmod,#01hmovtlo,#oboh;2 e+16 = 65536 = 15536 + 50000(0.05s)movth0,#03ch;3cb0h=15536;ram intimov2fh,#3fh;2fh is flash tagmov2eh,#00h;2eh is to interrupt countermov2dh,#00h;2dh is the second counterclrp1.0clrpl.l;enable interruptsetbeasetbeto;startuptosetbtro;system normal jdent

3、ifier "0.0"mov psw,#00h/entrk1: lcalllcalllcallkeyscan;key sacn subrutintichang;display character changediflash;display flashingdisplay;display subrutintimecal;time calculatelcalllcallsjmpentrk11. keyscankey scan subrutin2. tichangtime data character change3. diflash.display flashing4. dis

4、play.display subrutin5. timecal.time calculate6. delay60.delay 60ms7. dcchang.display character change1;keyscan:;key scan subrutin9;1. 8032 pl port pin definition9;p3.2=+l key bit;p3.3=timeset key9;2. ram bit ooh -press timeset key flag 1=pressed, 0=not;02h -press add 1 key pin pong flag:03h -press

5、timeset key pin pong flagkeyscan:noppush pswmov psw,#08hjbp3.2,keytim0lcall delay60;delay60msjbp3.乙 keytimosetb03humpkeysoutkeytimojnb03h,keyjmp0jbp3.2jimset0lcalljbumpkeyjmpo:ljmptimseto:nopclrjbsetbclrmovmovmovljmptimesok:nopdecdeccjneclrsetbttttt: umpkeyscao:nopjblcalljbsetbljmpkeyp6h:jblcalljbke

6、yjmp:add1prs:clrjbjnbadd1in:incmovcjnecjneeq67h0: jcdelay60p3.2jimset0keysoutkeyscao03hoohjimesokooheto2dh,#00r0,#67hr1,#6fhkeysoutror1ro,#63h,tttt1oohetokeysout;delay60msjim eset key is pressed;timeset key is pressed;keysoutp3.5,keyp6hdelay60;delay60msp3.5,keyp6ho2hkeysoutjnb o2h,keyjmpp3.5,add1prs

7、delay60;delay60msp3.5,add1prsump keysouto2hooh,add1ino1h,eq67h1mov a,r0;+l key is pressedar0,ar0,#67h,less67ha,# 03h,eq67h0eq67h1moveq67h1:r0,#0ump keysoutless67h:cjnecjneeq66h0: jcmoveq66h1:less66h:cjnecjneeq65h0: jcmoveq65h1:r0,#66h 丄 ess66ha,#0ah,eq66h0eq66h1r0,#0ump keysoutr0,#65h 丄 ess65ha,#06h

8、,eq65h0eq65h1r0,#0ump keysoutro,#64h,keysouta,#0ah,eq64h0 keysoutr0,#0pswless65h:cjnecjneeq64h0: jcmovkeysout:noppopret2;tichang;time data character change1=pressed, 0=not:2. ram bit ooh -press timeset key flagmovr7,#4movr0,#6fhmovr1,#67htchango:mova,r1lcalldcchangcplamovr0,adecrodecr1tichang:nop;di

9、splay character changedjnztichout:nopr7,tchang0ret;diflash;display flashing change;1. ram bit ooh -press timeset key flag 1=pressed, 0=not2. ram 2fh is flash tagdiflash:nopjbooh,flashinajmpflasoutflashin:mova,2fhrlamov2fh,aanla,#03hcjnea,#03h, flasoutpushpswmovpsw,#08hmovr1,#offhpoppswflasout:retnop

10、9;4.;display:;display subrutin9; ram:6fhclock hore 10 bit;6ehclock hore 1 bit;6dhclock min 10 bit;6ch9clock min 1 bitdisplay:nopsetbpl.3movp0,6fhclrp1.0lcalldelay60;delay60mslcalldelay60;delay60mssetbp1.0movp0,6ehclrpl.llcalldelay60;delay60mslcallsetbdelay60pl.l;delay60msmovp0,6dhclrpl.2lcalldelay60

11、;delay60mslcalldelay60;delay60mssetbpl.2movp0,6chclrpl.3lcalldelay60;delay60mslcalldelay60;delay60mssetbpl.4setbpl.7setbpl.6setbpl.5ret;5.;timecal:time calculate"pressed, 0=not1. ram bit ooh -press timeset key flag2. ram 2eh to interrupt counter 3. ram 2dh is the second counter4. ram:6fhclock h

12、ore 10 bit6ehclock hore 1 bit6dhclock min 10 bit6chclock min 1 bittimecal:nopjboohjimeoulmova,2eh;hour display flashcjnealojimecal9timeca1jnctimeca29mova,66h/cjnem18hjimeca5/timeca5jnctimeou1/adda,# 18h/clrp1.0mov 66h,a mova,65hadda,#18hmov 65h,atimeou1:ljmptimeca2:cjnetimeca3jncmovcjnetimeca6jcsubb

13、setbmov mov subb movtimeouta,#2o,timeca3 timecaja,66h m18hjimeca6 timeou2a,# 18hp1.066h,aa,65ha,#18h65h,atimeou2:ljmptimeout;hour display flashtimecaj:mov2eh,#ooh;seconde add 1mova,2dh9cjnea,#59,timecaf/timecafjnctimecag/inca/mov2dh,a/umptimeout;seconde add 1timecag:mov2dh, #00;miniut ox add 1mova,6

14、4h/incajnb/06h,timefasdecaclr06htimefas:cjnea,#10,timeca79timeca7jnctimeca8/mov64h,a9umptimeout;miniute ox add 1timeca8:mov64h,#0;miniute xo add 1mova,65h9inca/cjnea,#6,timeca9 /timeca9jnctimecaa/mov65h,a/umptimeout;miniute xo add 1timecaa:mov65h,#0;hourox add 1movaz66h9inca/cjneaiojimecab/timecabjc

15、timecah /ljmptimecac/timecah:mov66h,a;hourox add 1mova,67h;ifhouris24cjnem2jimen24/mova,66h/cjneaz#4,timecai/timecakjnctime24h;if hour is 24timen24:umptimeouttime24h:mov64h,#00;min oxmov65h,#00;min xomov66h,#00;houroxmov67h,#00;hourxomov44h,#04;first programljmptimeout;newone daytimecac:mov66h,#0;ho

16、urxo add 1mova,67h/inca /cjnea,#3jimecad/timecadjnctimecae/mov67h,a9umptimeout;hourxo add 11997-11-17timecae:mov 67h,#0timeout:nopret;6;delay60:delay looms for next rangingdelay60:pushmovmovw60ms: movpswpsw,#00hr3,#6r4,#0fah;#100.5ms *10 = 5ms 1997-9-3;ofah =250w5oous1:djnzdjnzpopretr4,w500uslr3,w60

17、mspsw;time = 2us 2 us * 250 = 0.5 ms;7;dcchang:;display characters change routine;note:;1. entry a一load seto阡;2. ret adisplay character- 一一一 一dcchang:mov dptr, #charalmovc a,a+dptrretcharacters listcharal: db3fh,06h,5bh,4fh,66h,6dh;setoff :;characters:dbdbdbdbdbdbdb00h,01h,02h,03h,04h,05h,0,1,2,3,4,

18、57dh,07h,7fh,6fh,77h,7ch06h,07h,08h,09h,0ah,0bh,6,7,&9, a, b,39h,5eh,79h,71h,73h,3eh0ch,0dh,0eh,0fh,10hlh,c, d, e, f, p, u,76h,38h,40h,6eh,0ffhz00h12hz13hz14h,15h,16h/ 17hh, l, y, 8.,”0bfh,86h,0dbh,0cfh,0e6h,0edh18hj9h, 1ah, 1bh, 1ch, 1dh,0.,1., 2.,3.,4.,5.,0fdh,87h,0ffh,0efh,0f7h,0fch 1eh, 1fh,2oh, 21h, 22h, 23h,6.,7., 8.,9.,a.,b.,ob9h,oceh/of9h,of1h,of3h/obeh 24h, 25h, 26h, 27h, 28h, 29h,c.,d.,e.,f.,p.,u.,0f6h,0b8h,0c0h,0deh,0ffh,80h 2ah, 2bh, 2ch, 2dh, 2eh, 2fhh.z l.,y.,8.,"to,t1 interrupt subroutine1. tointsr.to interrupt se

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论