Thank you very much Scott, Your code is exactly what was needing. Luis F. ----- Original Message ----- = From: "Scott Dattalo" To: "Microcontroller discussion list - Public." Sent: Monday, November 06, 2006 3:31 PM Subject: Re: [pic] RETLW table on PIC18Fxxxx antoniasse wrote: > I=B4m looking for retlw instead tblrd (table-read instructions) > becouse I have some codes writes for the 16Fxxx and I have > to change for the 18Fxxx series, Then In this case, > it will be easier for me. Luis, If you're porting table lookup code from the 16F series to the 18F series then don't forget that the index value added to the program counter must be multiplied by 2 on the 18F. I usually write my table code something like so: MOVLW HIGH (table_start) MOVWF PCLATH MOVF index,W ADDLW LOW (table_start) SKPNC INCF PCLATH,F MOVWF PCL For the 18F series I'd change it slightly to: CLRF PCLATU MOVLW HIGH (table_start) MOVWF PCLATH RLNCF index,W ADDLW LOW (table_start) SKPNC INCF PCLATH,F MOVWF PCL I also usually make sure the index is in range for the table. This can be done with a single ANDLW instruction as long as the length of your table is an even power of 2. You may wish to write a macro that does everything for you and then your 16F code can 18F code can be made to look identical. Scott -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist