This code is used to save and restore the context registers of a PIC18F device before executing an interrupt service routine. FSR0 only needs to be saved
-
ISR:
-
; Save processor context
-
movwf wSave, 0
-
movff STATUS, statSave
-
movff BSR, bsrSave
-
-
; Save FSR0
-
movff FSR0L, fsr0lSave
-
movff FSR0H, fsr0hSave
-
-
; Insert code here
-
-
End_Isr:
-
; Restore FSR0
-
movff fsr0lSave, FSR0L
-
movff fsr0hSave, FSR0H
-
-
; Restore processor context and return
-
movff bsrSave, BSR
-
movf wSave, w, 0
-
movff statSave, STATUS
-
retfie 0