# Thread: PCA0MD &= ~0x40; Need some help cyphering

1. ## PCA0MD &= ~0x40; Need some help cyphering

so PCAOMD is a register on a micro processor. so usually they have an 8 bit register that you can turn a function on or off by binary code so if it was just PCA0MD = 0x40 that would be 01000000 so the seventh bit would be on, which in the actual case would not be correct the 7th bit needs to be off and i think some of the other bits on, so

&= is bitwise AND ? what does ~ mean? could you explain and show the results.

2. From Bitwise operations in C - Wikipedia

Bitwise NOT ~ [ones' complement (unary)]
Tim S.

3. Useful macros:
Code:
```#define BITSET(v,b) { (v) |= (1U << (b)); }
#define BITRESET(v,b) { (v) &= ~(1U << (b)); }
#define BITINVERT(v,b) { (v) ^= (1U << (b)); }

/* Example: */
BITRESET( PCA0MD, 6 );  // reset bit 6 (the 7th bit).
BITSET( PCA0MD, 0 ); // set bit 0 (the 1st bit).```

4. so the first part & is a bitwise of 0x40 01000000 so would the first operand 0x40 be bitwised with the second operand of zeros? that would result in all zeros, then it would be bitwise not? the result would be all 1"s ?

EDIT i see that now UNARY( one operand) so i am looking at this again

5. so would it be a bitwise AND 1's complement then NOT?

6. No, it would be bitwise not of 0x40, then bitwise and with that result. The ~0x40 will almost certainly be computed at compile time rather than run time.