title: determine parity of a bit representation of a number in MIPS
body: <p>Is there some instruction in MIPS that will determine the parity of a certain bit representation? I know to determine whether a "number" has an even parity or an odd parity is to XOR the individual bits of the binary representation together, but that seems computationally-intensive for a set of MIPS instructions... and I need to do this as quick as possible.</p>
  
  <p>Also, the number I'm working in is represented in Grey Code... just to throw that in there. So is there some pseudo-instruction in MIPS to determine the parity of a "number" or do I have to do it by hand?</p>
  
  <p>If there is no MIPS instruction, which it seems very unlikely to be, any advice on how to do it by hand?</p>
  
  <p>Thanks,
  Hristo</p>
  
  <p>follow-up: I found a optimization, but my implementation isn't working.</p>
  
  <pre><code>unsigned int v; // 32-bit word
  v ^= v &gt;&gt; 1;
  v ^= v &gt;&gt; 2;
  v = (v &amp; 0x11111111U) * 0x11111111U;
  return (v &gt;&gt; 28) &amp; 1;
  </code></pre>