编写一个程序,要求比较两个字符串string1和string2所含字符是否相同,若相同则显示”match!”,若不相同则显示”no match!”.
已有数据段:
datarea SEGMENT ;define data segment
string1 DB 'move the cursor backward.'
N1=$-string1
string2 DB 'move the cursor backward.'
N2=$-string2
mess1 DB 13,10, 'match.',13,10,'$'
mess2 DB 13,10, 'no match!',13,10,'$'
datarea ENDS
程序如下:
datarea SEGMENT
string1 DB 'move the cursor backward.'
N1=$-string1
string2 DB 'move the cursor backward.'
N2=$-string2
mess1 DB 13,10, 'match.',13,10,'$'
mess2 DB 13,10, 'no match!',13,10,'$'
datarea ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:datarea
START:
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,datarea
MOV DS,AX
MOV ES,AX
LEA SI,string1
LEA DI,string2
CLD
MOV CX,25
REPE CMPSb
JNE NOMATCH
MATCH:
LEA DX,mess1
MOV AH,09H
INT 21H
JMP STOP
NOMATCH:
LEA DX,mess2
MOV AH,09H
INT 21H
JMP STOP
STOP:
MOV AH,4CH
INT 21H
CSEG ENDS
END START