About the only thing that can interfere with PORTD on an 877, is the Parallel Slave Port (PSP).

Occasionaly people will set TRISE = %11111111 thinking it sets PORTE to all INPUT. But it actually turns on PSP mode on PORTD, because Microchip used the extra bits in TRISE for something other than TRIS.
<br>