Q7
. Perform the following operations using bit masking.
(a)
Set the bits 2, 4 and 6 of the register P1OUT simultaneously
(b)
Clear the bits 2, 4 and 6 of the register P1OUT simultaneously
(c)
Toggle the bits 2, 4 and 6 of the register P1OUT simultaneously
(d)
Toggle all the bits of P1OUT simultaneously except the bits 2, 4 and 6
a.Setting a bit in kth position means making the bit in the kth position to 1 whether it is 0 or 1.
If P1OUT=11100011(i.e 227), then setting 2,4,6 bits makes it to 11101011 i.e 235
b.clearing a bit in kth popsition means making the bit in kth position to 0 whether it is 0 or 1.
If P1OUT = 11100011(i.e 227) then clearing 2,4,6 bits makes it to 11000001 i.e 193
c.Toggling a bit in kth position means making the bit in kth position to 0 if it is 1 and vice-versa.
if P1OUT = 11100011(i.e 227) toggling 2,4,6 bits makes it to 11001001 i.e 201
d.If P1OUT = 11100011(i.e 227) then toggling all bits except 2,4,6 bits means toggling 1,3,5,7,8 bits makes it to 01110110 i.e 118
Get Answers For Free
Most questions answered within 1 hours.