|
HI-TECH PICC-18 compiler 73
4.2.6 Bit Instructions
Wherever possible, PICC-18 will attempt to use the PIC18 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.
int foo;
foo |= 0x40;
Features and Runtime Environment
will produce the instruction
bsf _foo,6
To set or clear individual bits within integral types, the following macros could be defined and used.
#define bitset(var, bitno) ((var) |= 1 << (bitno))
#define bitclr(var, bitno) ((var) &= ~(1 << (bitno)))
To perform the same operation as the above example, the bitset macro could be employed as follows.
bitset(foo, 6);
E-mail: info@telesys.ru