资源描述:
《微机原理实验8237,8251,8253,8255,8259程序精华版》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、8237实验程序.MODELTINYDMAaddrEQU0E000H$237基地址.STACK10()・CODESTAR:MOVAX,0MOVDS,AXmovsi,30()()hmoval,Offhmovcx,0800hSTAR3:mov[si],al;禁止DMA操作;复位;清除先/后寄存器;源启始地址3000HincsidecalloopSTAR3moval,04hmovdx,DMAaddr+8outdx,almoval,00movdx,DMAaddr+Odhoutdx,almovdx,DMAaddr+Ochoutdx,al;movdx,3000hmovdx,DMAadd
2、r+00houtdx,almovoutal,30hdx,almoval,00movdx,DMAaddr+Ochoutdx,al;清除先/后寄存器movdx,6000h;目的启始地址6000Hmovdx,DMAaddr+02houtdx,almoval,60houtdx,almovahOOmovdx,DMAaddr+Ochoutdx,al;清除先/后寄存器movdx,DMAaddr+03hmovoutax,7ffh;长度0800Hdx,almoval,ahoutdx,almovdx,DMAaddr+Obhmoval,88houtdx,al;通道()方式字moval,85hou
3、tdx,al;通道1方式字movdx,DMAaddr+8moval,41houtdx,al;允许8237T.作、存贮器方式传送starl:movdx,DMAaddr+()fhmoval,0choutdx,al;允许通道0、通道1movdx,DMAaddr+09hmoval,04houtdx,al;允许DMA操作movdx,DMAaddr+08hNOPNOPstar2:inal,dxTESTAL,()3Hjzstar2;等待DMA结束movdx,DMAaddr+Odhinal,dx;读暂存寄存器movdx,DMAaddr+Ochoutdx,almovdx,DMAaddr+3;
4、清除先/后寄存器INAL,DXMOVAH,ALINAL,DXCMPAX,0FFFFHJNZstarlmovdx,DMAaddr+09hmoval,00houtdx,al;清除DMA请求movdx,DMAaddr+()8hmoval,04houtdx,al;禁止DMA操作movdx,DMAaddr+Odhinal,dx;读暂存寄存器movsi,3()()()hmovbx,6000hmovcx,0800hSTAR5:moval,[sijcmpal,ds:[bx]jnefalseincsiincbxloopSTAR5true:jmp$false:jmp$ENDSTAR//////
5、////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8251实验程序.MODELTINY;使川8253的计数器0,外接2Mhz,经26分频后,送给8251,产牛4800bpsCTL_ADDRDATA_ADDRW_8253_T0W_8253_CEQU0FF01HEQU0FF00HEQU0BF00HEQU0BF03H;控制字或状态字;读写数据;计数器0地址;控制
6、字.STACK100.DATAReceive_BufferDB10DUP(O)Send_BufferEQUReceive_Buffer;接受缓冲器;发送缓冲器.CODESTART:MOVAX,@DATAPROCNEARMOVDX,W_8253_CMOVAL,37HOUTdx,alMOVDX,W_8253_T0MOVAL,26HOUTDX,ALINIT_8253MOVDS,AXMOVES,AXNOPCALLINIT_8253CALLINIT_8251START1:MOVCX,10CALLReceive_GroupMOVCX,10CALLSend_GroupJMPSTART1;
7、定时器(),方式3;BCD码26(2000000/26)=16*4800MOVAL,0OUTDX,ALRETINIT.8253ENDPCALLRESET_8251MOVDX,CTL_ADDR;?MOVAL,7E比?OUTDX,AL;?CALLDLTIME;延时MOVAL,15比?OUTDX,AL;?CALLDLTIMERETINIT_8251PROCNEAR;波特率系数为16,8个数据位;一个停止位,偶校验OUTDX,AL;允许接收和发送发送数据,清错误标志INIT_8251ENDPReset_8251PROCNE