《汇编语言实验二查找匹配字符串.docx》由会员分享,可在线阅读,更多相关《汇编语言实验二查找匹配字符串.docx(3页珍藏版)》请在第一文库网上搜索。
1、汇编语言实验二查找匹配字符串一、目的查找匹配字符串SEARCH二、实验内容程序接收用户键入的一个关键字以及一个句子。如果句子中不包含关键字则显示NOmatch!,;如果句子中包含关键字则显示MATCH,且把该字在句子中的位置用十六进制数显示出来。流程图mess3DBMatchat1ocationmess4DBNOTMATCH.,13,10;$mess5DBHifthesentence,13,10,$changeDB13,10;$stoknin11abe1bytema1db10act1db?stokn1db10dup(?)stokni21abe1bytema2db50act2db?stokn2d
2、b50dup(?)DATAENDSSTACKSSEGMENT;此处龄人依垓殁代喝STACKSENDSCODESEGMENTmainprocfarassumecs:code,ds:data,es:dataSTART:pushdssubAX,AXsubB,BXsubDI,D1subSI,SpushAX;为魅dosM情玄后而更用到的高存器MOVAX1DATAMOVDS,A1EADX,mess1MOVah,09INT21h瀚出Enterkeyword1EADX,stoknin1MOVah,Oah;用21-中做的Oah备功就疑取美ti专INT21hcmpact1,0jeexit果石玄石拽i出程序a10:
3、;*-*输入SentenCe在村所1EAD,changeMOVah,09INT21h;输出B福,整村1EADX,mess2MOVah,09INT21h僚出EnterSentence:1EADX,stoknin2MOVah,OahINT21h;用21孑中罐的Oah号功荏嶷取句孑MOVA1,act1CBWMOVCX,A;作存关缠字AiOcxPUSHCX;CX入垓MOVA1,act2cmpA1,0jea50;缶仔旬孑长度到a1,若与孑石学酎跳同笈3notmatchSUBA1,act1jsa50;若旬孑长庭J孑关继专长盛,的跣超醒3notmatchINCA1CBW1EABX,stokn2;将劭孑的芍牯
4、加蒙世BXMOVDI1OMOVSI1Oa20:,*的彳$MMOVAH,BX+DICMPAH,stokn1SI;遇见与在彳柳善跳转i)a30jnea30INCD1INCS1DECCX;:2遇到一个加第的学名,cx-1,cx不处0弼晓露下一个学Q,由CX为O聂镯明弟维学砧的克CMPC,Ojea40jmpa20a30:1*外捶林,BX+1,情度si,di0G的踊林叨较INCBXDECA1CmPA1,Ojea50MOVDI1OMOVSI1OPOPCXpushCXjmpa20a40:1*match,瞪bx湍总旬孑的蓄处经加一得到关键与的在住,褊用二出副片十六色制孑曲祗仍色萎觞出SUBBX,offsets
5、tok2INCBX1EADX1ChangeMOVah,09INT21h1EADX,mess3MOVah,09INT21hCA11btoh1EADX,mess5MOVah,09INT21hjmpa10.mnmnmm*“遭村第十二世断JbtohPROCNEARMOVCH,4rotate:MOVC1,4RO1BX,C1MOVA1,B1andA1,OfhaddA1,30hcmpa1,3ahj1printitadda1,7hprintit:MOVd1,a1MOVah,2int21hdecchjnzrotateretbtohendpa50:.*星3match1EADX,changeMOVah,09INT21h1EADX,mess4MOVah,09INT21hjmpa10exit:retmainendpCODEENDSENDSTART四、运行结果及分析音E:J1SOFTIasBbinDTTeBp.exeEnterkeyword:abbEnterSentence45454abbNatchatIocation:0006HifthesentenceEnterSentencexfdfeaaabbNatcbatIocation:0007HifthesentenceEnterSentencezkC五、实验小结六、附录(选)