汇编实验报告(河北工业大学)

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

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

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

资源描述

实验一顺序与分支程序设计一、实验目的1)掌握顺序程序设计方法。2)掌握分支程序的结构及分支程序的设计,调试方法。2)学习数据传送及算术和逻辑运算指令的用法。3)熟悉在PC机上建立、汇编、连接、调试和运行汇编语言程序的过程。二、实验内容1)有一字变量BUF1是以原码表示的有符号数,要求将其转换为反码和补码,分别存入BUF2和BUF3单元,并在屏幕上显示出来。源代码:DATASEGMENTBUF1DW9348HBUF2DW4DUP(0),0AH,0DH,'$'BUF3DW4DUP(0),'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATABEGIN:MOVAX,DATAMOVDS,AXMOVAX,BUF1ADDAX,0JSNEXTMOVBUF2,AXMOVBUF3,AXJMPEEENEXT:ANDAX,7FFFHNOTAXMOVBUF2,AXINCAXMOVBUF3,AXEEE:MOVCX,0004HMOVDI,OFFSETBUF2MOVDX,[DI]ADDDI,03BBB:MOVAX,DXANDAX,000FHCMPAL,0AHJBQQQADDAL,07HQQQ:ADDAL,30HMOV[DI],ALDECDIPUSHCXMOVCL,04HSHRDX,CLPOPCXLOOPBBBMOVCX,0004HMOVSI,OFFSETBUF3MOVDX,[SI]ADDSI,03HCCC:MOVAX,DXANDAX,000FHCMPAL,0AHJBDDDADDAL,07HDDD:ADDAL,30HMOV[SI],ALDECSIPUSHCXMOVCL,04HSHRDX,CLPOPCXLOOPCCCMOVDX,OFFSETBUF2MOVAH,09HINT21HMOVDX,OFFSETBUF3MOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDBEGIN运行结果:2)有两个两字节无符号数分别放在存储单元A、B起始的缓冲器中,求其和,结果放在A起始的缓冲区并在屏幕上显示。相加若有进位不存入存储单元。源代码:DATASEGMENTADB34H,18H,2DUP(0),'$'BDB56H,83HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAL,AMOVBL,BADDAL,BLMOVAH,A+1MOVBH,B+1ADCAH,BHMOVA,ALMOVA+1,AHMOVCX,0004HMOVDI,OFFSETAMOVDX,[DI]ADDDI,03NEXT:MOVAX,DXANDAX,000FHCMPAL,0AHJBQQQADDAL,07HQQQ:ADDAL,30HMOV[DI],ALDECDIPUSHCXMOVCL,04SHRDX,CLPOPCXLOOPNEXTMOVDX,OFFSETAMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTART运行结果:3)在BUF和BUF+1、BUF+2单元分别放有一个无符号字节型数,编程序将其中最大数存入MAX单元,并在屏幕上显示。源代码:STACKSEGMENTSTACKDB1024DUP(0)STACKENDSDATASEGMENTBUFDB70H,35H,1FHMAXDB2DUP(?),'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKBEGIN:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,BUF+1JNBLP1MOVAL,BUF+1LP1:CMPAL,BUF+2JAELP2MOVAL,BUF+2LP2:MOVCX,02HMOVDI,OFFSETMAXMOVDL,ALINCDILP3:ANDAL,0FHCMPAL,0AHJBLP4ADDAL,07HLP4:ADDAL,30HMOV[DI],ALDECDIPUSHCXMOVCL,04SHRDL,CLPOPCXMOVAL,DLLOOPLP3MOVDX,OFFSETMAXMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDBEGIN运行结果:4)要求同上,只是比较的数为有符号数。源代码:STACKSEGMENTSTACKDB1024DUP(0)STACKENDSDATASEGMENTBUFDB98H,75H,32HMAXDB2DUP(?),'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKBEGIN:MOVAX,DATAMOVDS,AXMOVAL,BUFCMPAL,BUF+1JGLP1XCHGAL,BUF+1LP1:CMPAL,BUF+2JGLP2XCHGAL,BUF+2LP2:MOVMAX,ALMOVCX,02HMOVDI,OFFSETMAXMOVDL,[DI]INCDILP3:MOVAL,DLANDAL,0FHCMPAL,0AHJBLP4ADDAL,07HLP4:ADDAL,30HMOV[DI],ALDECDIPUSHCXMOVCL,04SHRDX,CLPOPCXLOOPLP3MOVDX,OFFSETMAXMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDBEGIN运行结果:6)从键盘上接收一位十进制数X,计算Y值,并以十六进制形式显示出来,Y按下列公式计算。)6(2/)5()4(2)3(2222XXXXXXXXXXY源代码:DATASEGMENTXDB?YDB?DATAENDSSTACKSEGMENTSTACKDW20HDUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXl0:MOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HMOVAH,1INT21HSUBAL,30HMOVX,ALCMPX,3JZl1CMPX,4JZl2CMPX,5JZl3CMPX,6JZl4CMPX,0JZl6JMPl0l1:MOVAL,XMULXADDAL,XMOVY,ALJMPl5l2:MOVAL,XMULXSUBAL,XSUBAL,XMOVY,ALJMPl5l3:MOVAL,XMULXMOVY,ALJMPl5l4:MOVAL,XMULXMOVBL,2DIVBLMOVY,ALl5:MOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HMOVDL,YMOVCL,4SHRDL,CLCMPDL,9JLEl7ADDDL,7l7:ADDDL,30HMOVAH,2INT21HMOVDL,YANDDL,0FHCMPDL,9JLEl8ADDDL,7l8:ADDDL,30HMOVAH,2INT21HJMPl0l6:MOVAH,4CHINT21HCODEENDSENDSTART运行结果:7)从键盘上接收两个一位十六进制数X和Y,然后再输入一个A-D之间的一个字符,按下列要求计算。源代码:DATASSEGMENTXDB?YDB?ZDB?SDB?DATASENDSCODESSEGMENTASSUMECS:CODES,DS:DATASSTART:MOVAX,DATASMOVDS,AXL0:MOVAH,1INT21HSUBAL,30HMOVX,ALMOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HMOVAH,1INT21HSUBAL,30HMOVY,ALMOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HMOVAH,1INT21HMOVZ,ALCMPZ,'A'JZL1CMPZ,'B'JZL2CMPZ,'C'JZL3CMPZ,'D'JZL4CMPZ,'Q'JZL7L1:MOVAL,XADDAL,YMOVS,ALJMPL6L2:MOVAL,XSUBAL,YMOVS,ALCMPS,0JSL5JNSL6L3:MOVAL,XMULYMOVS,ALJMPL6L4:MOVAL,XMOVBL,YMOVAH,0DIVBLMOVS,ALJMPL6L5:NEGSJMPL6L6:MOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HMOVDL,SL9:ADDDL,30HMOVAH,2INT21HMOVDL,0AHMOVAH,2INT21HMOVDL,0DHINT21HJMPL0L7:MOVAH,4CHINT21HCODESENDSENDSTART运行结果:实验二循环与子程序程序设计一、实验目的1)加深对循环结构的理解。2)掌握循环程序的设计方法。3)学习子程序的定义和调用方法。4)掌握子程序、子程序的嵌套、递归子程序的结构。5)掌握子程序设计、编制及调试。6)熟练掌握DEBUG的常用命令,学会用DEBUG调试程序。二、实验内容1)编制程序计算S=1+2·3+3·4+4·5+……+N(N+1)+……直到N(N+1)大于200为止,并将结果由屏幕上显示出来。源代码:DATASEGMENTBUFDB'S=1+2*3+3*4+4*5+…+N(N+1)+…=','$'RESDW4DUP(0),'$'DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,OFFSETBUFMOVAH,09HINT21HMOVDX,1MOVBL,2NEXT:MOVAL,BLINCBLMULBLADDDX,AXCMPAX,200JNANEXTMOVCX,0004HMOVDI,OFFSETRESADDDI,03HNEXT1:MOVAX,DXANDAX,000FHCMPAL,0AHJBNEXT2ADDAL,07NEXT2:ADDAL,30HMOV[DI],ALDECDIPUSHCXMOVCL,04SHRDX,CLPOPCXLOOPNEXT1MOVDX,OFFSETRESMOVAH,09HINT21HMOVAH,4CHINT21HCODEENDSENDSTART运行结果:2)将从3000H内存单元开始的100个字节存储单元全部清0。源代码:DATASEGMENTORG3000HXDB100DUP(?)DATAENDSSTACKSEGMENTSTACKDB10DUP(?)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKSTART:MOVAX,DATAMOVDS,AXLEASI,XMOVCX,100LP:ANDBYTEPTR[SI],00HINCSILOOPLPMOVAH,4CHINT21HCODEENDSENDSTART运行结果:3)编制在屏幕上显示九九乘法表的程序。源代码:DATASEGMENTXDB1YDB1ZDB1SDB?YSDB?TENDB10DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AX;装入段寄存器L1:MOVAL,XMULYMOVZ,ALCALLSCINCYMOVBL,XCMPY,BLJAL2JMPL1;内循环L2:INCXCMPX,9HJAL3MOVY,1MOVDL,0AHMOVAH,02HINT21HMOVDL,0DHMOVAH,02HINT21H;输出回车换行JMPL1;外循环L3:MOVAH,4CHINT21HSCPROC;输出子程序ADDY,30HMOVDL,YMOVAH,02HINT21H;输出YMOVDL,'X'MOVAH,02HINT21H;输出XADDX,30HMOVDL,XMOVAH,02HINT21H;输出XMOVDL,'='MOVAH,02HINT21H;输出=MOVAX,0MOVAL,ZDIVTENMOVS,ALMOVYS,AHcmps,1jbl10ADDS,30HMOVDL,SMOVAH,2INT21H;输出高位

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

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

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

×
保存成功