Wherever possible, HI-TECH C will attempt to use the PIC10/12/16 bit instructions. For
example, when using a bitwise operator and a mask to alter a bit within an integral type,
the compiler will check the mask value to determine if a bit instruction can achieve the
same functionality.
unsigned int foo;
foo |= 0x40;
will produce the instruction:
BSF _foo,6
To set or clear individual bits within integral type, the following macros could be used:
#define bitset(var, bitno) ((var) |= 1UL << (bitno))
#define bitclr(var, bitno) ((var) &= ~(1UL << (bitno)))
To perform the same operation as above, the bitset macro could be employed as follows:
bitset(foo,6);