Quote Originally Posted by sougata View Post
... So if I use Banksel in my ASM routine (not within the main body of the program but ISR) would there be any problem ? If yes, then why ? Context is being restored automatically either through the shadow registers for High Priority or through your program if LP is used.
Context/Shadow registers will ensure that when it returns from the interrupt ... those 3 register sets will have the same contents in them.

But if values get written to the wrong BANK somewhere within the ISR, shadow registers can't help.

It's especially important to maintain the proper PREV_BANK when using ASM in the Main program, since there are no Shadow registers to get everything back to normal when it's finished.

And ALL ASM routines in the Main program that use any PBP macros like CHK?RP, RST?RP, MOVE?xx with other bank switching methods, should end with ...
Code:
; for 16F's ...
  clrf  STATUS
PREV_BANK = 0

; for 18F's
  clrf BSR
PREV_BANK = 0
Which resets PBP's banking system in preparation for the next statement.
<br>