title: Base64 Assembler Fill Array Error "Operands different sizes" Visual Studio
body: <p>Im trying to make a Base64Encode in inline assembler in Visual Studio.</p>
  
  <p>I got this func</p>
  
  <pre><code>char* Base64Encode(char* data, int len)
  {
  // Tabelle mit den Zeichen für die Codierung
  const char* encodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  //
  char* result;   
  
  
  if (len &gt; 0)            // sonst gibt es nichts zu tun ...
  {
      int encodedLength   = ((len + 2) / 3) * 4;      // effektiv die Ganzzahlfassung von ceil(length/3)*4
      result = new char[encodedLength+1];             // +1 wg. Null-Terminierung
      _asm
      {           
          mov esi,data
          mov edi,encodeTable
  
          xor eax, eax
          // get 3 bytes
          mov ah, byte ptr[esi]
          mov al, byte ptr[esi+1]
          shl eax,16
          mov ah, byte ptr[esi+2]
  
          //
          mov edx,eax
          shl eax,6
  
          shr edx, 26
          mov bl, byte ptr[edi + edx]    
          mov [result],bl
  
          //
          mov edx, eax
          shl eax, 6                                    
  
          shr edx, 26
          mov bl, byte ptr[edi + edx]            
          mov[result+1], bl
  
          //manipulate in edx bitset3
          mov edx, eax
          shl eax, 6
  
          shr edx, 26
          mov bl, byte ptr[edi + edx]
          mov[result+2], bl
  
          //manipulate in edx bitset4
          mov edx, eax
          shl eax, 6
  
          shr edx, 26
          mov bl, byte ptr[edi + edx]
          mov[result+3], bl
  
  
      }
  }
  else
  {
      result = "";
  }
  return result;
  }
  </code></pre>
  
  <p>The encoding is working proper, I have in bl always the right letter, but the output is not working ( result array doesn't fill with the letters, im getting the error that the operands have different sizes, I am only allowed to make changes in the __asm function ) .</p>
  
  <p>Could somebody help me how to fill the result-array with the letters I get in bl? Debugging always shows me the right letters in the bl ' s if i comment out all the result lines.</p>
  
  <p>EDIT:
  <a href="https://i.stack.imgur.com/qllTi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qllTi.png" alt="enter image description here"></a></p>
  
  <p>I  get nothing in the result array when i use the byte ptr.</p>
  
  <p>Any ideas?</p>
  
  <p>EDIT2:</p>
  
  <p><a href="https://i.stack.imgur.com/gBOWk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gBOWk.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/fSZqo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fSZqo.png" alt="enter image description here"></a></p>