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-or-bitmask” method. However, according to ARM documentation, the Assembly ORR command (bitwise OR) does not 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 read-after-write hazard which stalls the CPU. In general, what is the most efficient way to ORR a register with a mask without wasting a register on constantly keeping that mask in memory? Does ARM recommend anything?
I’m writing ARM assembly code that at some point has to set a single
Share
is perfectly fine in standard ARM. You can encode immediate values in a 32-bit ARM instruction, but their range is limited. See this explanation.
Your link points to the Thumb documentation; are you sure you need to be using Thumb instructions?