try to visit the link below:

http://www.microchipc.com/sourcecode/#bootloader

maybe you can find some clue, I did not find exactly the same chipset that you have but other examples base on other chipset may be a good reference.