Indirect Addressing; INDF and FSR Registers
INDF RegisterThe INDF register is not a physical register. Addressing INDF actually addresses the register whose address is contained in the FSR register (FSR is a pointer). This is indirect addressing.
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). A simple program to clear RAM locations 20h-2Fh using indirect addressing is shown Below: FSR RegisterFile register 04 is the File Select Register (FSR). It is used for indirect or indexed addressing of the other file registers, particularly the GPRs (General Purpose Registers 0Ch-4Fh). If a file register address (00–4F) is loaded into FSR, the contents of that file register can be read or written through file register 00, the Indirect File Register (INDF). This method can be used for accessing a set of data RAM locations, by reading or writing the data via INDF, and selecting the next file register by incrementing FSR. This indexed, indirect file register addressing is particularly useful for storing a set of data which has been read in at a port, in, for example, a data logging application. An output data table of predefined values, such as seven-segment display codes, can use the program data table method described. The demonstration Program below loads a set of file registers, 20–2F, with dummy data (AA), using FSR as the index register. Here, FSR operates as a pointer to a block of locations and is incremented between each read or write operation. Notice that the data actually has to be moved into INDF each time.
Indirect File Register Addressing - Flow of the above program.
|
|||||