您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 东南大学信息学院微机实验报告九
实验九一、实验目的1.熟悉系统功能调用INT21H的有关功能2.编写时钟程序二、实验任务1.执行时钟程序时,屏幕上显示提示符“:”,由键盘输入当前时、分、秒值,即XX:XX:XX,随即显示时间并不停地计时。2.当有键盘按下时,立即停止计时,返回DOS。三、源程序DATASEGMENTBUFFERDB11DB?DB10DUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATAOUTCLK:MOVAX,DATAMOVDS,AXMOVDL,':'MOVAH,2INT21HMOVDX,OFFSETBUFFERMOVAH,0AH;输入字符串INT21HMOVBX,OFFSETBUFFER+2MOVAL,[BX];时针,ASCII码转非压缩BCDCMPAL,03AHJAEERROR1CMPAL,02FHJBEERROR1ANDAL,0FHMOV[BX],ALINCBXMOVAL,[BX]ANDAL,0FHMOV[BX],ALINCBXINCBXMOVAL,[BX];分针ANDAL,0FHMOV[BX],ALINCBXMOVAL,[BX]ANDAL,0FHMOV[BX],ALINCBXINCBXMOVAL,[BX];秒针ANDAL,0FHMOV[BX],ALINCBXMOVAL,[BX]ANDAL,0FHMOV[BX],ALMOVBX,OFFSETBUFFER+2CALLTOBCD;时针,两位非压缩BCD转换成两位压缩BCDMOVCH,ALADDBX,3CALLTOBCDMOVDH,AL;分针,两位非压缩BCD转换成两位压缩BCDMOVDH,ALADDBX,3CALLTOBCD;秒针,两位非压缩BCD转换成两位压缩BCDMOVDL,ALCMPCH,24HJAEERRORCMPDH,60HJAERRORCMPDL,60HJAERRORERROR1:MOVAH,4CHINT21HAGAIN:CALLDELAYMOVAL,DL;秒针加1ADDAL,1DAAMOVDL,ALCMPAL,60HJAERRORJNEDISPYMOVDL,0MOVAL,DHADDAL,1;分针DAAMOVDH,ALCMPAL,60HJAERRORJNEDISPYMOVDH,0MOVAL,CHADDAL,1DAA;时针MOVCH,ALCMPAL,24HJAEERRORJNEDISPYMOVCH,0ERROR:MOVDL,0MOVDH,0MOVCH,0DISPY:MOVBX,OFFSETBUFFERMOVAL,0DHMOV[BX],ALINCBXMOVAL,0MOV[BX],ALINCBXMOVAL,CHCALLTRANINCBXMOVAL,':'MOV[BX],ALINCBXMOVAL,DHCALLTRANINCBXMOVAL,':'MOV[BX],ALINCBXMOVAL,DLCALLTRANINCBXMOVAL,'$'MOV[BX],ALPUSHBXPUSHCXPUSHDXMOVDX,OFFSETBUFFERMOVAH,9INT21HMOVAH,06HMOVDL,0FFHINT21HPOPDXPOPCXPOPBXJNEGOJMPAGAINGO:MOVAH,4CHINT21HTOBCDPROC;两位非压缩BCD转换成压缩MOVAL,[BX]MOVCL,4SHLAL,CLORAL,[BX+1]RETTOBCDENDPTRANPROC;BCD转ASCIIMOVCL,ALSHRAL,1SHRAL,1SHRAL,1SHRAL,1ORAL,30HMOV[BX],ALINCBXMOVAL,CLANDAL,0FHORAL,30HMOV[BX],ALRETTRANENDPDELAYPROCPUSHCXPUSHAXMOVAX,0FFFFHFIR:MOVCX,02FFFHGOON:DECCXJNEGOONDECAXJNEFIRPOPAXPOPCXRETDELAYENDPCODEENDSENDOUTCLK四、思考题时钟程序中存在误差吗?若有误差,其来源在何处?如何进行误差矫正?答:存在,来源自实验循环的次数,来自“MOVAX,0FFFFHFIR:MOVCX,02FFFH”,如要进行矫正,只需调整AX与CX使之乘积与计算机运行速度相匹配即可。
本文标题:东南大学信息学院微机实验报告九
链接地址:https://www.777doc.com/doc-5069046 .html