Geotronix wrote: > > I am working on a project using a 16F877 and am having difficulty in > indirectly addressing RAM locations. I would like to send a byte of data > to RAM location 0x120, by using the following: > > movfw Offset ;contains the value 20h > movwf FSR > movfw Data1 > bcf STATUS,RP0 > bsf STATUS,RP1 > movwf INDF > > YET...when simulated, Data1 is moved to 0x020. > It seems that no matter which page I switch to prior to executing the movwf INDF statement, Data1 is placed into 0x020. > Can anyone help? Some PICs have more than 256 bytes of RAM available, (16F877 for example), but the FSR can only hold values from 0 - 255. Therefore, to indirectly access RAM addresses above 255, there needs to be another address bit available. This bit is in the STATUS register and is called IRP. For example if IRP = 0, you can indirectly access RAM 0x00 - 0xFF (Banks 0 and 1) if IRP = 1, you can indirectly access RAM 0x100 - 0x1FF (Banks 2 and 3) This bit only works in conjunction with the FSR register and indirect addressing and is effectively bit 9 of the indirect address. STATUS RP0 and RP1 are not used with indirect addressing, only direct addressing. Your code should be modified like this... movfw Offset ;contains the value 20h movwf FSR bsf STATUS,IRP ; indirectly access banks 2 and 3 movfw Data1 movwf INDF ; written to 0x120 -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu