How to reduce Timer error of Atmel 89S51 microchip?
I am no expert on this chip. Still, I see a common source of inaccuracy in your program: when the counter times out, the interrupt is activated, and some instructions after that you set the TL0, which makes the counter start to count down your 1ms again. Hence there is some dead time between each 1ms interval that is 'lost'. I am not sure this is enough to explain your 1s deviation but it could be.

There are various ways to reduce this 'lost' time:


experiment, measure, and adapt the value you assign to TH0 accordingly (duct tape development style)
exchange the TL0 and TH0 assignments (effect will be small)
(assuming the counter keeps running) instead of assigning a new value to TL0 you can update it (keeping the counts it has already accumulated): TL0 = TL0 - ((8192 - 1000) % 32 );


But the only real solution is to keep the timer running freely and be more intelligent with the counting of the timeouts.