您好,欢迎访问三七文档
当前位置:首页 > 建筑/环境 > 建筑材料 > 微机原理与接口技术实验报告及答案
微机实验答案实验三统计学生成绩设有20个学生成绩分别56、78、67、40、87、99、63、51、74、100,90,80,68、88、55、66、84、96、45、73分。编写程序实现统计低于60分、60-69分、70-79分、80-89分、90-99分及100分的人数,并分别存放在s5、s6、s7、s8、s9、s10单元中。实验代码如下:datasegmentscoredb56,78,67,40,87,99,63,51,74,100,90,80,68,88,55,66,84,96,45,73s5db0s6db0s7db0s8db0s9db0s10db0dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovsi,0movcx,20lop1:cmpscore[si],60jbstep1cmpscore[si],70jbstep2cmpscore[si],80jbstep3cmpscore[si],90jbstep4cmpscore[si],100jbstep5inc[s10]jmpexitstep1:inc[s5]jmpexitstep2:inc[s6]jmpexitstep3:inc[s7]jmpexitstep4:inc[s8]jmpexitstep5:inc[s9]exit:incsilooplop1moval,s6;显示s6,可用s5,s7,s8等替换(实验要求之思考题三)addal,48movdl,almovah,02int21hmovah,4chint21h实验四查找字符实验内容试编写一个有主程序和子程序结构的程序模块。主程序:要求从键盘接收一串字符并存于字节数组TABLE中,显示字符CHAR出现的次数。子程序:在以TABLE为首地址的字节数组中查找CHAR,统计出现的次数。实验代码如下:datasegmenttabledb100dup('$')str1db'pleaseenterastringwhichislessthan100andendwithenterbutton:$'str2db'timesthatcharappearis:$'ndw?dataendsstacksegmentstack'stack'db100dup('$')stackendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axleadx,str1movah,9int21h;输出str1callfunc1;回车,换行movsi,0movcx,100lop1:movah,1int21hcmpal,0dhjzexitmovtable[si],alincsilooplop1;从键盘输入exit:movn,sicallfunc2;计算'char'出现的次数callfunc1;回车,换行leadx,str2movah,9int21h;输出str2callfunc1;回车,换行moval,bladdal,30hmovdl,almovah,2int21h;输出'bx'movah,4chint21hfunc1procnearpushdxpushaxmovdl,0ahmovah,2int21hmovdl,0dhmovah,2int21hpopaxpopdxretfunc1endp;输出回车,换行func2procnearpushsipushcxpushaxmovcx,simovax,sisubax,3;此处为何减3,下面会有解释leasi,tablemovbx,0lop2:cmpbyteptr[si],'c'jnzexit1;判断完c后加1再循环,而h,a,r则不然incsicmpbyteptr[si],'h'jnzexit2incsicmpbyteptr[si],'a'jnzexit2incsicmpbyteptr[si],'r'jnzexit2incbxexit1:incsiexit2:cmpsi,axloopnzlop2popaxpopcxpopsiretfunc2endpcodeendsendstart实验六定时计数器实验实验代码如下:.modelsmall.386codesegmentassumecs:codestart:movax,datamovds,axmovdx,203hmoval,00110110boutdx,almovdx,200hmovax,0h;0h减1后得到FFH,从而满足题目要求outdx,almoval,ahoutdx,al;movdx,203hmoval,01110110boutdx,almovdx,201hmovax,fhoutdx,almoval,ahoutdx,almovah,4chint21hcodeendsendstart实验七中断控制器实验实验相关知识简介:实验内容1、单中断,使用单脉冲电路产生脉冲信号作为8259中断请求输入,每按一次单脉冲按键,触发一次中断,使LED灯向左移一位,显示到最左端后再从最右端开始开始,循环显示。2、单中断:使用单脉冲电路产生的脉冲信号作为386EX模块8259中断请求输入,每按一次单脉冲按键,触发一次中断,使7段数码管显示的“5”字左移一位,显示到最左端后再从最右端开始显示,如此重复。实验1代码:.ModelSmall.386CODESEGMENTASSUMECS:CODESTART:INAL,21HANDAL,0DFH;开通IR5中断通道OUT21H,ALCLIMOVAX,00HMOVDS,AXMOVSI,4*35HMOVAX,OFFSETINTPMOV[SI],AX;设置中断向量,将intp的偏移地址赋给[si]ADDSI,2MOVAX,SEGINTPMOV[SI],AX;si+2后将段地址赋给[si]MOVDX,203HMOVAL,10000011B;设置方式字OUTDX,ALMOVBL,1;设置bl的值,用于以后循环亮灯STEP:STIHLT;等待中断信号,接到中断信号后重复该步骤JMPSTEPINTPPROCNEARCLIPUSHAXPUSHDXMOVAL,BLMOVDX,200H;输出LED亮灯信号OUTDX,ALROLBL,1;循环左移,控制亮灯信号MOVAL,20HOUT20H,AL;中断结束命令POPDXPOPAXSTIIRETINTPENDPCODEENDSENDSTART实验2代码:.ModelSmall.386CODESEGMENTASSUMECS:CODESTART:INAL,21HANDAL,0DFH;开通IR5中断通道OUT21H,ALCLIMOVAX,00HMOVDS,AXMOVSI,4*35HMOVAX,OFFSETINTP;设置中断向量,将INTP的偏移地址赋给[SI]MOV[SI],AX;SI+2后,将INTP的段地址赋给[SI]ADDSI,2MOVAX,SEGINTPMOV[SI],AXMOVDX,203HMOVAL,10000011B;设置方式字OUTDX,ALMOVBL,1;给bl赋值,用以控制各数码管的亮暗STEP:STIHLT;等待中断信号,接到中断信号后重复该步骤JMPSTEPINTPPROCNEARPUSHAXPUSHDXCLIMOVDX,200HMOVAL,6DH;使数码管显示数字“5”OUTDX,ALMOVDX,201HMOVAL,BL;使对应bl的数码管亮,其余暗OUTDX,ALROLAL,1;循环左移一位CMPAL,01000000BJNZSTEP1;若循环到第七位,则赋值1,重新从最右端开始MOVAL,1;显示,并将al值赋给bl,避免丢失STEP1:MOVBL,ALMOVAL,20HOUT20H,AL;中断结束命令POPDXPOPAXSTIIRETINTPENDPCODEENDSENDSTART【参考实验流程图】三、实验代码1、完成指导手册要求实验十二8位A/D转换实验(中断方式)实验内容从ADC0809通道0输入+5V可变电压,使用中断方式采集数据,并将转换数据在7段数码管上以16进制数显示。实验代码如下:.Modelsmall.386DATASEGMENTLEDDB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,67H,77H,7CH,39H,5EH,79H,71HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDX,AXCLIMOVAX,00HMOVES,AXMOVDI,4*35HMOVAX,OFFSETINTPMOV[DI],AXMOVAX,SEGINTPMOV[DI+2],AXSTIINAL,21HANDAL,11011111B;开放MIR5通道OUT21H,ALSTEP:MOVDX,200HMOVAL,0;启动转化OUTDX,ALMOVCX,0;用于选择显示高位还是低位STIHLT;等待中断JMPSTEPMOVAH,4CHINT21HINTPPROCFARPUSHAXPUSHDXCLIMOVDX,201H;读数据INAL,DXMOVBL,AL;将AL数值储存在BL里ANDCX,1;取cx的最低位,若为0则显示低四位,为1则显示高四位JNZSTEP2ANDAL,00001111BMOVAH,0;屏蔽AL高4位,并将AX(数值上等于偏移量)赋给DIMOVDI,AXMOVDX,210HMOVAL,LED[DI];设置低位要显示的数字OUTDX,ALMOVDX,211HMOVAL,04H;设置显示位置OUTDX,ALDECCX;将CX减1,使CX最低位改变为1,故可使下次终端显示高4位JMPEXITSTEP2:MOVAL,BLPUSHCXMOVCL,4;将AL高4位移到低4位ROLAL,CLPOPCXANDAL,00001111H;屏蔽AL高4位MOVAH,0MOVDI,AXMOVDX,210H;设置低位要显示的数字MOVAL,LED[DI]OUTDX,ALMOVDX,211HMOVAL,08H;设置显示位置OUTDX,ALDECCX;将CX减1,使CX最低位改变为0,故可使下次终端显示低4位EXIT:MOVAL,65H;IR5中断结束OUT20H,ALPOPDXPOPAXSTIIRETINTPENDPCODEENDSENDSTART实验十五DMA读操作实验利用8237DMA的0通道实验MEMI/O的传送。将2000H:0000H~2000H:0007H共8个数据01H,02H,04H,08H,10H,20H,40H,80H通过DMA方式一次传送,并在8个led中显示对应状态。DMA请求使用单脉冲长生,led与8255的PA口连接,DMA传送时,通过8255的传输端口控制led的亮与灭。说明:8255的DMA_EN的作用是为了在DMA响应期间,使能8255,并禁止A1A0译码,使其A1A0=00,因此,DMA传送期间传送的数据会固定送往PA端口,此时的8255PA口当做8为锁存器使用。实验代码如下:.Modelsmall.386DATASEGMENTLEDDB01H,02H,04H,08H,10H,20H,40H,80HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVCX,8H;设置往内存单元赋值次数MOVAX,2000HMOVES,AX;设置要存入数值的内存起始地址为2000H:0000HMOVDI,0LEASI,LED;将变量起始地址赋给siSTEP:MOVAL,[SI]MOVES:[DI],ALINCDI;传送8个数据到2000:0000H单元INCSILOOPSTEPMOVAL,10000000BMOVDX,213H;设置8255A端口1方式输出OUTDX,ALMOVAL,00000100BMOVDX,208H;禁止82C37A工作OUTDX,ALMOVDX,20CHOUT
本文标题:微机原理与接口技术实验报告及答案
链接地址:https://www.777doc.com/doc-6222372 .html