9.1.1.2 Indirect Read with FSR

The program memory can be accessed as data by setting bit 7 of an FSRxH register and reading the matching INDFx register. The MOVIW instruction will place the lower eight bits of the addressed word in the W register. Writes to the program memory cannot be performed via the INDFx registers. Instructions that read the program memory via the FSR require one extra instruction cycle to complete. The following example demonstrates reading the program memory via an FSR.

The high directive will set bit 7 if a label points to a location in the program memory. This applies to the assembly code shown below.

Read of Program Memory Using FSR Register

constants
	RETLW DATA0		;Index0 data
	RETLW DATA1		;Index1 data
	RETLW DATA2
	RETLW DATA3
my_function
	;… LOTS OF CODE…
	MOVLW	LOW constants
	MOVWF	FSR1L
	MOVLW	HIGH constants
	MOVWF	FSR1H
	MOVIW	2[FSR1]       ;DATA2 IS IN W