I made an error in the sample code I posted earlier tonight. I forgot to save & restore the value in W. The corrected code appears below: >> The 16F to 18F migration > I'd write it as (and I believe that the textual description of > routine's functionality is not optional): > > ; readit - function to return Nth octet from a d_user table in > ; program memory, where N is an unsigned 8-bit offest contained in > ; WREG on entry. On return, 8-bit value retrieved has been stored > ; in gotit variable. > ; > ; routine trashes WREG, STATUS, TBLPTR, & TABLAT > ; > readit MOVWF TABLAT, ACCESS ; save offset value for later (TABLAT is temp) ; > MOVLW UPPER d_user > MOVWF TBLPTRU, ACCESS ; load upper byte of pointer > MOVLW HIGH d_user > MOVWF TBLPTRH ; load high byte of pointer > MOVLW LOW d_user > MOVWF TBLPTRL ; load low byte of pointer ; MOVF TABLAT, W, ACCESS ; restore offset value > ; > ADDWF TBLPTRL, F, ACCESS > CLRF WREG, ACCESS > ADDWFC TBLPTRH, F, ACCESS > ADDWFC TBLPTRU, F, ACCESS ; adjust pointer to Nth element (N in WREG) > ; > tblrd* ; read byte from program memory into TABLAT > ; > movff TABLAT, gotit ; store byte into specified destination > ; > RETURN > > This should have the same functionality as your original 16F code. > And work in any size memory version 18 series PIC. Lee Jones -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist