資源描述:
《單片機(jī)—電子鐘實驗源程序》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、;22H~24H存時鐘時間;32H~34H存鬧鐘時間;42H~44H存秒表吋I'可;MON用于選擇時鐘/鬧鐘調(diào)時;30H作為標(biāo)志;RST用于選擇時、分、秒;LAST調(diào)時減1,NEXT調(diào)時加1;EXEC用于開始秒表計吋;40H作為標(biāo)志CM1EQU8001HCM2EQU8002HCM4EQU8004HORG0000HUMPMAINORG000BHLJMPSEROORGOO1BHUMPSERIORG0030HMAIN:MOVSP,#70HMOV32H,#OOHMOV33H,#OOHMOV34H,#00H;設(shè)置鬧鐘初始值MOV42H,#00HMOV43H,#
2、00HMOV44H,#00H;設(shè)置秒表初始值MOV26H?#11H;26H作為標(biāo)志(h,min,s)MOV3OH,#OOH;30H作為時鐘(0)與鬧鐘⑴的標(biāo)志MOVR4,#0C8H;設(shè)200次循環(huán)MOVTMOD,#20H;T0方式0,T2方式2MOVTH0,#63H;5msMOVTL0,#10HMOVTH1,#9CHMOVTL1Z#9CH;100MSSETBPl.lSETBEASETBETOSETBET1SETBTROMOVA,22H;檢查吋鐘格式是否正確CLRCSUBBA,#24HJNCINITMOVA,23HCLRCSUBBA,#60HJNCIN
3、ITMOVA,24HCLRCSUBBA,#60HJNCINITUMPLOADINIT:MOV22H,#12H;時鐘格式不正確時進(jìn)行初始化,為12:00:00MOV23H,#00HMOV24H,#00HLOAD:CLRRSOCLRRSI;第一組工作寄存器MOVA,40HJZS1;40H為1時,42H~44H(秒表)送顯示緩沖區(qū)MOVR0,#42HUMPNOADSI:MOVA,30HJZSOAD;30H為0時,22H~24H(時鐘)送顯示緩沖區(qū)MOVR0,#32H;30H為[時,32H~34H(鬧鐘)送顯示緩沖區(qū)UMPNOADSOAD:MOVR0,#22
4、HNOAD:MOVRl,#60H;將對應(yīng)的時間送入顯示緩沖區(qū)60H~65HMOVR5Z#O3HL00P1:MOVA,@ROANLA,#OFOHSWAPAMOV@R1,AMOVA,3OHINCRlJZC4MOVA,@ROLCALLNJ;鬧鐘調(diào)用NJANLA,#OFHUMPSENDMOV@R1,AC4:LCALLAJ;時鐘調(diào)用AJINCRlUMPSENDINCROCl:MOVA,25HDJNZR5,LOOP1CJNEA,#01H,C2LCALLDPILCALLLAST;調(diào)用顯示子程序;鍵值為LAST時,調(diào)用減1運(yùn)算MOVA,32HUMPSENDCJNEA
5、,22H,SWEEPC2:MOVA,25HMOVA,33HJNZSENDCJNEA,23H,SWEEPLCALLNEXTSETBTR1;鍵值為NEXT時,調(diào)用加1運(yùn)算;時鐘與鬧鐘的時和分相等時開定時器1SEND:MOV25H,#99HSWEEP:LCALLSEARCHCLRRSOMOVA,25HCLRRSI;25H存鍵號UMPLOADCJNEA,#04H,C6?/MOVA,40H?9?判斷時鐘h/min/s標(biāo)志位26HADDA,#01H?9MOVB,#02HAJ:SETBRSODIVAB;換工作寄存器MOV40H,BCLRRSI;鍵值為EXEC時,處
6、理40H標(biāo)志位MOVA,26HMOV42H,#00HCJNEAZ#11H,AJ1MOV43H,#00HMOVR1,#21HMOV44H,#00HSETBTRO;秒表賦初值UMPARETLJMPSEND;R1存對應(yīng)時鐘位C6:CJNEA,#O2H,C3AJ1:CLRTROMOVA,3OHCJNEA,#22H,AJ2ADDA,#O1HMOVR1,#22HMOVB,#02HAJ2:CJNEA,#44H,AJ3DIVABMOVR1Z#23HMOV3OH,BAJ3:CJNEA,#88H,ARET;鍵值為MON吋,處理30H標(biāo)志位MOVR1,#24HUMPSEN
7、DARET:RETC3:CJNEAZ#O3H,C1■/MOVA,26H?9?判斷鬧鐘h/min/s標(biāo)志位26HRLA?9;鍵值為RST時,處理26H標(biāo)志位NJ:SETBRSOMOV26H,ACLRRSI;第1組工作寄存器MOVA,26HCJNEAZ#11H,NJ1MOVR1,#31HUMPARET;R1存對應(yīng)時鐘位NJ1:CJNEA,#22H,NJ2NJ2:MOVR1,#32HCJNEA,#44H,NJ3NJ3:MOVR1,#33HCJNEA,#88H,NJRETNJRET:■MOVR1,#34HRET9■f一減1運(yùn)算LAST:MOVA,3OHJZL
8、AO;30H為0時,時鐘進(jìn)行減1運(yùn)算UMPNA0;30H為1時,鬧鐘進(jìn)行減1運(yùn)算LAO:LCALLAJCJN