汇编实验2

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

姓名班级学号:实验二循环与子程序程序设计一、实验目的1)加深对循环结构的理解。2)掌握循环程序的设计方法。3)学习子程序的定义和调用方法。4)掌握子程序、子程序的嵌套、递归子程序的结构。5)掌握子程序设计、编制及调试。6)熟练掌握DEBUG的常用命令,学会用DEBUG调试程序。二、实验内容1)编制程序计算S=1+2·3+3·4+4·5+……+N(N+1)+……直到N(N+1)大于200为止,并将结果由屏幕上显示出来。2)将从3000H内存单元开始的100个字节存储单元全部清0。3)编制在屏幕上显示九九乘法表的程序。4)编制在屏幕上显示用*组成的三角形的程序。5)设有五个字数据存放在以BUF为首地址的内存单元中,要求采用调用多个字数据相加的子程序方法编程,和的低位字放在RESULT单元,和的高位字放在RESULT+2单元,并将结果显示在屏幕上。6)编写一个递归子程序,计算指数函数Xn的值,其中X,n从键盘输入。三、实验设备PC机一台四、实验步骤1)按程序流程图编制实验程序。2)输入源程序。3)汇编、连接程序,执行程序,检查结果。姓名班级学号:4)对内存单元3000H开始的100个存储单元用E命令输入任意数。5)程序的执行可用DEBUG的G命令,也可用T命令单步跟踪执行。6)用D命令检查执行结果。五、实验报告的要求1)列出源程序。2)对程序中用到的寄存器说明其功能。3)总结计数控制循环程序的设计方法。4)说明怎样使用DEBUG进行程序调试的。调试过程中所遇到的问题是如何解决的。实验2-1源程序:DATASEGMENTBUFDB'1+2*3+3*4+4*5+...+N(N+1)=$'DATAENDSSTACK1SEGMENTPARASTACKDW20HDUP(0)STACK1ENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACK1,ES:DATASTART:MOVAX,DATAMOVDS,AX姓名班级学号:MOVDX,01HMOVBX,01HL1:INCBXMOVAX,BXINCAXMULBL;(进行乘法运算,bl作为乘数)ADDDX,AX;(DX作为累加变量)CMPAX,200;N(N+1)是否大于200JBEL1MOVBX,DXLEADX,BUFMOVAH,09HINT21H;输出字符串MOVCX,4LOP:MOVAX,4MOVDX,BXMULCLSUBAX,4MOVAH,ALMOVAL,CLMOVCL,AH;SHRDX,CL;cl作为移位位数寄存器ANDDX,0FHCMPDX,0AH姓名班级学号:JBEL2ADDDX,7HL2:ADDDX,30HMOVCL,AL;MOVAH,02HINT21HLOOPLOP;输出数据MOVAH,4CHINT21HCODEENDSENDSTART运行结果:实验2-2源程序:stack1segmentparastackdw20hdup(0)stack1endscodesegmentassumecs:code,ss:stack1start:movax,300hmovds,ax姓名班级学号:movcx,100;cx作为循环变量lop:movbx,cx;bx作为地址偏移moval,0h;al为0,目的是清零mov-1[bx],allooplopmovah,4chint21hcodeendsendstart运行结果:实验2-3源程序:datasegmentBUFDB09H,09Hdataendsstack1segmentparastackdw20hdup(0)stack1ends姓名班级学号:CODESEGMENTassumecs:code,ds:data,ss:stack1,es:dataSTART:MOVAX,DATAMOVDS,AXANDCX,0000HMOVCL,09H;;cl作为循环变量L1:MOVBUF,CLMOVCL,09HL2:MOVBUF+1,CLMOVAL,10SUBAL,BUFMOVDL,ALORDL,30HMOVAH,02HINT21HMOVDL,'*'MOVAH,02HINT21HMOVBL,10SUBBL,BUF+1MOVDL,BLORDL,30H姓名班级学号:MOVAH,02HINT21HMOVDL,'='INT21H;会运行一段小程序,使AX的值改变ANDAX,0000HMOVAL,10SUBAL,BUFMOVDL,ALMULBLMOVBL,10DIVBLMOVDL,ALMOVDH,AHORDL,30HMOVAH,02HINT21HMOVDL,DHORDL,30HMOVAH,02HINT21HMOVDL,''INT21HMOVCL,BUF+1LOOPL2姓名班级学号:MOVDL,0AHINT21HMOVCL,BUFLOOPL1MOVAH,4CHINT21HCODEENDSENDSTART运行结果:实验2-4源程序:datasegmentMDB20HLSDB00HLPDB00Hdataendsstack1segmentparastackdw20hdup(0)姓名班级学号:stack1endsCODESEGMENTassumecs:code,ds:data,ss:stack1,es:dataSTART:MOVAX,DATAMOVDS,AXMOVAL,03HMOVAH,00HINT10HMOVCX,5L1:MOVLP,CLMOVBX,6HSUBBX,CXMOVLS,BLMOVBH,00HMOVDH,LSMOVAL,MANDAH,00HSUBAL,LSMOVDL,ALMOVAH,02HINT10HMOVAL,LS姓名班级学号:ANDAH,00HMOVBX,2MOVAL,LSMULBLSUBAL,1MOVLS,ALMOVAH,9HMOVAL,'*'MOVBH,0MOVBL,0DHMOVCL,LSANDCH,00HINT10HMOVCL,LPANDCH,00HLOOPL1MOVAH,4CHINT21HCODEENDSENDSTART运行结果:姓名班级学号:实验2-5源程序:STACKSEGMENTSTACKDW100HDUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,SS:STACKSTART:MOVAH,01HINT21HANDBX,0000HSUBAL,30HMOVBL,ALMOVAH,01HINT21HSUBAL,30HANDCX,0000HMOVCL,ALMOVAX,01H姓名班级学号:ANDDX,0000HCALLMPUSHAXMOVBX,DXCALLSHOWPOPAXMOVBX,AXCALLSHOWMOVAH,4CHINT21HMPROCSUBCX,1HJBELCALLML:PUSHDXMULBXMOVCX,AXPOPAXPUSHDXMULBXPOPDXADDDX,AXMOVAX,CXRET姓名班级学号:MENDPSHOWPROCMOVCX,4L2:PUSHCXMOVCL,4ROLBX,CLMOVDL,BLANDDL,0FHCMPDL,0AHJBL3ADDDL,07HL3:ADDDL,30HMOVAH,02HINT21HPOPCXLOOPL2RETSHOWENDPCODEENDSENDSTART运行结果:实验2-6源程序:姓名班级学号:STACKSEGMENTSTACKDW100HDUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,SS:STACKSTART:MOVAH,01HINT21HANDBX,0000HSUBAL,30HMOVBL,ALMOVAH,01HINT21HSUBAL,30HANDCX,0000HMOVCL,ALMOVAX,01HANDDX,0000HCALLMPUSHAXMOVBX,DXCALLSHOWPOPAXMOVBX,AX姓名班级学号:CALLSHOWMOVAH,4CHINT21HMPROCSUBCX,1HJBELCALLML:PUSHDXMULBXMOVCX,AXPOPAXPUSHDXMULBXPOPDXADDDX,AXMOVAX,CXRETMENDPSHOWPROCMOVCX,4L2:PUSHCXMOVCL,4ROLBX,CLMOVDL,BL姓名班级学号:ANDDL,0FHCMPDL,0AHJBL3ADDDL,07HL3:ADDDL,30HMOVAH,02HINT21HPOPCXLOOPL2RETSHOWENDPCODEENDSENDSTART运行结果:

1 / 16
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功