0% found this document useful (0 votes)
620 views

Operators

1) The document performs bitwise operations on a variable X to reset, set, monitor, invert, extract, and insert bits. 2) It resets the 2nd bit, sets the 5th bit, monitors the 7th bit, inverts the 6th bit, and extracts bits 4-6 into variable Y. 3) It also resets the 2nd and 3rd bits, sets them again, and inserts the bit field 1010 into bits 4-7 of X.

Uploaded by

Ani Vin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
620 views

Operators

1) The document performs bitwise operations on a variable X to reset, set, monitor, invert, extract, and insert bits. 2) It resets the 2nd bit, sets the 5th bit, monitors the 7th bit, inverts the 6th bit, and extracts bits 4-6 into variable Y. 3) It also resets the 2nd and 3rd bits, sets them again, and inserts the bit field 1010 into bits 4-7 of X.

Uploaded by

Ani Vin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Let X=0x0F;

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);

You might also like