#byte PORTA = 5
main()
{
int i;
// Todos los bits son salidas
set_tris_a(0x00);
// Ponemos todos los bits a cero
PORTA = 0;
// Parte alta salida, parte baja entrada
set_tris_a(0x0F);
// Leemos el puerto en una variable
i = PORTA;
// Si esta seteado el primer bit seteamos el ultimo
if(PORTA & 1)
PORTA |= 0x80;
// Si esta seteado el segundo bit invertimos el anteultimo
if(PORTA & 2)
PORTA ^= 0x40;
// Si esta seteado el tercer bit limpiamos el antepenultimo
if(PORTA & 4)
PORTA &= ~0x20;
}