Hello, I have faced a problem with a function pointer variable. I have separated the uart module in two parts: HAL, which abstracts the hardware, and Service, which provides the uart service to the application. The interrupt routine is in HAL module, which has a function pointer variable that is called into the interrupt routine as interrupt handler. The actual interrupt handler function is in Service module. This function is assigned to the function pointer variable through a install function in the init routine. It works in debug simulation, but when I load the hex file to the microcontroller the application does not work. Anyone can help me?
Your design, while nice, is rather a bad match for an 8051 controller. In a nutshell, 8051s hate function pointers in C programs. Any usage of them makes the compiler's and linker's job explosively harder. And function pointers in an interrupt handler are even worse.
C51 interrupt handlers are best kept short. Really short. As a rule of thumb they shouldn't be calling any other functions if you can possibly help it --- much less refer to other functions via pointers.
So I strongly advise to stop worrying about why exactly this doesn't work --- just don't do it.