您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 汇编语言实现实时时钟显示
汇编语言实现实时时钟显示datasegmentmsgdb'Currenttimeis:'hoursdb?,?db':'minutesdb?,?db':'secondsdb?,?,0oldint1cdd?;旧的入口参数positiondw0;时间显示位置colordb07hdataendscodesegment;代码段assumecs:code,ds:codestart:movax,datamovds,axjmprunnewint1c:pushaxpushbxpushcxpushdxpushsipushdipushesmovax,datamovds,axmovax,0200h;获取系统时间,ch→hourscl→minutesDH→seconds,均为BCD码格式int1ah;时钟服务moval,chleasi,hours;时callBCDmoval,clleasi,minutes;分callBCDmoval,dhleasi,seconds;秒callBCDmovax,0b800h;显存地址,采用直接写显存的方法输出字符moves,ax;es:di指向显存地址leasi,position;设置时间显示位置movdi,[si]leasi,msgdisp:moval,[si]incsioral,aljzexitcldstosbincdijmpdispexit:popespopdipopsipopdxpopcxpopbxpopaxjmpds:oldint1c;执行旧的中断服务程序BCDprocpushax;用于将BCD码转换为ASCII码入口al-BCD码movah,al;出口shrah,1shrah,1shrah,1shrah,1andal,0fhaddax,'00';加上0的ASCII码xchgah,almov[si],axpopaxretBCDendprun:movax,datamovds,axmovax,351ch;获取原1ch的入口参数int21hmovwordptrds:oldint1c,bx;保存旧的入口参数movwordptrds:oldint1c+2,espushdspushcspopdsleadx,newint1cmovax,251ch;设置新1ch的入口参数int21hpopdsmovdx,offsetrun+10h;1节=16字节movcl,4shrdx,cl;相当于除以16以计算节大小callControl;调用控制子程序callflashmovah,31h;结束并驻留,DX:保留的长度(内存大小单位为节)int21hControlprocpushaxpushcxpushbxcallHideCursor;隐藏光标xorbx,bx;置0,时间显示位置getkey:movah,0;获取键盘扫描码int16hcmpax,011bh;esc-011bhjzreturncmpax,4800h;up-4800hjzupcmpax,5000h;down-5000hjzdowncmpax,4b00h;left-4b00hjzleftcmpax,4d00h;right-4d00hjzrightjmpchangeColor;up:cmpbx,160jcgetkeysubbx,160jmpchangePosdown:addbx,160jmpchangePosleft:cmpbx,0jzgetkeysubbx,2jmpchangePosright:addbx,2changePos:callflashmovds:position,bxjmpgetkeychangeColor:;subal,30hmovds:color,ahcallflashjmpgetkeyreturn:popbxpopcxpopaxretControlendpflashprocpushaxpushbxpushcxpushdxmovah,06h;AH使用显示服务(INT10H)的向上卷屏功能(06H)moval,00h;AL滚动行数,0为整个窗口movbh,ds:color;BH显示页面(本程序均使用第0页)movch,0movcl,0;CH,CL窗口左上角坐标movdh,24movdl,79;DH,DL窗口右下角坐标,因为清全屏所以为(0,0)~(24,79)int10h;调用中断popdxpopcxpopbxpopaxretflashendpHideCursorprocpushaxpushdxpushbxmovah,02movdh,24movdl,00movbh,00int10HpopbxpopdxpopaxretHideCursorendpcodeendsendstart
本文标题:汇编语言实现实时时钟显示
链接地址:https://www.777doc.com/doc-4094439 .html