Compare two strings of equal length, if they are the same, output Match!, if they are different, output No Match!

Article Directory

problem

Compare two strings of equal length, if they are the same, output Match!, if they are different, output No Match!

Code

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

operation result

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43475285/article/details/106304737