比较两个等长的字符串,若相同,则输出Match!,若不同,则输出No Match!

文章目录

问题

比较两个等长的字符串,若相同,则输出Match!,若不同,则输出No Match!

代码

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

运行结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43475285/article/details/106304737