title: Operand Size Conflict in x86 Assembly
body: <p>I've just started programming in Assembly for my computer organization course, and I keep getting an <code>operand size conflict</code> error whenever I try to compile this <code>asm</code> block within a C program.</p>
  
  <p>The <code>arrayOfLetters[]</code> object is a char array, so shouldn't each element be one byte?  The code works when I do <code>mov eax, arrayOfLetters[1]</code>, but I'm not sure why that works, as the <code>eax</code> register is 4 bytes.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define SIZE 3
  
  char findMinLetter( char arrayOfLetters[], int arraySize )
  {
      char min;
  
      __asm{
          push eax
          push ebx
          push ecx
          push edx
          mov dl, 0x7f        // initialize DL
  
          mov al, arrayOfLetters[1] //Problem occurs here
  
          mov min, dl        // read DL
          pop edx
          pop ecx
          pop ebx
          pop eax
      }
  
      return min;
  }
  
  int main()
  {
      char arrayOfLetters[ SIZE ] = {'a','B','c'};
  
      int i;
  
      printf("\nThe original array of letters is:\n\n");
      for(i=0; i&lt;SIZE; i++){
          printf("%c ", arrayOfLetters[i]);
      }
      printf("\n\n");
  
      printf("The smallest (potentially capitalized) letter is: %c\n", findMinLetter( arrayOfLetters, SIZE ));
  
      return 0;
  }
  </code></pre>