PIC16F877A not working with 4MHz oscillator
I suspect that you are not turn off the ADC.
I mean when this MCU starts the ADCON1 register set to 00h. And bits PCFG3:PCFG0 are also 0000b. Thus, according the table on the pg.130 of the datasheet all  pins in the port0 are analog inputs. This table tell us that we need set bits PCFG3:PCFG0 on 011Xb to use the port0 as digital input-output.
Try to add
ADCON1 = 6;

before
TRISA = 0;