title: Compare two words
body: <p>How to compare two words in NASM assembly? consider this code:</p>
  
  <pre><code>global start
  start:
      mov eax,array
      mov edx,4
      mov ecx,2987074
  .LOOP1:
      cmp word [eax],ecx
      je .FOUND
      add eax,4
      sub edx,1
      jz .NOTFOUND
      jmp .LOOP1
  .FOUND:
      xor ebx,ebx
      jmp .EXIT
  .NOTFOUND:
      mov ebx,1
  .EXIT:
      mov eax,1
      int 0x80
  
  array:  
      dd 1137620
      dd 3529469
      dd 2987074
      dd 1111111
      dd 2222222
  </code></pre>
  
  <p>returns </p>
  
  <blockquote>
    <p>foo.asm:7: error: mismatch in operand sizes</p>
  </blockquote>
  
  <p>and changing cmp from <code>cmp word [eax],ecx</code> to <code>cmp word [eax],word ecx</code></p>
  
  <p>returns:</p>
  
  <pre><code>foo.asm:7: warning: register size specification ignored
  foo.asm:7: error: mismatch in operand sizes
  </code></pre>
  
  <p>I have no idea how to fix this. Can someone explain it?</p>