(and this may not be supported on the 877?)
Just for completeness, it appears the TRIS assembly command works on the 16F877 for PORTS A,B, and C, but not PORTS D or E.

Thr following works but gives warning "Use of this instruction is not recommended"

Code:
ASM
    movlw   0x07
    TRIS   PORTA
ENDASM
and this
Code:
ASM
    movlw   0x07
    TRIS   PORTD
ENDASM
gives errors.