您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 微机原理实时时钟课程设计
西南科技大学微机原理课程设计题目电子实时时钟软件设计1任务实现如图所示电子日历时钟功能。2基本要求1)可通过M键切换显示模式:日期(年、月、日)、时间(小时、分、秒)、秒表(小时、分、秒、1/100秒)、闹钟(小时、分)。2)在秒表显示模式,可通过I键切换(启动/暂停)计时,当暂停计时时可通过A键复位。3)在闹钟显示模式,有两种输入方式方式一:直接按格式输入时间方式二:可通过A键依次使On/Off标志、小时、分、秒闪烁或变色,这时可通过I键切换On/Off标志或加1调整。4)可通过esc键结束程序。3扩展要求1)在日期显示模式,可通过A键依次使年、月、日闪烁或变色,这时可通过I键加1调整。2)在时间显示模式,可通过A键依次使小时、分、秒闪烁或变色,这时可通过I键加1调整。3)调整和秒表操作不影响日期和时间的准确性。4)自定义的其它扩展功能说明:本程序为西科微机原理课程设计题目,下面的代码只实现了基本要求部分,并且秒表还存在部分问题(秒表模式修改了定时器0,结束后对时间略有影响,测试闹钟时可以直接在秒表模式下,按q键跳过秒表模式),代码仅供参考,欢迎对其繁琐处进行修改,调试。DateYYYY:MM:DDTimeHH:MM:SSBeepOn/OffHH:MM:SSMeter00:00:00:00MMMM各部分程序流程图:开始初始化:清空屏幕,扬声器初始化刷新时间与日期判断模式0?1?2?3?闹钟打开?BFLAG0?进入相应模式:调用对应子程序改变模式mode的值有键按下?Esc?M?是否响了BFLAG=1?检查停止时间是否到了CALLCHESTOP结束检出时间是否到callchestartYNNYNYNNYY主函数流程图开始保护现场寄存器入栈取系统日期AH=2AINT21HDAY=DLMON=DHYEAR=CX取系统时间AH=2CHINT21HHOUR=CHMIN=CLSEC=DHMSEC=DL还原现场,寄存器出栈退出,回到主程序时间与日期的刷新子过程开始保护现场,寄存器入栈打印提示信息打印提示信息取年AX=YEAR调用BCD转换显示过程打印’/’取月AX=MON调用BCD转换显示过程打印’/’取日AX=DAY调用BCD转换显示过程将后面多余的字符清除调用BCD转换显示过程退出,回到主程序时间日期显示子过程开始提示语显示闹钟在响?BFLAG=2?关闭设置光标位置输入字符按格式输入,将其存放到缓存区A?设定的时间转化为二进制数AI键输入方式:时间调整方式退出,回到主程序NY闹钟设定子过程YN该过程与代码略有不同,处理on/off位是后来添加的代码,流程图没有加入开始初始化屏幕,光标开头有键按下?A?取光标位置,自加,SI++光标DL自加光标到‘:’?到末尾?按照DL值置光标位置初始化SI=OFFSETBEEPHOURYNYNYNNY处理第一位处理第二位SIHOUR第一位?SIHOUR第二位?SIMIN第一位?处理第三位处理第四位YYYNNN是否I?读光标出字符并自加,[SI]自加打印改变后的字符AI键输入时间方式:时间调整输入DATASEGMENTUISDB0DH,0AH,10dup(0),50DUP('*'),'$'UIEDB0DH,0AH,10dup(0),50DUP('*'),'$';界面字符MSG1DBTHEDATAIS$MSG2DBTHETIMEIS$MSGINDBPLEASECHOOSEINPUTMETHODS:,0DH,0AHDB21DUP(),PRESSAFORA/IMETHOD,ORFORDIRECTMETHOD$MSGDIRDBPLEASEINPUTLIKETHIS:OO:00,0DH,0AHDB21DUP(),PRESSENTERTOCONFIRM$MSGWARNDBERROR!PLEASEENTERAGAIN$MSGAIDBPRESSaTOCHANGEPOSITION,0DH,0AHDB21DUP(),iTOCHANGEVALUE,ENTERTOCONFIRM$MSGSECDBPRESSiTOSTARTANDSTOP,0DH,0AHDB21DUP(),qTOQUIT,aTOCLEARIFITHASSTOPED$NULINEDB25DUP(?),'$';清空行KSBUFDB6,0,6DUP(?)KEYNUMDB?MODEDB?DAYDB?MONDB?YEARDW?SECDB?MSECDB?MINDB?HOURDB?BEEPHOURDB0,0BEEPMINDB0,0SWIOFFDBFF$SWIONDBN$SETSTRDB00:00OFF/ON,'$'WSTRDB00:00:00,'$'BFLAGDB0SFLAGDB0INISEGDW0INIOFFDW0DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXCALLCLEARCALLCREATUIMOVMODE,0CALLSOUNDAGAIN:CALLREFRESH;刷新时间日期;******BFALG为闹钟与秒表标志位。下面为处理闹钟CMPBFLAG,0JESETMOUCMPBFLAG,1JNECRINGCALLCHESTARTJMPSETMOUCRING:CALLCHESTOPJMPSETMOUJMAGAN:JMPAGAIN;二级跳转SETMOU:MOVDX,0815HMOVAH,02MOVBH,0INT10H;设置光标;模式判断***********CMPMODE,0JEMODE0CMPMODE,1JEMODE1CMPMODE,2JEMODE2CMPMODE,3JEMODE3MODE0:CALLTIMESHOWJMPKEYSCANMODE1:CALLDATESHOWJMPKEYSCANMODE2:CALLBEEPMOVMODE,03HJMPKEYSCANMODE3:CALLSEDWHATCHMOVMODE,0H;键盘扫描*********KEYSCAN:MOVAH,0BHINT21HCMPAL,00JEAGAINMOVAH,08HINT21HCMPAL,1BHJZSTOPCMPAL,'m'JNEAGAININCMODECMPMODE,4JNEJMAGANMOVMODE,0JMPJMAGANSTOP:MOVAH,4CHINT21H;*******时间日期刷新*****REFRESHPROCPUSHAXPUSHCXPUSHDXMOVAH,2AHINT21HMOVDAY,DLMOVMON,DHMOVYEAR,CXMOVAH,2CHINT21HMOVHOUR,CHMOVMIN,CLMOVSEC,DHMOVMSEC,DLPOPDXPOPCXPOPAXRETREFRESHENDP;********年月日显示DATESHOWPROCPUSHAXPUSHCXPUSHDXMOVDX,OFFSETMSG1MOVAH,09INT21HMOVAX,YEAR;取年CALLBTOBCDMOVDL,'/'MOVAH,02HINT21HMOVAH,0MOVAl,MON;月CALLBTOBCDMOVDL,'/'MOVAH,02HINT21HMOVAH,0MOVAL,DAY;日CALLBTOBCDMOVDX,OFFSETNULINEMOVAH,09INT21HPOPDXPOPCXPOPAXRETDATESHOWENDP;*********时间显示TIMESHOWPROCPUSHAXPUSHBXPUSHCXPUSHDXMOVDX,OFFSETMSG2MOVAH,09INT21HMOVAH,0MOVAL,HOUR;取时CALLBTOBCDMOVDL,':'MOVAH,02HINT21HMOVAH,0MOVAL,MIN;分CALLBTOBCDMOVDL,':'MOVAH,02HINT21HMOVAH,0MOVAL,SEC;秒CALLBTOBCDCMPSFLAG,0JETOCLRMOVDL,':'MOVAH,02HINT21HMOVAH,0MOVAL,MSEC;10M秒CALLBTOBCDTOCLR:MOVDX,OFFSETNULINEMOVAH,09INT21HPOPDXPOPCXPOPBXPOPAXRETTIMESHOWENDP;将二进制转化为BCD码并显示BTOBCDPROCPUSHDXPUSHBXPUSHCXMOVCX,0MOVBX,10BTOD:MOVDX,0DIVBXPUSHDXINCCLCMPAX,0JABTODSHOW:POPDXADDDL,30hMOVAH,02hINT21hLOOPSHOWPOPCXPOPBXPOPDXRETBTOBCDENDP;*****闹钟设定******BEEPPROCMOVDX,0715HMOVAH,02MOVBH,0INT10HMOVDX,OFFSETMSGINMOVAH,09INT21HCMPBFLAG,2;设定时还在响,那么关闭JNESETMINAL,61HANDAL,0FDHOUT61H,ALSETM:MOVDX,0715HMOVAH,02MOVBH,0INT10HMOVAH,07HINT21HCMPAL,'a'JEINA;选择输入方式,a为切换输入,其他键为键盘直接输入MOVDX,OFFSETMSGDIRMOVAH,09INT21HMOVDX,0915HMOVAH,02MOVBH,0INT10HMOVDX,OFFSETKSBUFMOVAH,10INT21H;键盘输入字符存入缓存区MOVBFLAG,1MOVSI,OFFSETKSBUF+1MOVCL,BYTEPTR[SI]MOVBX,10INCSIANDBYTEPTR[SI],0FHMOVAL,BYTEPTR[SI]MULBLINCSIANDBYTEPTR[SI],0FHADDAL,BYTEPTR[SI]MOVBEEPHOUR,ALADDSI,2ANDBYTEPTR[SI],0FHMOVAL,BYTEPTR[SI]MULBLINCSIANDBYTEPTR[SI],0FHADDAL,BYTEPTR[SI]MOVBEEPMIN,ALJMPTOENDINA:MOVDX,OFFSETMSGAI;A/I切换输入方式MOVAH,09INT21HMOVDX,0915HMOVAH,02MOVBH,0INT10HMOVDX,OFFSETSETSTRMOVAH,09INT21HMOVDX,0915HMOVAH,02MOVBH,0INT10HMOVSI,OFFSETBEEPHOUR;*****a键切换光标位置*********KASCAN:MOVAH,0BHINT21HCMPAL,00JEKASCANMOVAH,08HINT21HMOVKEYNUM,ALCMPAL,'a'JNEKISCANMOVBH,0MOVAH,03HINT10HINCDLINCSICMPDL,17HJETOMICMPDL,1AHJETOSWCMPDL,22HJETOHOJMPSETFTOMI:INCDLJMPSETFTOSW:MOVDL,21HJMPSETFTOHO:MOVDL,15HMOVSI,OFFSETBEEPHOURSETF:MOVAH,02HINT10HKAJMP:JMPKASCAN;*****i键改变光标处字符*****KISCAN:CMPKEYNUM,'i'JNEJKCR0MOVAH,08H;读光标处字符INT10HINCALINCBYTEPTR[SI]CMPSI,OFFSETBEEPHOURJEJUGHORCMPSI,OFFSETBEEPHOUR+1JEJUGHOR2CMPSI,OFFSETBEEPHOUR+2JEJUGMINCMPSI,OFFSETBEEPHOUR+3JEJUGMIN2CMPSI,OFFSETBEEPHOUR+4JECHGSWJMPJUGHORJKCR0:JMPKCRJUGHOR:CMPAL,32HJNAPRINTMOVBYTEPTR[SI],0MOVAL,30HJMPPRINTJUGHOR2:CMPBEEPHOUR,2HJE
本文标题:微机原理实时时钟课程设计
链接地址:https://www.777doc.com/doc-4458424 .html