用汇编进行字符串匹配
2、试编写一程序,要求比较两个字符串 STRING1 和 STRING2 所含字符是否完全相同,若相同则显示 MATCH,若不相同则显示 NO MATCH。
.model small
.dataSTRING1 db 'hello world!',0STRING2 db 'hello china!',0matchString db 'MATCH$'nomatchString db 'NO MATCH$'
.codestart:mov ax,@datamov ds,axcall comparemov ah,4chint 21hcompare procpush axpush bxpush dxpush simov si,0comstart:mov bx,offset STRING1mov dl,[bx][si]mov bx,offset STRING2cmp dl, [bx][si]jne nomatchcmp dl, 0je matchinc sijmp comstartnomatch:mov dx,offset nomatchStringmov ah,09hint 21hjmp funcreturnmatch:mov dx,offset matchStringmov ah,09hint 21hjmp funcreturnfuncreturn:pop sipop dxpop bxpop axretcompare endpend start