PIC17C75X
EXAMPLE 6-1: SAVING STATUS AND WREG IN RAM (SIMPLE)
; The addresses that are used to store the CPUSTA and WREG values must be in the data memory
; address range of 1Ah - 1Fh. Up to 6 locations can be saved and restored using the MOVFP
; instruction. This instruction neither affects the status bits, nor corrupts the WREG register.
;
UNBANK1
UNBANK2
UNBANK3
UNBANK4
UNBANK5
EQU
EQU
EQU
EQU
EQU
0x01A
0x01B
0x01C
0x01D
0x01E
; Address for 1st location to save
; Address for 2nd location to save
; Address for 3rd location to save
; Address for 4th location to save
; Address for 5th location to save
;
(Label Not used in program)
; Address for 6th location to save
(Label Not used in program)
UNBANK6
;
EQU
0x01F
;
:
; At Interrupt Vector Address
; Push ALUSTA value
; Push BSR value
; Push WREG value
; Push PCLATH value
PUSH
MOVFP
MOVFP
MOVFP
MOVFP
;
ALUSTA, UNBANK1
BSR, UNBANK2
WREG, UNBANK3
PCLATH, UNBANK4
:
; Interrupt Service Routine (ISR) code
;
POP
;
MOVFP
MOVFP
MOVFP
MOVFP
UNBANK4, PCLATH
UNBANK3, WREG
UNBANK2, BSR
; Restore PCLATH value
; Restore WREG value
; Restore BSR value
; Restore ALUSTA value
UNBANK1, ALUSTA
RETFIE
; Return from interrupt (enable interrupts)
1997 Microchip Technology Inc.
Preliminary
DS30264A-page 37