Re: 18F, table read, sdcc

Peter Onion <[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.gnupic
Message-ID <[email protected]>
On Sat, 2005-08-06 at 00:43 +0200, Alessandro Zummo wrote:
> 
>  Hello,
> 
>   anyone has suggestions on the best way to read data
>  stored in program memory using SDCC/PIC16?
> 
>   in assembly I would use a DB directive,
>  TBLPTR and the table read istruction..
> 
>   I was planning to keep using the DB directive,
>  assemble with gpasm -c into an object file,
>  and loading the data from C.


It's easy.... No need to mess around with TBLPTRL/H/U, let the compiler
do all that for you....

unsigned char __code myData[8] = {1,2,3,4,5,6,7,8};
unsigned char __code *myDataPointer = myData;

Sequential access via pointer
n = *myDataPointer++;

Random access via array
n = myData[m];

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.