Ist das noch aktuell? http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_intpromote : Why *does* the *compiler* compile *an* 8-bit *operation* that uses *bitwise* operators *into* a *16-bit* operation *in* *assembly?* Bitwise operations in Standard C will automatically promote their operands to an int, which is (by default) 16 bits in avr-gcc. To work around this use typecasts on the operands, including literals, to declare that the values are to be 8 bit operands. This may be especially important when clearing a bit:
1 | var &= ~mask; /* wrong way! */ |
The bitwise "not" operator (~) will also promote the value in mask to an int. To keep it an 8-bit value, typecast before the "not" operator:
1 | var &= (unsigned char)~mask;" |