汇编初学者 请教一个关于字符串比较的问题 cmpsb
我用记事本写了个汇编程序,为什么跟我想要的结果不一样,求各位大神帮帮忙。。。。
程序代码:data segment
MAXLEN db 22
ACTLEN db ?
STRING1 db 20 dup(?)
STRING2 db 20 dup(?)
mess1 db 'please input the frist string:','$'
mess2 db 'please input the second string:','$'
mess3 db 'MATCH!',13,10,'$'
mess4 db 'NOT MATCH!',13,10,'$'
data ends
code segment
main proc far
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
;input the frist string
mov ah,9
mov dx,seg mess1
mov ds,dx
mov dx,offset mess1
int 21h
lea dx,MAXLEN
mov ah,0ah
int 21h
;input the second string
mov ah,9
mov dx,seg mess2
mov ds,dx
mov dx,offset mess2
int 21h
lea dx,MAXLEN
mov ah,0ah
int 21h
lea si,STRING1
lea di,STRING2
cld
mov cx,20
repe cmpsb
jnz next
mov ah,9
mov dx,seg mess2
mov ds,dx
mov dx,offset mess3
jmp exit
next:
mov ah,9
mov dx,seg mess4
mov ds,dx
mov dx,offset mess4
exit:
ret
main endp
code ends
end start









