----- Original Message ----- From: "Kashif Ali" To: Sent: Friday, May 18, 2001 8:13 AM Subject: Re: [PIC]:a newbie mpasm question > i don't know how to use indirect address in pic16f84. > any one can send me an example of indirect addressing routine. > > kashif ali Here is some sample code to move 8 bytes using indirect addressing. To obtain the address of a variable you would use a MOVLW instruction. For example, to move 8 bytes from "HERE" to "THERE" you could use the following sequence: MOVLW HERE ;obtain address of 'HERE' MOVWF SOURCE ;store into source pointer MOVLW THERE ;obtain address of 'THERE' MOVWF DEST ;store into destination pointer CALL Block_Move ;move the data ;--------------------------------------------------------------------- ;Block_Move -- Move 8 Bytes from SOURCE to DEST ; Entry: ; SOURCE should be pointing at place to move from ; DEST should be pointing at destination place to store block ; Exit: ; SOURCE ,DEST, TEMP0, TEMP1, FSR will be destroyed. However, ; the data will be moved ;-D ;--------------------------------------------------------------------- Block_Move movlw d'8' ;Number of bytes to move movwf TEMP0 _move_lp movf SOURCE,W ;Set up source pointer movwf FSR movf INDF,W ;get the byte movwf TEMP1 ; and save it movf DEST,W ;Set up destination pointer movwf FSR movf TEMP1,W ;pick up saved byte movwf INDF ; and store it (now it is moved to destination) incf SOURCE, F ;increment pointers to point to next byte incf DEST, F decfsz TEMP0, F ;see if we have moved all the bytes goto _move_lp return Hope this helps. Michael Brown Instant Net Solutions www.KillerPCs.net -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics