First, the manual refers to BIS_SR() etc. but the names
actually begin with an underscore (e.g. _BIS_SR()).

Second, the manual gives a prototype of

  void BIS_SR(const uint16_t x);

But the following won't compile:

  void sleep(const int16_t x)
  {
    _BIS_SR(x);
  }

The definition uses an "i" constraint for the input value, so x
must be a literal constant. A "const int16_t" value won't work.

However, if you change the definition from

  #define _BIS_SR(x) __asm__ __volatile__( "bis %0, r2" : : "i" ((uint16_t)x) )

to

  #define _BIS_SR(x) __asm__ __volatile__( "bis %0, r2" : : "ir" ((uint16_t)x) )

Then "const int16_t" is correct and the above example code
compiles correctly.  Using "ir" as the constraint appears to
generate optimal code in all cases.

The same fix should probably be made to all of the related
macros that set/clear bits.

I think.

Or is there a reason I can't see why those input constraints
are "i" instead of "ir"?

-- 
Grant Edwards                   grante             Yow!  I'm a fuschia bowling
                                  at               ball somewhere in Brittany
                               visi.com            


Reply via email to