On this link you can find some examples for PIC 18F452. They helped me a lot. This microcontroler is similar with 16F877 but not the same. You should read datasheets for boath and make appropriate corections in code. It all depends what you need.
okay, thats one of the reasons why i am also planning to use an 18F452 as an A/D converter
the link that i have provided you will help you in using the 16F877 as an A/D converter although it is written for the 16F876. but there are very minor differences between the 877 and the 876.
here is some code and schematic to help you it was done in basic but it's just to show you how easy it is. It reads 0-5v but you can set it up to read 0-50v using the right parts so that you don't excced 5volts on the pic it al so has a bar graph under neath it hope it helps you
If you didn't buy 16F877 yet my advice is to buy 18F452. They have similar price. Then you should try examples on the link that I post earlier. Most of your work is done there. But it's all on you.