How to copy MSB to rest of the byte?
<p>In an interrupt subroutine (called every 5 µs), I need to check the MSB of a byte and copy it to the rest of the byte.</p>

<p>I need to do something like:</p>

<pre><code>if(MSB == 1){byte = 0b11111111}
else{byte = 0b00000000}
</code></pre>

<p>I need it to make it fast as it is on an interrupt subroutine, and there is some more code on it, so efficiency is calling.</p>

<p>Therefore, I don't want to use any if, switch, select, nor <code>&gt;&gt;</code> operands as I have the felling that it would slow down the process. If i'm wrong, then I'll go the "easy" way.</p>

<p>What I've tried:</p>

<pre><code>byte = byte &amp; 0b100000000
</code></pre>

<p>This gives me <code>0b10000000</code> or <code>0b00000000</code>.</p>

<p>But I need the first to be <code>0b11111111</code>.</p>

<p>I think I'm missing an OR somewhere (plus other gates). I don't know, my guts is telling me that this should be easy, but it isn't for me at this moment.</p>