title: Assembly mask logic question
body: <p>This is very simple, but I haven't been able to figure it out yet.</p>
  
  <p>This question is regarding a assembly mmx, but it's pure logic.</p>
  
  <p>Imagine the following scenario:</p>
  
  <pre><code>MM0: 04 03 02 01 04 03 02 01  &lt;-- input  
  MM1: 02 02 02 02 02 02 02 02  
  MM2: 04 03 02 01 04 03 02 01  &lt;-- copy of input
  
  after pcmpgtw MM0, MM1
  
  MM0: FF FF 00 00 FF FF 00 00  &lt;-- words where MM0 is greater than MM1 (comparing words)  
  MM1: 02 02 02 02 02 02 02 02  
  MM2: 04 03 02 01 04 03 02 01
  
  after pand MM0, MM2  
  
  MM0: 04 03 00 00 04 03 00 00  &lt;-- almost there...
  MM1: 02 02 02 02 02 02 02 02  
  MM2: 04 03 02 01 04 03 02 01  
  </code></pre>
  
  <p>What I want is to know fill the zeros of MM0 with 02. I suppose I would have to invert MM0 register in step2, changing the FF's to 00's and the 00's to FF's and then do a and to MM1 and finally a or to merge the two.</p>
  
  <p>If I was able to get:</p>
  
  <pre><code>MM3: 00 00 FF FF 00 00 FF FF
  
  then, pand MM2, MM3
  
  MM1: 04 03 00 00 04 03 00 00  
  MM2: 00 00 02 02 00 00 02 02
  
  finally por MM0, MM1 would give me the desired outcome:
  
  MM0: 04 03 02 02 04 03 02 02  &lt;-- Aha!
  </code></pre>
  
  <p>Summing up, how can I get that MM3 register as 00 00 FF FF 00 00 FF ? How can I invert the bits, proving I only have AND, OR, XOR and NAND instructions available in MMX registers?</p>
  
  <p>Any answer is greatly appreciated. Thanks.</p>