port masking and ports in pic
If you want to get a byte with RB3, RB4 and RB5 in the lower 3 bits (i.e. RB5 is the LSB), do this:

unsigned char uByte = ((RB3 &lt;&lt; 2) | (RB4 &lt;&lt; 1) | RB5);


Then do your compression, so assuming the lower two bits of uByte need to go to RA3 and RA4 (i.e. RA4 is the LSB), and set the PORTA bits like this:

RA3 = ((uByte &gt;&gt; 1) &amp; 0x1);
RA4 = (uByte &amp; 0x1);