How to get the low 16-bit half-word most efficiently on ARM (ARM7TDMI)?
<p>Say we have a 32-bit value in a register: r0 = 0x12345678; The task is to get the low half-word part, which is 0x5678 (or alternatively nullify the high half-word).
In terms of C code that's equivalent to: <code>r0 = r0 &amp; 0xFFFF;</code></p>

<p>Limitations: it needs to be done in a single ARM7TDMI instruction without using other registers. This is motivated by the fact that getting the high half is just a right shift like <code>LSR r0, r0, #16</code>.</p>

<p>So far I can do it either in 2 instructions: left shift + right shift, rotate + shift; or by using an additional register containing a mask 0xFFFF and AND-ing.</p>

<p>On ARM7TDMI it's not possible to just AND with a constant like 0xFFFF, because it doesn't fit into the immediate value scheme.</p>

<p>In addition it looks like that modern ARM-s have "MOVT" which solves it by doing <code>MOVT r0, #0</code>, but ARM7TDMI doesn't have it!</p>

<p>I want to believe that it's possible without MOVT, because it's such a basic thing.</p>