C does not really have any bit operations, which is a
nuisance if the target microprocessor has bit
manipulation instructions. To set or clear a bit in a
byte the programmer may choose to go with the portable
C code or drop down into non-portable assembler. Eg.
const char bitOfInterestMask = 0x01;
/* set the bit */
abyte |= bitOfInterestMask;
/* clear the bit */
abyte &= ~bitOfInterestMask;
I noticed on the HC08 port that the set operation is
efficiently optimised to the bset instruction but the
clear operation isn't optimised to the bclr instruction.
Log in to post a comment.