I find myself using (apparently unnecessary) 'LDR' instructions because of this sort of thing all the time. And that adds up, in Cortex-M chips with kilobytes of program memory.
I find myself using (apparently unnecessary) 'LDR' instructions because of this sort of thing all the time. And that adds up, in Cortex-M chips with kilobytes of program memory.
The following classes of constant are available in Thumb-2:
•Any constant that can be produced by shifting an 8-bit value left by any number of bits.
•Any replicated halfword constant of the form 0x00XY00XY
•Any replicated halfword constant of the form 0xXY00XY00
•Any replicated byte constant of the form 0xXYXYXYXY
See page 92 here: http://hermes.wings.cs.wisc.edu/files/Thumb-2SupplementRefer...
There is also MOVT which will set the top 16 bits of a register to any 16-bit value and not affect the bottom 16bits
And there is MOVW (MOV.W) which will set the bottom 16 bits to any value and zero the top 16 bits
MOVW + MOVT allows loading any 32-bit value in 2 instructions (8 bytes)
Regarding the 00XY00XY and XY00XY00 forms: I'm going to have to sleep on this, but this is a bit of mystery to me so far. I'm going to have to keep an eye out for those sorts of constants now! Maybe they're actually quite common?? - I suppose this will certainly let you form many kinds of mask useful for SIMD operations.