This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Avoiding macro using 32 bits shift warning

Hi,

I use below macro
#define SFRX(Sfr,Msk) (Sfr=((Sfr & (~ ((Msk)>>8)) ) |(Msk)))
to simply both Set and Reset specified bits in some register.

If I write SFRX ( MyReg , 0x0100 ) this macro clears bit 0.
If I write SFRX ( MyReg , 0x0002 ) this macro set bit 1.
If I write SFRX ( MyReg , 0x0102 ) this macro clears bit 0 and sets bit 1 in one go whithout affecting other bits.

Now I would like to use this macro for a 32-bits system:
#define SREG(Reg,Msk) (Sfr=((Sfr & (~ ((Msk)>>32)) ) |(Msk)))

Although the compiler warns that shifting is too long it works fine.
(main.c(56): warning: #63-D: shift count is too large)

My question is: how do I prevent this warning to occur?

Thanks

Henk

0