Microchip Technology DM164130-9 User Manual

Page of 101
PICkit™ 3 Starter Kit User’s Guide
DS41628B-page 82
 2012 Microchip Technology Inc.
3.12.6
Assembly Language
3.12.6.1 BOTH
EXAMPLE 3-43: 
Here, FSR0 is pointed towards the Queue location. 
 explains the code in 
. It is important to note that FSR0 is two bytes wide in order to address 
locations in program memory across multiple pages.
FIGURE 3-16:
BEFORE FILTERINIT IS CALLED
FIGURE 3-17:
AFTER FILTERINIT IS CALLED
After FilterInit is called, the FSR0 register is pointing towards the fist byte in 
queue. The INDF0 register can now be read/written to. Any affects on the INDF0 reg-
ister will affect the value at the assigned address in the FSR0 register. An increment of 
FSR0 will point to the next byte in the Queue register. In this case, it is the second ADC 
reading. 
A rotate or shift to the right is a quick method to divide by two. 
FilterInit:
 movlw    low Queue  ;point to the Queue holding the ADC values
 movwf    FSR0L
 movlw    high Queue
 movwf    FSR0H
INDF0
Queue [7]
Address: 
Value: ??????
Address: 0x000
Value: ??????
Address: 0x0054
Value[0]: d’15’
FSR0L:FSR0H
0x004:0x005
INDF0
Queue [7]
Address: 
Value: 0x0054
Address: 0x000
Value: d’15’
Address: 0x0054
Value[0]: d’15’
FSR0L:FSR0H
0x004:0x005
rrcf  RunningSum,w  ; divide by 2 and copy to a version we can corrupt