您好,欢迎访问三七文档
实验四字符串的匹配与替换程序设计一、实验目的1)掌握串操作指令的使用方法。2)掌握串处理程序的设计方法。3)熟练使用各种程序结构。二、实验内容3)编写程序把从键盘输入的以回车为结束符的字符串中的空格去掉并按相反的顺序输出。4)编写程序在字符串STRING1中指定位置插入字符串STRING2。三、实验设备PC机一台四、实验步骤1)按程序流程图编制实验程序。2)输入源程序。3)汇编、连接程序,执行程序,检查结果。4)程序的执行可用DEBUG的G命令,也可用T命令单步跟踪执行。5)用D命令检查执行结果。五、程序源代码3)codesegmentassumecs:code,ss:stackstart:movah,01hmovcx,0input:int21hpushaxinccxcmpal,0dhjneinputcallnewladdsp,2deccxmovch,0movah,02houtput:popdxcmpdl,20hjeoutput_okint21houtput_ok:loopoutputmovax,4c00hint21hnewlprocpushaxpushdxmovah,02hmovdl,0ahint21hmovdl,0dhint21hpopdxpopaxretnewlendpcodeendsendstart4)DATASEGMENTDA0DB0DH,0AH,'$'DA1DB'Pleaseenterthefirststring.'DB0DH,0AH,'$'DA2DB'Pleaseenterthesecondstring.'DB0DH,0AH,'$'DA3DB'Pleaseenterthelocationinthefirststringyouwanttoinsertin.'DB0DH,0AH,'$'DA4DB50HDB?DB50HDUP('$')DA5DB50HDB?DB50HDUP('$')DA6DB10HDB?DB10HDUP('$')DATAENDSCODESEGMENTMAINPROCFARASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVAH,9MOVDX,OFFSETDA1INT21HMOVAH,0AHMOVDX,OFFSETDA4INT21HMOVAH,9MOVDX,OFFSETDA0INT21HMOVDX,OFFSETDA2INT21HMOVAH,0AHMOVDX,OFFSETDA5INT21HMOVAH,9MOVDX,OFFSETDA0INT21HMOVDX,OFFSETDA3INT21HMOVAH,0AHMOVDX,OFFSETDA6INT21HMOVDI,OFFSETDA6+2MOVCL,[DA6+1]MOVAX,0MOVBL,10NEXT6:CMPCL,0JZNEXT7MULBLADDAL,[DI]SUBAL,30HINCDIDECCLJMPNEXT6NEXT7:MOVBH,[DA4+1]MOVAH,2MOVCL,ALMOVCH,0;SETTHETIMESOFCIRCULATIONCMPCX,0JZNEXT2;IFYOUWANTTOINSERTINTOTHEBEGINNINGOFSTRING1MOVDI,OFFSETDA4+2NEXT1:MOVDL,[DI]INT21HINCDILOOPNEXT1NEXT2:MOVCL,[OFFSETDA5+1]MOVCH,0CMPCX,0JZNEXT4;IFTHESTRING2ISEMPTYMOVSI,OFFSETDA5+2NEXT3:MOVDL,[SI]CMPDL,0DHJZNEXT4INT21HINCSIJMPNEXT3NEXT4:MOVDL,[DI]CMPDL,0DHJZNEXT5INT21HINCDIJMPNEXT4NEXT5:MOVAH,4CHINT21HMAINENDPCODEENDSENDSTART六、实验结果3)4)
本文标题:汇编-实验四
链接地址:https://www.777doc.com/doc-4599514 .html