3、gment;**********************************mainprocfarassumecs:program;----------------------start:movah,02hmovdl,10h;输出字符的ascll码movbl,15;定义行列let0:movcx,16let1:int21hpushdx;回车换行movah,02hmovdl,0int21hmovah,02hmovdl,0int21hpopdxincdllooplet1pushdx;回车换行movah,02hmovdl,0dhint21hmovah,0
4、2hmovdl,0ahint21hpopdxdecblcmpbl,0jnelet0jeexitexit:movah,01hint21hmovax,4ch;输出int21hmainendp;-------------------------------------programendsend;査找匹配字符串search;*************************************************DATAREASEGMENTSTRING1DB"Enterkeyword:$";建立输出语句STRING2DB"Entersentence
5、:$"STRING3DB"Matchatlocation:$"STRING4DB"Nomatch!",13,10,"$"STRING5DB"Hofthesentence.$"keywordDB50D,?,51DDUP(?)sentenceDB50D,?,51DDUP(?)DATAREAENDS;*********************CODESEGMENTMAINPROCFARASSUMECS:CODE,DS:DATAREA,ES:DATAREA;_------------------------------START:PUSHDSSUBAX,AX
6、PUSHAXMOVAX,DATAREAMOVDS,AXMOVES,AXLEADX,STRING1;显示STRING1MOVAH,09HINT21HLEADX,keywordMOVAH,0AHINT21HMOVAH,02HMOVDL,0AHINT21HLEADX,STRING2;显示STRING1MOVAH,09HINT21HLEADX,sentenceMOVAH,0AHINT21HMOVAH,02HMOVDL,0AHINT21HLEASI,keyword+2;关键词LEADI,sentence+2MOVAX,0MOVAL,[sentence+1];句
7、子字符个数MOVAH,[keyword+1];关键词字符个数CMPAL,AHJLNOSUBAL,AHMOVAH,0MOVCX,AXINCCXCOMPARE:PUSHCXMOVCX,3;采用movax,字符个数,使字符的个数不固定CLDREPZCMPSBJZMATCHMOVAX,3;采用movax,字符个数SUBAX,CXSUBSI,AX;关键词回到词首MOVAX,2;采用movax,字符个数-1SUBAX,CXSUBDI,AXPOPCX;将堆栈段中的一个字单元弹出LOOPCOMPARENO:LEADX,STRING4MOVAH,09HINT21HJM
8、PEXITMATCH:POPCXMOVBX,DILEADX,STRING3MOVAH,09HINT21HSU