资源描述:
《倒计时器设计 汇编》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、采用51单片机机型设计可实现输入、倒计时、暂停功能适合北京理工大学单片机课程作业参考….ORG0000HMOVP1,#3FH;初始显示000AJMPMAINORG001BHAJMPDENGORG000BHAJMPJISHIORG0030HMAIN:MOVTMOD,#11HMOVTH1,#0DFHMOVTL1,#0FFH;T1控制灯亮间隔SETBTR1SETBEASETBET1MOVP3,#04HCHUSHI:MOV30H,#3FH;个位MOV31H,#3FH;十位MOV32H,#3FH;百位MOV34H,#00H;暂存MOV35H,
2、#00H;控制是否有按键间隙MOV37H,#00HMOV38H,#00H;是否开始倒计时MOV40H,#01H;对应30H存数码管显示MOV41H,#01HMOV42H,#01HMOV50H,#00H;对应30H存第几123...MOV51H,#00HMOV52H,#00HTEST:MOVP0,#0F0H;判断输入数值MOVA,P0ANLA,#0F0HCJNEA,#0F0H,HAVEMOV35H,#01H;有间隔35H置1SJMPTESTHAVE:MOVA,#0FEHNEXT:MOVB,AMOVP0,AREAD:MOVA,P0ANL
3、A,#0F0HCJNEA,#0F0H,YESMOVA,BRLACJNEA,#0EFH,NEXTYES:ACALLDAYAREAD:MOVA,P0ANLA,#0F0HMOVR2,AMOVA,BANLA,#0FHORLA,R2YES1:MOVR1,AMOVR0,#0MOVDPTR,#TAB1SJMPCMKEYDAY:MOVR6,#20;延时DL2:MOVR7,#7DHDL1:NOPNOPDJNZR7,DL1DJNZR6,DL2RETCMKEY:MOVA,R0MOVCA,@A+DPTRCLRCSUBBA,R1JZDISPINCR0MOVA
4、,#10HSUBBA,R0JZTESTSJMPCMKEYDISP:MOVA,38H;判断是否开始计时了CJNEA,#01H,NORMALMOVA,35HCJNEA,#01H,NORMALMOVDPTR,#TAB2MOVA,R0CJNEA,#0FH,BACK1;判断是否为15(暂停)CLRTR0;暂停,则关闭计时CLRET0MOV38H,#00HAJMPBACK1NORMAL:MOVDPTR,#TAB2;显示程序段MOVA,R0MOV37H,ACJNEA,#0BH,GO;输入是否为11(倒计时)MOV38H,#01H;倒计时开始MOV
5、TH0,#3CHMOVTL0,#0BHSETBET0SETBEAMOVR4,#0AHMOV35H,#00HSETBTR0AJMPTESTGO:MOVCA,@A+DPTR;不倒计时MOV34H,A;暂存于34HMOVR0,40HMOVR1,41HMOVR2,42HMOVA,35HCJNEA,#00H,BIJIAOAJMPBACK1BIJIAO:CJNER0,#01H,YIWEI;判断输入了几个数,是否移位MOV30H,34HMOV50H,37HMOV40H,#00HAJMPBACK1YIWEI:CJNER1,#01H,ERWEIMOV
6、31H,30HMOV30H,34HMOV51H,50HMOV50H,37HMOV41H,#00HAJMPBACK1ERWEI:CJNER2,#01H,BACK1MOV32H,31HMOV31H,30HMOV30H,34HMOV52H,51HMOV51H,50HMOV50H,37HMOV42H,#00HBACK1:MOV35H,#00HCLRCMOVA,38HCJNEA,00H,BQLMOVA,34HCJNEA,#77H,BQL;判断是否为10(清零)LJMPCHUSHIBQL:ACALLDAYLJMPTESTDENG:MOVA,P3
7、;子程序三个数码管轮流发光CJNEA,#04H,BIAN1;P3口001010100轮流变换RRAMOVP3,AAJMPHUIBIAN1:CJNEA,#02H,BIAN2RRAMOVP3,AAJMPHUIBIAN2:MOVP3,#04HHUI:MOVR5,P3CJNER5,#01H,FIRMOVP1,30HAJMPBACKFIR:CJNER5,#02H,SECMOVP1,31HAJMPBACKSEC:MOVP1,32HBACK:MOVTH1,#0DFHMOVTL1,#0FFHRETIJISHI:DJNZR4,RET0;子程序倒计时M
8、OVR4,#0AH;10次后,开始减数计时MOVR0,50HMOVR1,51HMOVR2,52HCJNER0,#00H,GEWEI;判断是否开始借位CJNER1,#00H,SHIWEI;三位轮流判断CJNER2,#00H,BAIWEI