title: C Bitwise Operation according to truth table
body: <p>My program has register of 8 bit namely <code>PC0,PC1,PC2,PC3,PC4,PC5,PC6,PC7.</code></p>
  
  <p>I don't care about <code>PC0,PC1,PC2,PC3.</code>
  I want to set the bits according to truth table as mentioned :</p>
  
  <pre><code>             PC4    PC5   PC6 (Ports)
  Row1 :        0      0     0         
  Row2 :        0      0     1      
  Row3 :        0      1     0      
  Row4 :        0      1     1    
  Row5 :        1      0     0     
  Row6 :        1      0     1     
  </code></pre>
  
  <p>The PC7 state should not be changed while setting the bit and should be untouched. I can set the bits individually, but need to set them at once.
  Here is what I have done:</p>
  
  <pre><code>void Set(unsigned char Row)
  {
    if(Row == 1)
    {
     PC_ODR &amp;= ~(0x40) //To Set 0 to PC6
     PC_ODR &amp;= ~(0x20) //To Set 0 to PC5
     PC_ODR &amp;= ~(0x10) //To Set 0 to PC4
    }
  
    if(Row == 2) 
    {
     PC_ODR |= 0x40   //To Set 1 the PC6
     PC_ODR &amp;= ~(0x20) //To Set 0 to PC5
     PC_ODR &amp;= ~(0x10) //To Set 0 to PC4
    }
  
   // ......So on for Row 3, 4,5,6
  }
  </code></pre>
  
  <p>For all the 6 rows, the code will become lengthy, is there any way I can use shift operator and AND / OR operator to get things done in short.</p>