Hi Neil, I guess you can use these operations (hope someone has better algorithm for you): Initialize table pointer (traditional way): movlw upper ( table ) movwf TBLPTRU movlw high ( table ) movwf TBLPTRH movlw low ( table ) movwf TBLPTRL Initialize table pointer (cheat way, when you are absolutely sure that the table is in the page 0...): clrf TBLPTRU clrf TBLPTRH movlw low ( table ) movwf TBLPTRL Initialize table pointer (cheat way, when you use a separate section in the linker script for the table): clrf TBLPTRU ; assume that the table is on below that range movlw high ( table ) ; load the section address only movwf TBLPTRH clrf TBLPTRL ; table starts at the offset 0 on that section incrementing by one (efficient way) TBLRD*+ ; we do not use the value of TABLAT here so we only incremented the pointer... incrementing manually by one (math operations way, you do not need this...)= : INCF TBLPTRL CLRF WREG ADDWFC TBLPTRH ADDWFC TBLPTRU incrementing by another number: MOVLW 0x10 ; or other incrementals ADDWF TBLPTRL CLRF WREG ADDWFC TBLPTRH ADDWFC TBLPTRU ; you can leave out this if you absolutely sure it will never overflow incrementing by another number (silly thing, slightly smaller prog mem footprint but much slower): MOVLW 0x10 ; or other incrementals TBLRD*+ DECFSZ WREG,F BRA $-4 Tamas On 17 January 2012 05:28, PICdude wrote: > Put a bit of time into this tonight, and partially answering my own > question, I found that I can do it this way (simplified)... > > // Define data... > unsigned char rom LookupTable[10] =3D { 1,2,3,5,7,9,11,13,17,19 }; > // Access/retrieve data... > a =3D LookupTable[5]; > > But still wondering, is there a more space-efficient way to do this if > I directly manipulate TBLPTRU/H/L etc ? > > Cheers, > -Neil. > > > > > Quoting PICdude : > > > I should also point out that this is for an 18F PIC. > > > > > > > > Quoting PICdude : > > > >> On the subject of tables in C18, as I've been tinkering with C > >> (instead of asm) for PICs, I'm going to get into tables soon. > >> > >> Off the top of my head right now, I can see how I'd use TBLPTRU/H/L to > >> point to the correct data, but not sure yet how data is declared and > >> held in memory efficiently, and how these will be 256-byte boundary > >> aligned (though I would think that that's not necessary here). These > >> will be pre-determined values. > >> > >> Anyone care to share an example of how this is done with C18? AFAIK, > >> the mchip app notes all show this in assembly. > >> > >> Cheers, > >> -Neil. > >> > >> > >> -- > >> 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 > > > > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .