LI R0,>0008
MOV @FLAGS,R1
COC R0,R1
Another, possibly simpler way to do this is to use a table of bits, and then you can reference it directly. For instance:
BITFLAGS DATA >0001,>0002,>0004,>0008
DATA >0010,>0020,>0040,>0080
DATA >0100,>0200,>0400,>0800
DATA >1000,>2000,>4000,>8000
then anywhere you need them:
COC @BITFLAGS+6,@FLAGS
(where the +6 is because you wanted bit 3). It costs you 32 bytes for the table, but you could only store the flags you actually use. The test itself is one instruction, and while it'll be slower than the TB, not by much. (Especially if you can get the table into scratchpad, though I would not do that unless you do a LOT of bit tests). Still costs 6 bytes, though. You can make it four bytes by keeping FLAGS in a dedicated register, though -- with 15 GP registers that's more possible than on some machines.
Edited by Tursi, Sat Feb 4, 2012 5:40 AM.