title: Comparing strings in Assembly
body: <p>So, I'm fairly new to assemlby. My task is to check for a substring in a string and print out yes/no answer. Both strings are put in by the user.</p>
  
  <p>I have put offset of the string into bx register, offset of the substring into bp register. Using index numbers in di and si registers, I want to compare characters of my strings. Both of my index registers are set to 2, which should be the first character of the string.</p>
  
  <pre><code>mov dl,[bx+di]
  mov al,[bp+si]
  cmp dl,al
  jz AnswerYes
  jmp AnswerNo
  </code></pre>
  
  <p>I used this to compare first characters in each string.</p>
  
  <p>When I put 'a' in both string, the program should jump to AnswerYes and print out 'yes'. When I print [bx+di] and [bp+si], it prints out 'a' for both of them, which means they are the same, but the program always jumps to AnswerNo. </p>
  
  <p>If I do this:</p>
  
  <pre><code>cmp dl,'a'
  </code></pre>
  
  <p>it prints our yes, meaning they are the same.</p>
  
  <p>When I do this:</p>
  
  <pre><code>cmp al,'a'
  </code></pre>
  
  <p>it prints out no, even though they are the same.</p>
  
  <p>I suspect the problem is with me using bp register, since I've never used it before. I always used only one string in my program, for which I always used bx register.</p>
  
  <p>Thanks for help in advance.</p>