Hi,
I noticed the following in msp430/include/iomacros.h :
119 #define _BIS_SR(x) __asm__ __volatile__( "bis %0, r2" : : "i"
((uint16_t)x) );
120 #define _BIC_SR(x) __asm__ __volatile__( "bic %0, r2" : : "i"
((uint16_t)x) );
~~~
Problem:
--------
This very simple code snippet does compile
_BIS_SR(0xDEAD);
while this more complex one doesn't
// restore the previous state of the DCO and SMCLK flags
_BIS_SR(saved->sr.whole & (SCG0|SCG1));
and makes the angry gcc shoot
warning: asm operand 0 probably doesn't match constraints
inconsistent operand constraints in an `asm'
Explanation:
------------
The constraint on the operand is "i" (that is, immediate integer
operand). Now, if I change this constraint to "g" (that is, general),
the code does not generate a compiler error anymore.
And here is the generated code :
mov &saved, r15
mov 4(r15), r15
and #llo(192), r15
/* #APP */
bis r15, r2
As you can see, everything is fine. Hence, why is the constraint "i"
instead of "g" ? I cannot see any reason for this constraint to be "i"
only, but maybe I forgot something... What do you think ? (I don't want
to label such a behavior a bug before I'm sure it really is a bug.)
By the way, isn't the semi colon at the end of the #defines redundant ?
--
Corentin Plouet <[email protected]>