资源描述:
《微机原理与接口技术实验报告及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、微机实验答案实验三统计学生成绩设有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,73s5db0s6db0s7db0s8db0s9db0s
2、10db0dataendscodesegmentassumecs: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]jmpexitst
3、ep4:inc[s8]jmpexitstep5:inc[s9]exit:incsilooplop1moval,s6;显示s6,可用s5,s7,s8等替换(实验要求之思考题三)addal,48movdl,almovah,02int21hmovah,4chint21h实验四查找字符实验内容试编写一个有主程序和子程序结构的程序模块。主程序:要求从键盘接收一串字符并存于字节数组TABLE中,显示字符CHAR出现的次数。子程序:在以TABLE为首地址的字节数组中查找CHAR,统计出现的次数。实验代码如下:datasegmenttabledb100dup('$
4、')str1db'pleaseenterastringwhichislessthan100andendwithenterbutton:$'str2db'timesthatcharappearis:$'ndw?dataendsstacksegmentstack'stack'db100dup('$')stackendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axleadx,str1movah,9int21h;输出str1callfunc1;回车,换行movsi,0movcx,100lo
5、p1:movah,1int21hcmpal,0dhjzexitmovtable[si],alincsilooplop1;从键盘输入exit:movn,sicallfunc2;计算'char'出现的次数callfunc1;回车,换行leadx,str2movah,9int21h;输出str2callfunc1;回车,换行moval,bladdal,30hmovdl,almovah,2int21h;输出'bx'movah,4chint21hfunc1procnearpushdxpushaxmovdl,0ahmovah,2int21hmovdl,0dhm
6、ovah,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'jnzexit2incb
7、xexit1:incsiexit2:cmpsi,axloopnzlop2popaxpopcxpopsiretfunc2endpcodeendsendstart实验六定时计数器实验实验代码如下:.modelsmall.386codesegmentassumecs:codestart:movax,datamovds,axmovdx,203hmoval,00110110boutdx,almovdx,200hmovax,0h;0h减1后得到FFH,从而满足题目要求outdx,almoval,ahoutdx,al;movdx,203hmoval,011101
8、10boutdx,almovdx,201hmovax,fhoutdx,almoval,ahoutdx,almovah,4c