問題
同じ長さの2つの文字列を比較し、同じ場合は「Match!」を出力し、異なる場合は「NoMatch!」を出力します。
コード
data segment
str1 db 'ASDFGHJKL';字符串str1
str2 db 'ASDFGHJKL';字符串str2
len dw $-str2
output1 db 'Match!$'
output2 db 'No Match!$'
crlf db 01h,0dh,'$';回车换行
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov cx,len
mov si,0
mov di,0
L1:
mov bl,str1[si]
mov bh,str2[di]
cmp bl,bh
jnz L2
inc si
inc di
loop L1
jmp L3
L2:
lea dx,output2
mov ah,09h
int 21h
jmp L4
L3:
lea dx,output1
mov ah,09h
int 21h
lea dx,crlf
mov ah,09h
int 21h
L4:
mov ax,4c00h
int 21h
main endp
code ends
end start