资源描述:
《微机串口通信课设汇编程序课程设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、OUTBITequ08002h;位控制口OUTSEGequ08004h;段控制口IN_KEYequ08001h;键盘读入口CS8251Dequ09000h;串行通信控制器数据口地址CS8251Cequ09001h;串行通信控制器控制口地址datasegmentLEDBufdb6dup(?);显示缓冲Numdb1dup(?);显示的数据DelayTdb1dup(?)RBufdb0TBufdb0LEDMAP:;八段管显示码db3fh,06h,5bh,4fh,66h,6dh,7dh,07hdb7fh,6fh,77h,7ch,39h,5eh,79h,71hKeyTabl
2、e:;键码定义db16h,15h,14h,0ffhdb13h,12h,11h,10hdb0dh,0ch,0bh,0ahdb0eh,03h,06h,09hdb0fh,02h,05h,08hdb00h,01h,04h,07hcodesegmentassumecs:code,ds:dataDelayprocnearpushax;延时子程序pushcxmoval,0movcx,axloop$popcxpopaxretDelayendpDispprocnear;发送显示moval,TBufandal,0fh;只显示低四位movah,0movbx,offsetLEDMAPa
3、ddbx,axmoval,LEDBuf+1movLEDBuf+0,almoval,LEDBuf+2movLEDBuf+1,almoval,[bx];转换成显示码movLEDBuf+2,alretDispendpDisplayLEDprocnearmovbx,offsetLEDBufmovcl,6;共6个八段管movah,00100000b;从左边开始显示DLoop:movdx,OUTBITmoval,0outdx,al;关所有八段管moval,[bx]movdx,OUTSEGoutdx,almovdx,OUTBITmoval,ahoutdx,al;显示一位八段管
4、pushaxmovah,1callDelaypopaxshrah,1incbxdeccljnzDLoopmovdx,OUTBITmoval,0outdx,al;关所有八段管retDisplayLEDendpTestKeyprocnearmovdx,OUTBITmoval,0outdx,al;输出线置为0movdx,IN_KEYinal,dx;读入键状态notalandal,0fh;高四位不用retTestKeyendpGetKeyprocnearmovch,00100000bmovcl,6KLoop:movdx,OUTBITmoval,ch;找出键所在列nota
5、loutdx,alshrch,1movdx,IN_KEYinal,dxnotalandal,0fhjneGoon_;该列有键入deccljnzKLoopmovcl,0ffh;没有键按下,返回0ffhjmpExit1Goon_:decclshlcl,2;键值=列X4+行movch,4LoopC:testal,1jnzExit1shral,1inccldecchjnzLoopCExit1:movdx,OUTBITmoval,0outdx,almovch,0movbx,offsetKeyTableaddbx,cxmoval,[bx];取出键码movbl,alWaitR
6、elease:movdx,OUTBITmoval,0outdx,al;等键释放movah,10callDelaycallTestKeyjneWaitReleasemoval,blretGetKeyendpIInitprocnear;8251初始化movdx,CS8251Cmoval,01001111b;1停止位,无校验,8数据位,x64outdx,almoval,00010101b;清出错标志,允许发送接收outdx,alretIInitendpSendprocnear;串口发送movdx,CS8251Cmoval,00010101b;清出错,允许发送接收out
7、dx,alWaitTXD:inal,dxtestal,1;发送缓冲是否为空jzWaitTXDmoval,TBuf;取要发送的字movdx,CS8251Doutdx,al;发送pushcxmovcx,0ffffhloop$popcxretSendendpReceiveprocnear;串口接收movdx,CS8251CWaitRXD:inal,dxtestal,2;是否已收到一个字jeWaitRXDmovdx,CS8251Dinal,dx;读入movRBuf,alretReceiveendpstartprocnearmovax,datamovds,axcallII
8、nitmovLEDBuf