On Mon, 5 Jan 1998 18:31:06 +0100 Rob Aerts writes: >in a program, i have 16 bytes (in ram) >i want to read and modify these bytes using a counter >(witch points to the specified byte) All the PIC instructions access RAM directly. But the PIC has special hardware to indirectly access RAM. It works through two special function registers: FSR and INDF. The FSR (File Select Register) register holds the address of the RAM byte to be accessed. It is the pointer or index register. The INDF (INDirect File) register acts as a 'shadow' copy of the register selected by FSR. Reading the INDF register returns a copy of the data found at the RAM location [FSR]. Writing to the INDF register stores the data at the location indexed by FSR. For example: table equ h'10' ;Start of the table in RAM. ; Store some values in the table using direct access. movlw 1 movwf table ;Entry 0 in the table = 1 movlw 2 movwf table+2 ;Entry 1 in the table = 2 ; Read entries in the table sequentially using indirect access. movlw table ;Address of entry 0 in table. movwf FSR ; Now INDF is a copy of entry 0. movfw INDF ;Get data from entry 0 call output ;Send data out (for example) incf FSR movfw INDF ;Get data from entry 1. call output To access any byte in the table, compute the true address in RAM and write it to FSR. Then read or write the table data to INDF. ; Read a byte from the table. Table index (0-16) in W. addlw table ;Offset to start of table. movwf FSR ;Point to desired data in table. movfw INDF ;Read it.