鈥?/div>
During an interrupt, only the return PC value is saved
on the stack. Typically, users may wish to save key reg-
isters during an interrupt e.g. W register and STATUS
register. This will have to be implemented in software.
Example 9-1 stores and restores the STATUS and W
registers. The user register, W_TEMP, must be de铿乶ed
in both banks and must be de铿乶ed at the same offset
from the bank base address (i.e., W_TEMP is de铿乶ed
at 0x70 - 0x7F in Bank 0). The user register,
STATUS_TEMP, must be de铿乶ed in Bank 0.
EXAMPLE 9-1:
SAVING THE STATUS AND W REGISTERS IN RAM
Copy W to a Temporary Register regardless of current bank
Swap STATUS nibbles and place into W register
Change to Bank 0 regardless of current bank
Save STATUS to a Temporary register in Bank 0
Routine)
Swap original STATUS register value into W (restores original bank)
Restore STATUS register from W register
Swap W_Temp nibbles and return value to W_Temp
Swap W_Temp to W to restore original W value without affecting STATUS
MOVWF
W_TEMP
;
SWAPF
STATUS,W
;
BCF
STATUS,RP0
;
MOVWF
STATUS_TEMP
;
:
: (Interrupt Service
:
SWAPF
STATUS_TEMP,W ;
MOVWF
STATUS
;
SWAPF
W_TEMP,F
;
SWAPF
W_TEMP,W
;
DS30559A-page 68
Preliminary
漏
1996 Microchip Technology Inc.