I'm using an ARMv7 processor with Thumb-2 instructions.
I have executed an ADD
, SUB
or a CMP
. Now I want to move the condition flag LE
to r2
. After this, r2
should contain either 0
or 1
.
I've been looking through the Thumb-2 manual, but I haven't found a conditional MOV instruction or a special instruction to read the flags.
What's the most efficient way to do this? Thanks in advance!
You need to start a conditional block with an ite
(if-then-else) instruction and then just use conditional assignments:
ite le @ if-then-else (le)
movle r2, #1 @ if (le) then r2 = #1
movgt r2, #0 @ else r2 = #0
In general, you can use arbitrary conditional instructions in Thumb-2 if you prefix them with appropriate IT-instructions. Read the manual for details.