主题:[原创]汇编语言实现比较两个字符串的问题,大家看看
谢谢帮忙!兄弟把这个改正确,贡献出来
data segment
string1 db 81
db ?
db 81 dup(?)
string2 db 81
db ?
db 81 dup(?)
mesg1 db 'please input two strings:',0ah,0dh
db '$'
mesg2 db 'they are the same.',0ah,0dh
db '$'
mesg3 db 'they are the different',0ah,0dh
db '$'
data ends
code segment
assume cs:code,ds:code,es:code
start:mov ax,data
mov ds,ax
mov es,ax
disp1:mov dx,offset mesg1
mov ah,09h
int 21h
lf:mov dl,0dh
mov ah,02h
int 21h
input1:mov dx,offset string1
mov ah,0ah
int 21h
mov dl,0ah
mov ah,02h
int 21h
input2:mov dx,offset string2
mov ah,0ah
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov bl,string1
mov dl,string2
cmp bl,dl
jne disp3
mov cl,string1
mov ch,0h
sjy:lea si,string1
lea di,string2
cld
repe cmpsb
jnz disp3
mov dx,offset mesg2
mov ah,09h
int 21h
jmp pend
disp3:mov dx,offset mesg3
mov ah,09h
int 21h
pend:mov ah,4ch
int 21h
code ends
end start
data segment
string1 db 81
db ?
db 81 dup(?)
string2 db 81
db ?
db 81 dup(?)
mesg1 db 'please input two strings:',0ah,0dh
db '$'
mesg2 db 'they are the same.',0ah,0dh
db '$'
mesg3 db 'they are the different',0ah,0dh
db '$'
data ends
code segment
assume cs:code,ds:code,es:code
start:mov ax,data
mov ds,ax
mov es,ax
disp1:mov dx,offset mesg1
mov ah,09h
int 21h
lf:mov dl,0dh
mov ah,02h
int 21h
input1:mov dx,offset string1
mov ah,0ah
int 21h
mov dl,0ah
mov ah,02h
int 21h
input2:mov dx,offset string2
mov ah,0ah
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov bl,string1
mov dl,string2
cmp bl,dl
jne disp3
mov cl,string1
mov ch,0h
sjy:lea si,string1
lea di,string2
cld
repe cmpsb
jnz disp3
mov dx,offset mesg2
mov ah,09h
int 21h
jmp pend
disp3:mov dx,offset mesg3
mov ah,09h
int 21h
pend:mov ah,4ch
int 21h
code ends
end start