Specifications

Chapter 2 - Microcontroller PIC16F84
One of the possible cases of errors if saving was not done when going to a subprogram of
an interrupt
Due to simplicity and frequent usage, these parts of the program can be made as macros. The
concept of a Macro is explained in "Program assembly language". In the following example, contents
of W and STATUS registers are stored in W_TEMP and STATUS_TEMP variables prior to interrupt
routine. At the beginning of PUSH routine we need to check presently selected bank because
W_TEMP and STATUS_TEMP are found in bank 0. For exchange of data between these registers,
SWAPF instruction is used instead of MOVF because it does not affect the status of STATUS register
bits.
Example is a program assembler for following steps:
1. Testing the current bank
2. Storing W register regardless of the current bank
3. Storing STATUS register in bank 0.
4. Executing interrupt routine for interrupt processing (ISR)
5. Restores STATUS register
6. Restores W register
If there are some more variables or registers that need to be stored, then they need to be kept after
storing STATUS register (step 3), and brought back before STATUS register is restored (step 5).
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_07Poglavlje.htm (4 of 7) [4/2/2003 16:17:55]