资源描述:
《计算机学院汇编实验.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实验四字符串的匹配与替换程序设计3)编写程序把从键盘输入的以回车为结束符的字符串中的空格去掉并按相反的顺序输出。datasegmentstrdb20,22dup(?),'$'msgdb'Pleaseinputyoustr:',0ah,0dh,'$'dataendsstacksegmentdb20dup(?)stackendscodesegmentassumecs:code,ds:data,ss:stackstart:movax,datamovds,axmovdx,offsetmsgmovah,09hint21hmovdx,offsetstr;输入字符串movah,0
2、ahint21hmovdl,0ah;回车换行movah,02hint21hmovdl,0dhint21hmovdi,offsetstrmovch,0movcl,[di+1]adddi,cxincdilop:movdl,[di]cmpdl,''jenextmovah,02hint21hnext:decdilooplopmovah,4chint21hcodeendsendstart4)编写程序在字符串STRING1中指定位置插入字符串STRING2。DSEGSEGMENTSTR1DB'1234658236'N1EQU$-STR1STR2DB'4567355'N2EQU$
3、-STR2STRDBN1+N2DUP(?),'$'DSEGENDSCODESEGMENTASSUMECS:CODE,DS:DSEGBEGIN:MOVAX,DSEGMOVDS,AXLEASI,STR1LEADI,STR2LEABX,STRMOVCX,N1NEXT1:MOVAL,[SI]MOV[BX],ALINCSIINCBXLOOPNEXT1MOVCX,N2NEXT2:MOVAL,[DI]MOV[BX],ALINCDIINCBXLOOPNEXT2LEADX,STRMOVAH,9INT21HMOVAH,4CHINT21HCODEENDSENDBEGIN