simple...
the adc just measures the analogue voltage present on an ADC channel (in the datasheet this is given as AN0, AN1, this simple means analogue channel 0, 1 etc.), and then converts it to a 10 bit value. The 16F877 has a 10 bit ADC, this means a maximum of 2^10 range, or 1024 bits for a full scale value.
In other words when 5 volts (same as the ADC reference voltage) is given to an ADC channel, the equivalent word value is 1024.
Thus the calculation for conversion is as follows.
ADC Word= (Channel VoltageX1024)/5
when I volt is given we get (1024X1)/5 = 51
Similarly this value can be converted back to voltage, during display..