1. You first need to set the TRIS register for a port. Having TRISA = %00000000 makes all pins output. From right to left they are arranged as porta.0 to porta.7. (F877 has 6 pins on PORTA). If you want to make one of them an input, say you need PORTA.1 as input, then you state TRISA = %00000010. Now, all of them are outputs except for PORTA.1 (also for some PICs, you need to watch for MCLR pin which is an input-only pin).
OR, you can just say INPUT PORTA.1

2. You should keep all registers at the beginning. No need to put them into each subroutine.

3. ON is a reserved word. Thus, you can not use it for another purpose.

4. In your code you have "goto Main" but there is no Main. I think you meant "goto ON", but since you can not use "ON", just change ON to Main.

5. For the FOR loop you have, you will not have 8-bits on PORTA. Thus you need to have a look at there. Check Bruce's example on the link above.


Check the datasheet of the PIC you will use. Check which pin can be used as an input-only and/or output-only etc.

Also, check how many pins you have on each port.


----------

------------