hsc's hardware interrupt is not working

hello i am practicing with 100 ppr encoder. if i choose the reference value of 1000 on plc and want to light lamp in hardware interrupt then there is no problem but as you can see in the picture, if i want to calculate for revolution of encoder in hardware interrupt, encoder's pulse value is wrong. it stops to 999. why is there a problem like that, if i move this program to main ob the issue is fixed. why do we use hardware interrupt then 350940709_276787534715718_926220972832823560_n.jpg
 
Top