>>Hi all! >> >>in <iomacros.h> i got these defs: >> >>#define _BIS_SR(x) __asm__ __volatile__( "bis %0, r2" : : >>"i" ((uint16_t)x) ); >>#define _BIC_SR(x) __asm__ __volatile__( "bic %0, r2" : : >>"i" ((uint16_t)x) ); >> >>#define __bis_SR_register(x) __asm__ __volatile__( "bis %0, r2" : : >>"i" ((uint16_t)x) ); >>#define __bic_SR_register(x) __asm__ __volatile__( "bic %0, r2" : : >>"i" ((uint16_t)x) ); >> >>in the post "Constraints on inline asm operands" of 2005-01-20 the >>author noted that the constraints "i" requires an immediate value >>(i.e. a constant), otherwise an error is generated. >>That's fine. So my question is: shouldn't the 3rd and 4th defs have >>the constraint "r" ? >> >>I mean, from their name I understand they were meant to operate >>register to register, weren't they? Is that a copy-and-paste mistake >>or is there a reason i can't get ? >> >>For the moment I defined my own: >> >>__my_bis_SR_register(x) __asm__ __volatile__( "bis %0, r2" : : "r" >>((uint16_t)x) ); >> >> >> >These macros exists with two different names for compatibility with >other tool chains for the MSP430. They are intended to be identical, and >I believe are correct as they stand. > >Regards, >Steve
Ok. Then I'll add another def to my own collection. I think it's quite useful to have something like: __BIS_SR_reg2reg(x) __asm__ __volatile__( "bis %0, r2" : : "r" ((uint16_t)x) ); for example i use it in routines that cannot be interrupted, this way: int_status = READ_SR & GIE; // read status register and mask GIE dint(); // ensure this routine in unninterruptible ... ...stuff... ... __BIS_SR_reg2reg(int_status) // = eint() if irqs were enabled so that the interrupt status is unaltered at the end of the routine and no test and jump is required. Roberto