title: How to compare two strings assembly
body: <p>Could anyone tell me how to compare two strings in assembly language, I`ve written the followign, but it does not seem to work.</p>
  
  <pre><code>assume cs:code, ds:data
  
  data segment
  sirlung db "abcdjjj"
  lungimelung equ $-sirlung
  sirscurt db "aby"
  lungimescurt equ $-sirscurt
  exista db "Exista!$"
  nuexista db "NU exista!$"
  iesire db "Apasa enter pentru iesire!$"
  
  
  data ends
  
  code segment
  start:
  mov ax,data
  mov ds,ax
  
  mov bx,offset sirlung
  mov di,offset sirscurt
  dec bx
  push bx
  push di
  mov dx,lungimelung
  mov si,lungimescurt
  bucla1:
      pop di
      pop bx
      inc bx
      mov al,sirlung[bx]
      mov cl,sirscurt[di]
  
      cmp al,cl
      jne bucla1
      push bx
      push di
      je bucla2
      cmp bx,dx
      ja sfarsit_nu_exista
  bucla2:
      inc bx
      inc di
      mov al,sirlung[bx]
      mov cl,sirscurt[di]
      cmp al,cl
      jne bucla1      
      cmp di,si
      jl sfarsit_exista
      jae bucla2
  
  
  
  
  
  sfarsit_exista:
  mov dx,offset exista
  mov ah,09h
  int 21h
  mov ah, 0ah
  mov dx,offset iesire
  int 21h
  mov ax,4c00h
  int 21h
  
  sfarsit_nu_exista:
  mov dx,offset nuexista
  mov ah,09h
  int 21h
  mov ah, 0ah
  mov dx,offset iesire
  int 21h
  mov ax,4c00h
  int 21h
  
  code ends
  end start
  </code></pre>