Drew Vassallo says:
Just looking through my code to try to reduce some cycles and came up with this method for compensating for lost time during ISR servicing.
If you're doing a PWM loop or otherwise performing some loop count timing and get interrupted, you might be able to compensate for the lost time with:;; No context saving required. btfsc flag, 0 ; to indicate whether or not you're inside PWM loop decfsz counter ; loop counter for PWM retfie incfsz counter retfie
Note that the last incfsz (not incf!) is needed so your counter doesn't go below zero, which could hurt if you're using decfsz to monitor your loop counter. It would never skip the last retfie.
Of course, the path through the ISR has to be equal in time to the time through one PWM loop for this to be at all valuable.
Just thought I'd throw it out there as a useful snippet if anyone is intersted.