title: What is the most efficient way to set one bit of a register in ARM?
body: <p>I'm writing ARM assembly code that at some point has to set a single bit of a register to 1. This is best done of course via "register-<code>or</code>-bitmask" method. However, according to ARM documentation, the Assembly <code>ORR</code> command (bitwise OR) does <em>not</em> take immediate values. In other words you can only bitwise-OR a value in one register with a value in another register. When you think about it, it makes sense because ARM instructions are themselves 32-bit long, so there's no way to cram a 32-bit mask into an instruction. However, writing an immediate value to a register just to use it right a way is inefficient because it produces a <a href="http://en.wikipedia.org/wiki/Hazard_%28computer_architecture%29#Read_After_Write_.28RAW.29" rel="nofollow">read-after-write</a> hazard which stalls the CPU. In general, what is the most efficient way to <code>ORR</code> a register with a mask without wasting a register on constantly keeping that mask in memory? Does ARM recommend anything?</p>