PDA

View Full Version : table of constant



detonator
- 18th August 2006, 17:20
Sorry I have a stupid question about syntax,
how can I implement table of constants (lot of constants) into picBasic code?
thank you.

SteveB
- 18th August 2006, 17:52
Detonator,

First, the constants you declare in Pic Basic are only used during during the assembly process to create the code. In the code that is loaded into the pic, there is just the number.

Now, There are a number of ways to do what it sounds like you want to do. Here are 2:

1) Using the LOOKUP or LOOKUP2 commands
2) Saving your data into the EEPROM or an Unused portion of Program Memory as a lookup table. Then you can lookup the data in the table based on whatever you need. Read up and then search the forum on the following PBP commands: EEPROM, DATA, READ, WRITE also READCODE, WRITECODE, ERASECODE. You might also want to read Darrel Taylor's work (http://www.pbpgroup.com/modules/wfsection/article.php?articleid=10) on storing strings into program memory. It may be useful if your data is 7 bits or less (as well as this thread on Embedded Strings in your Code Space (http://www.picbasic.co.uk/forum/showthread.php?t=1999)).

Just a couple of ideas to get you started. Have a look and get back with some more specifics. (Do a little homework on your own and you will likely get a lot of help here working out the details/bugs)

Steve

detonator
- 18th August 2006, 18:15
thank you Steve,
I meant somethink like DT or RETLW in assembler
so I'll do this part of program in assembler

Darrel Taylor
- 18th August 2006, 21:32
This one might be more applicable to storing large tables of word constants.

Using EXT with Labels ...
http://www.picbasic.co.uk/forum/showthread.php?t=3891#LAB
<br>