您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 其它行业文档 > 汇编语言程序设计实验报告
学生实验报告册2011——2012学年第1学期实验名称:汇编语言程序设计学院:信息与电气工程学院班级:09级计算机科学与技术2班学号:13514031姓名:于志佳指导教师:徐静实验一DEBUG的使用实验目的:(1)熟悉在计算机上建立、汇编、调试和运行汇编语言程序的过程(2)通过实验熟悉DEBUG程序的使用方法,掌握DEBUG命令实验题目1:编程计算表达式:V-(W-(X+7)*Y+Z)/X,其中X,Y,Z,W单元中,计算上面表达式,并把运算结果存入V存储单元中。(1)在DEBUG下运行、调试该程序。(2)用DEBUG中的E命令修改内存单元内容。(3)用DEBUG中的A命令修改指令。(4)用DEBUG中的D命令显示运算表达式的结果。源代码:datasegmentxdw0001hydw0002hzdw0010hwdw0020hvdw2DUP(?)dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovax,xaddax,7imulymovcx,axmovbx,dxmovax,wcwdsubax,cxsbbdx,bxmovcx,axmovbx,dxmovax,zcwdaddax,cxadcdx,bxidivxmovv,axmovv+2,dxmovah,4chint21hcodeendsendstart运行结果:实验题目2:编写程序,把从键盘上输入的小写字母转换成大写字母显示出来(1)用DEBUG的G、T命令执行指令源程序:codesegmentassumecs:codestart:movah,01hint21hmovbl,alcmpbl,'a'jbstartcmpbl,'z'jastartsubbl,20hmovdl,blmovah,02hint21hmovah,4chint21hcodeendsendstart运行结果:实验二顺序结构程序设计实验目的:(1)学习数据传送指令和算术运算指令的用法(2)熟练掌握DEBUG的使用方法实验题目1:从键盘上接收两个一位十六进制数据,求其和,并以十进制形式显示出来。源代码:codesegmentassumecs:codestart:movcx,02h;loop循环次数movbl,00hinput:movah,01hint21hsubal,30h;数字cmpal,0ahjlnextsubal,07h;大写字母cmpal,10hjlnextsubal,20h;小写字母next:addbl,al;把两数之和放在bh中loopinput;转化为十进制数moval,blcbwcmpal,0ahjggreatermovdl,aladddl,30hjmpout1greater:movcl,0ahidivclmovcl,06himulcladdbl,al;十进制显示moval,blmovcl,04hshral,clandal,0fhjzjumpmovdl,aladddl,30hmovah,02hint21hjump:andbl,0fhmovdl,bladddl,30hout1:movah,02hint21hmovah,4chint21hcodeendsendstart运行结果:实验2:求表达式Y=A*X*X-B*X+C,已知A、B、C、D分别放在DATAA、DATAB、DATAC和DATAX字节单元中,求得的结果存入DATAY字单元中。要求:(1)在DEBUG下多次修改X值,观察执行结果。(2)从键盘上输入X值,并以十六进制形式显示结果。源代码:datasegmentdataadb2databdb3datacdb1dataxdb2dataydw?dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axagain:moval,dataximulalmovcx,axmoval,dataacbwimulcxmovcx,axmovbx,dxmoval,databimuldataxsubcx,axsbbbx,0addcl,datacadcch,0movdatay,cxcmpdatay,0ahjaenext1movdl,byteptrdatayadddl,30hmovah,02hint21hjmpout1next1:movbx,dataymovch,blmovcl,4shrbl,clandbl,0fhmovdl,bladddl,30hmovah,02hint21hmoval,chandal,0fhmovdl,aladddl,30hmovah,02hint21hout1:movah,4chint21hcodeendsendstart运行结果:实验三简单分支结构程序设计实验目的:(1)掌握条件转移指令和无条件转移指令的使用方法(2)掌握指令对标志寄存器中各标志位的影响情况(3)掌握标志位和转移指令之间的关系实验1:从键盘上接收三个一位十进制数,选出其中大于平均值的数据显示出来。源代码:codesegmentassumecs:codestart:movah,01hint21hsubal,30hmovbl,almovah,01hint21hsubal,30hmovbh,almovah,01hint21hsubal,30hmovcl,almovch,0addch,bladdch,bhaddch,clmoval,chmovah,0cbwmovdh,03hidivdhmovdh,alcmpbl,aljnanext1movdl,bladddl,30hmovah,02hint21hnext1:moval,dhcmpbh,aljnanext2movdl,bhadddl,30hmovah,02hint21hnext2:moval,dhcmpcl,aljnaout1movdl,cladddl,30hmovah,02hint21hout1:movah,4chint21hcodeendsendstart运行结果:实验2:已知DATA单元开始存放三个带符号数,判断三个数是否为同号,若同时为正,显示“+”号,同时为负,显示“—”,否则显示“”。源代码:datasegmentdata1db4,5,6dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovsi,0again:rcldata1[si],1jncnext1incsircldata1[si],1jncnext2incsircldata1[si],1jncnext2movdl,'-'jmpout1next1:incsircldata1[si],1jcnext2incsircldata1[si],1jncnext3next2:movdl,''jmpout1next3:movdl,'+'out1:movah,02hint21hmovah,4chint21hcodeendsendstart运行结果:实验四多分支结构程序设计实验目的:(1)掌握多分支结构程序设计的方法(2)掌握无条件转移指令JMP的目标地址的表示形式及使用方法实验题目1:有一函数:已知DATAX存储单元存放一个带符号字节数据X,根据X的值求出y的值,并把y的值存放在DATAY单元中。x(x<1)y=2x+9(1<=x<=10)3x-11(x>=10)源代码:datasegmentdataxdb?dataydb?dataendscodesegmentassumecs:code,ds:datastart:movax,datamovds,axmovbl,dataxcmpbl,01hjlnext1cmpbl,0ahjlnext2moval,blmovch,03himulchsubal,0bhmovwordptr[datay],axmovdl,byteptr[datay]movah,02hint21hmovdl,byteptr[datay+1]jmpout1next1:movdatay,blmovdl,datayjmpout1next2:moval,blshlal,1addal,09hmovdatay,almovdl,datayout1:movah,02hint21hmovah,4chint21hcodeendsendstart运行结果:实验五循环结构程序设计实验目的:(1)掌握循环程序的结构及执行过程(2)掌握数据串操作指令和循环控制指令的功能(3)掌握循环程序的设计方法与调试方法实验1:编写程序,要求比较两个字符串string1和string2所含字符是否相同,若相同,则显示“MATCH”,若不相同则显示“NOMATCH”。实验代码:datasegmentstring1db'dfghasd'string2db'dfghasd'countequoffsetstring2-offsetstring1message1db'no_match$'message2db'match$'dataendscodesegmentassumecs:code,ds:data,es:datastart:movax,datamovds,axmoves,axmovcl,countmovsi,offsetstring1movdi,offsetstring2again:moval,byteptr[si]cmpal,byteptr[di]jnznext1incsiincdiloopagainmovdx,offsetmessage2jmpout1next1:movdx,offsetmessage1out1:movah,09hint21hmovah,4chint21hcodeendsendstart运行结果:实验2:从键盘上输入一系列字符以$结束,统计其中字母,数字及其他字符的个数,并显示出这三类的计数结果。源代码:codesegmentassumecs:codestart:movbh,0movbl,bhmovch,bhinput:movah,01hint21hcmpal,'$'jzagaincmpal,'a'jbnext1cmpal,'z'janext2incbhjmpagainnext1:cmpal,'A'jbnext3cmpal,'Z'janext2incbhjmpagainnext3:cmpal,'0'jbnext2cmpal,'9'janext2incbljmpagainnext2:incchagain:loopnzinputmovdl,''movah,02hint21hmoval,bh;输出数字个数cbwmovcl,0ahidivclmovdh,ahmovdl,aladddl,30hmovah,02hint21hmovdl,dhadddl,30hint21hmovdl,''movah,02hint21hmoval,bl;输出字母个数cbwmovcl,0ahidivclmovdh,ahmovdl,aladddl,30hmovah,02hint21hmovdl,dhadddl,30hint21hmovdl,''movah,02hint21hmoval,ch;输出其它字符个数cbwmovcl,0ahidivclmovdh,ahmovdl,aladddl,30hmovah,02hint21hmovdl,dhadddl,30hint21hmovah,4chint21hcodeendsendstart运行结果:
本文标题:汇编语言程序设计实验报告
链接地址:https://www.777doc.com/doc-5801954 .html