English
Language : 

PIC16F8X_13 Datasheet, PDF (19/128 Pages) Microchip Technology – 18-pin Flash/EEPROM 8-Bit Microcontrollers
PIC16F8X
4.5 Indirect Addressing; INDF and FSR
Registers
The INDF register is not a physical register. Address-
ing INDF actually addresses the register whose
address is contained in the FSR register (FSR is a
pointer). This is indirect addressing.
EXAMPLE 4-1: INDIRECT ADDRESSING
• Register file 05 contains the value 10h
• Register file 06 contains the value 0Ah
• Load the value 05 into the FSR register
• A read of the INDF register will return the value of
10h
• Increment the value of the FSR register by one
(FSR = 06)
• A read of the INDF register now will return the
value of 0Ah.
Reading INDF itself indirectly (FSR = 0) will produce
00h. Writing to the INDF register indirectly results in a
no-operation (although STATUS bits may be affected).
FIGURE 4-1: DIRECT/INDIRECT ADDRESSING
RP1 RP0
Direct Addressing
6
from opcode
0
A simple program to clear RAM locations 20h-2Fh
using indirect addressing is shown in Example 4-2.
EXAMPLE 4-2: HOW TO CLEAR RAM
USING INDIRECT
ADDRESSING
NEXT
CONTINUE
movlw
movwf
clrf
incf
btfss
goto
:
0x20 ;initialize pointer
FSR ; to RAM
INDF ;clear INDF register
FSR ;inc pointer
FSR,4 ;all done?
NEXT ;NO, clear next
;YES, continue
An effective 9-bit address is obtained by concatenating
the 8-bit FSR register and the IRP bit (STATUS<7>), as
shown in Figure 4-1. However, IRP is not used in the
PIC16F8X.
Indirect Addressing
IRP
7
(FSR)
0
bank select location select
bank select
00h
0Bh
0Ch
Data
Memory (3)
2Fh (1)
30h (1)
4Fh (2)
50h (2)
00
01
10
11
00h
not used not used
Addresses
map back
to Bank 0
7Fh
7Fh
Bank 0 Bank 1 Bank 2 Bank 3
Note 1: PIC16F83 and PIC16CR83 devices.
2: PIC16F84 and PIC16CR84 devices
3: For memory map detail see Figure 4-1.
location select
 1996-2013 Microchip Technology Inc.
DS30430D-page 19