I am not going to bother checking that project.
Man, what a horror
Do you know there is something known as 'indention'
Your code is absolutely unreadable. No wonder you're facing troubles while debugging this mess
Keep in mind that more clear & readable code you write, more easy it'll be to test & debug it for you as well as for others.
Still I am going to give few suggestions to you..
1) AT89C51XD2.h & intrins.h are compiler's native headers, so they must be within <> & not "".
2) Use typedef to define your own variable types & not #define.
3) Though it is acceptable always specify void when defining functions not having arguments,
4) Go find & use some good "programming styles". C is already famous(!?) for its read-only programs, but we certainly don't want to add to its (ill)fame.