<p>In ARM assembly immediates are encoded by an 8-bit rotated value which means we can only encode </p>

<pre><code>(0-256)^2n.
</code></pre>

<p>Now my problem is that I want to clear the upper 16-bits of r0 and replace it with the half-word stored r1. But because of the limited range of the immediates I have to do: -</p>

<pre><code>bic r0, r0, #0xff000000
bic r0, r0, #0x00ff0000
add r0, r0, r1, LSL #16
</code></pre>

<p>Is it possible to do replace the 2 bic instructions with a single instruction? 0xffff0000 is unencodable. Perhaps I should be using another logical operation to clear the upper 16-bits?</p>

<p>Thanks</p>

<p>EDIT: Sorry I forgot to say that the top 16-bits of r1 is empty, and I'm using an ARM7TDMI</p>

If you can clear the whole thing, you could
```
xor
```
it with itself.
If you need to retain the bottom half, might you be able to left-shift the register 8 bits and back? That may be same number of instructions, though.