Operators
Operators
X &= ~(1<<2);
1. RESET 1 bit
nd
Make a 2 Bit 0 in variable x
X|=(1<<5);
2.SET 1 BIT
th
Make a 5 bit 1 in variable X
while(X&(1<<7) ==1);
3. Monitor a Bit
Monitor for 7th bit to go low
X^=(1<<6);
4.INVERTING BITS
th
Invert 6 bit in X
X>>4;
5.EXTRACTING BITS
th
Extracting 4-6 bit and load it to y Y= (X>>4) &(0x07);
6.INSERTING BITS
X&= ~(1<<2) &~(1<<3);
6.a) reset 2nd and 3rd bit in x
nd
rd
X|=(1<<2)|(1<<3);
6.b) Set 2 and 3 bit in X
-make 4th-7th bit
6.c) Inserting bit fields 1010
X&= ~ (0xF0);
from 4th-7th bit
-make 4th-7th bit -1010
X|=(0xA<<4);