Maker Pro
Maker Pro

Context saving

A

Alexander

I always saved the context like the example below and restored it in reverse
order.
With the new series you are able to push and pop file-registers.
Is it possible to simply push and pop the registers???
If not can I use movff for it???

ThanX

Alexander

ORG 0x04 ; interrupt vector location
GOTO ISR ; Interrupt Service Routine

ISR
;************************
;*** ISR CONTEXT SAVE ***
;************************
movwf W_TEMP ; context save: W
swapf STATUS,W ; context save: STATUS
movwf STATUS_TEMP ; context save
clrf STATUS ; bank 0, regardless of current bank
movfw PCLATH ; context save: PCLATH
movwf PCLATH_TEMP ; context save
clrf PCLATH ; page zero, regardless of current page
bcf STATUS,IRP ; return to bank 0
movfw FSR ; context save: FSR
movwf FSR_TEMP ; context save
;*** context save done ***
 
N

NewsGroup

Alexander said:
I always saved the context like the example below and restored it in reverse
order.
With the new series you are able to push and pop file-registers.
Is it possible to simply push and pop the registers???
If not can I use movff for it???

ThanX

Alexander

ORG 0x04 ; interrupt vector location
GOTO ISR ; Interrupt Service Routine

ISR
;************************
;*** ISR CONTEXT SAVE ***
;************************
movwf W_TEMP ; context save: W
swapf STATUS,W ; context save: STATUS
movwf STATUS_TEMP ; context save
clrf STATUS ; bank 0, regardless of current bank
movfw PCLATH ; context save: PCLATH
movwf PCLATH_TEMP ; context save
clrf PCLATH ; page zero, regardless of current page
bcf STATUS,IRP ; return to bank 0
movfw FSR ; context save: FSR
movwf FSR_TEMP ; context save
;*** context save done ***

Looking at the 18 series data sheet, you can't push and pop registers but it
looks like you should be able to do the following:-

movwf TOSL
movff STATUS,TOSH
movff BSR,TOSU
push

; ISR Stuff

pop
movff TOSU,BSR
movf TOSL,W
movff TOSH,STATUS
retfie

The TOSU register is only 4 bits so has to contain the BSR.

HTH

Mike.
 
Top