This is the winner:
Code:
portb = (portb & %00011111 ) | ( ( i rev  3 ) << 5 )
	portc = (portc & %10111111 ) | ( i.3 << 6 )
I've tried both in MPLAB SIM but
Code:
	portc = (portc & %10111111 ) | ( i << 3 )
doesn't mask the port right.

THANK YOU. Problem solved