您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 汇编上机实验报告心得体会
汇编语言程序设计第一次上机作业1.从键盘上接受一个字符,找出他的前导字符和后继字符,按顺序显示这三个字符。寄存器分配:AL:存输入值xDL:输出显示流程图:如右图所示DATASEGMENTADB0DATAENDSSTACKSEGMENTSTACKDB200DUP(0)STACKENDSCODESEGMENTASSUMEDS:DATA,SS:STACK,CS:CODES:MOVAX,DATAMOVDS,AXMOVAH,1INT21HINCALMOVDL,ALMOVAH,2INT21HDECALMOVDL,ALMOVAH,2INT21HDECALMOVDL,ALMOVAH,2INT21HCODEENDSENDS开始输入→AX(AL)+1→ALAL→DL显示(AL)-1→ALAL→DL显示(AL)-1→ALAL→DL显示结束2.从键盘上输入一个数字字符,如不是,显示‘notodd’,否则显示‘odd’。寄存器分配:AL:存输入值xDL:输出显示流程图:如右图所示程序代码如下:DATASEGMENTADB0BUFDB,'NOTODD$'EADB,'ODD$'DATAENDSSTACKSEGMENTSTACKDB200DUP(0)STACKENDSYCODESEGMENTASSUMEDS:DATA,SS:STACK,CS:CODES:MOVAX,DATANMOVDS,AXMOVAH,1INT21HYCMPAL,'0'JNGEBCMPAL,'9'JGEBLEADX,EAMOVAH,9INT21HJMPCB:LEADX,BUFMOVAH,9INT21HC:MOVAH,4CHINT21HCODEENDSENDS开始输入→ALAL0显示notodd结束AL9显示odd第二次上机作业1.将以H为首地址的字节存储区中的技能被3整除又能被13整除的无符号整数的个数(假定=9)显示出来;同时对应的显示它们分别对应的地址偏移量。(利用多种寻址方式做)DATASEGMENT寄存器分配:SI:存H的偏移地址HDW1,3,5,39,13,117,15,17,$CX:计数N=$-HDX:存余数BDW3BX:循环计数CDW13DDW0DATAENDSSTACKSEGMENTSTACKDB200DUP(0)STACKENDSCODESEGMENTASSUMECS:CODE,SS:STACK,DS:DATABEGIN:MOVAX,DATANMOVDS,AXMOVCX,0YMOVBX,NLEASI,HNLOPA:MOVAX,SIDIVBMOVD,DXYJNZNEXTDIVCMOVD,DXJNZNEXTMOVDL,[SI]MOVAH,2INT21HINCCXINCSIDECDXJNZLOPANNEXT:INCSIDECDXJNZLOPAYEXIT:MOVDL,CLMOVAH,2INT21HMOVAH,4CHINT21H开始H偏移→SIN→BX0→CX(SI)→AX(AX)mod3=00(AX)mod13=0[SI]→DL显示(SI)+1CX+1DX-1=0CX显示结束CODEENDSENDBEGIN2.在以TAB为首地址的字存储区中存放有n个无符号数,统计低三位全为一的数的个数。寄存器分配:SI:TAB的偏移地址AX:存[SI]DX:计个数CX:循环计数STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTTABDW'1,9,10,20,30,40'N=($-TAB)/2DATAENDSCODESEGMENTASSUMECS:CODE,SS:STACK,DS:DATABEGIN:MOVAX,DATAMOVDS,AXMOVDX,0MOVCX,NMOVBX,7HLEASI,TABLOPA:MOVAX,SIANDAX,BXNCMPAX,BXJNEEXITINCDXYINCSIDECCXJNZLOPANEXT:INCSIDECCXJNZLOPAEXIT:MOVDL,DLMOVAH,2INT21HMOVAH,4CHINT21HCODEENDSNEMDBEGIN开始TAB首地址→SI7H→BX;0→DLN→CX(SI)→AX(AX)AND(BX)→AXAX=BXDL+1→DL(SI)+1→SI(CX)-1→CXCX=0显示DL结束(SI)+13.键盘接受一串字符到BUF为首地址的字节单元中,要求用下列方法分别编程,将它们以相反的次序显示在屏幕的下一行中:(1).按地址从尾向前依次显示。STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTBUFDB20DB?DB20DUP(0)BUF1DB20DUP(0)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKBEGIN:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,10INT21HMOVCL,BUF+1MOVCH,0LEADI,BUF1P1:LEASI,BUF+2ADDSI,CXDECSIMOVAL,[SI]MOVBYTEPTR[DI],ALINCDIMOVDL,ALMOVAH,2INT21HLOOPP1NEXT:MOVAH,4CHINT21HCODEENDSENDBEGIN(2).利用堆栈反向显示。STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTBUFDB20DB?DB20DUP(0)DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKBEGIN:MOVAX,DATAMOVDS,AXLEADX,BUFMOVAH,10INT21HMOVCL,BUF+1MOVCH,0LEASI,BUF+2P1:MOVAL,[SI]MOVAH,0PUSHAXINCSILOOPP1P2:POPBXMOVDL,BLMOVAH,2INT21HMOVCL,BUF+1MOVCH,0LOOPP2NEXT:MOVAH,4CHINT21HCODEENDSENDBEGIN(3).利用交换的方法反序后,然后显示:即ai——ajSTACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTBUFDB'asfdcvb'N=$-BUFBDW?ADB2DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKBEGIN:MOVAX,DATAMOVDS,AXLEASI,BUFLEADI,BUFMOVCX,NDECCXMOVB,CXINCCXADDDI,BMOVAX,CXDIVALOAP:MOVBL,[DI]MOVDL,[SI]XCHGBL,DLMOV[SI],DLMOV[DI],BLINCSIDECDIDECALJNZLOAPP2:LEASI,BUFMOVDH,[SI]MOVDL,DHMOVAH,2INT21HINCSILOOPP2NEXT:MOVAH,4CHINT21HCODEENDSENDBEGIN第三次上机作业1.在以BUF1和BUF2为首地址的两个字存储区中,分别存放有10个不相等的无符号数。依次找出同时在这两个存储区中出现的数,将他们放在以BUF3为首地址的存储区中。寄存器分配:SI:BUF1偏移地址DI:BUF2偏移地址BP:BUF3偏移地址CX,DX:循环计数STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTBUF1DW1,3,7,15,20,18,14,17,19,21BUF2DW4,6,8,17,20,25,27,18,3,16BUF3DW10DUP(?)DATAENDSCODESEGMENTASSUMECS:CODE,SS:STACK,DS:DATABEGIN:MOVAX,DATAMOVDS,AXLEASI,BUFIYLEADI,BUF2LEABP,BUF3MOVCX,10NMOVDX,10LOPA:MOVAX,[SI]MOVBX,[DI]CMPAX,BXYJEBDECDXNJZCADDDI,2JMPLOPAB:MOV(BP),AXADDBP,2DECDXJZJZCADDDIJMPLOPAJNZC:LEADI,BUF2INCSIMOVDX,10DECCXJZDJMPLOPAJNZD:MOVAH,4CHINT21HDATAENDSENDBEGINJZBUF1EA→SIBUF2EA→DIBUF2EA→BP10→CX;10→BX开始(SI)→AX(DI)→BXAX=BXDX-1AX→(BP)(BP)+2DX-1(DI)+2BUF2EA→DI(SI)+1;10→DXCX-1结束DX=0(DI)+22.键盘接受一串字符到以TAB为首地址的字节存储区中,利用向前移动的方法,删除数字字符,然后在屏幕的下一行,显示删除后的字符串。寄存器分配:CX:计数控制循环SI:TAB首地址AL:存(SI)STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTTABDB100DUP(0)DATAENDSCODESEGMENTASSUMECS:CODE;SS:STACK;DS:DATABEGIN:LEASI,TABMOVCX,10LOPA1:MOVAH,1INT21HJNZMOV[SI],ALMOVDL,ALJZMOVAH,2INT21HDECCXJNZLOPA1MOVDL,0AHMOVAH,2YINT21HMOVSI,0NMOVCX,10YLOPA2:MOVAL,[SI]NCMPAL,’0’JLACMPAL,’9’JGAMOVBL,SILOPA3:INCSIJNZMOV[SI],[SI+1]DECCXJZJNZLOPA3MOVSI,BLJMPLOPA2A:MOVDL,ALMOVAH,2JNZINT21HDECCXJZJNZLOPA2MOVAH,4CH开始TABEA→SI;10→CX输入→SI[SI]→ALAL→DL显示CX-1换行;10→CX;TABEA→SI[SI]→ALAL0AL9SI→BLSI+1CX-1BL→SIAL→DL显示CX-1结束SI+1SI+1INT21HCODEENDSENDBEGIN4.从键盘上接受若干个字符,以^Z结束,将其写到C:ABC.ASM文件中保存,然后显示在屏幕上。要求有提示信息。STACKSEGMENTSTACKDB200DUP(0)STACKENDSDATASEGMENTCEDB’CREATEERROR!’,0AH,0DH,’$’WEDB’WRITEERROR!’,0AH,0DH,’$’PIDB’PLEASEINPUT:’,0AH,0DH,’$’F_NAMEDB’C:AB.ASM’,0BUFDB32767DUP(?)F_NUMDW?DATAENDSCODESEGMENTASSUMESS:STACK;DS:DATA;CS:CODEBEGIN:MOVAX,DATAMOVDS,AXMOVAH,3CHMOVCX,0LEADX,F_NAMENYINT21HJNCCLEADX,CENMOVAH,9INT21HYJMPEXITNC:MOVF_NUME,AXLEADX,PIMOVAH,9INT21HLEADI,BUFYINPUT:MOVAH,1INT21HMOV[DI],ALINCDIMOVDL,[DI]MOVAH,2INT21HCMPAL,0DH开始创建文件成功失败提示输入输入;BUFEA→DI;DI+1输入=^Z输入为回车?换行;DI+1停止输入,写入文件夹显示关闭文件结束提示错误JEENDINCMPAL,0DHJNEINPUTMOVDL,0AHMOV[DI],DLINCDIMOVAH,2INT21HJMPINPUTENDINPUT:MOVAH,40HMOVBX,F_NUMLEADX,BUFSUBDI,DXMOVCX,DIINT21HJCED:MOVAH,3EHINT21HEXIT:MOVAH,4CHINT21HE:LEADX,WEMOVA
本文标题:汇编上机实验报告心得体会
链接地址:https://www.777doc.com/doc-2368307 .html