PDA

View Full Version : Fullfilling lookup tables



Acetronics2
- 25th July 2006, 13:58
Hi, Everybody

Suppose we want to have a 250 values LOOKUP table ....

Writing all values by hand is quite boring and not error-free guaranteed ... isn't it ???

Now, working with MPLAB ( or else ) permits to locate the beginning of the RETLW xx list in the ASM listing .... and we know how to include a text file containing RETLW xx 's , ... coming from an Excel page or so ... precomputing media.

Would it be possible to find something to include the DATA file into the PbP brackets ( easiest solution !!! ), or a modifier, i.e " REP x\250 ", or another trick to keep free space in the ASM Listing to allow including the DATA file .... ????

Alain

mister_e
- 25th July 2006, 14:12
Or i'm dumb or i need more cofee but i can't figure out what you ask for.

Please, help the old Quebecer guy to understand. It sounds an interesting idea overall, it's just unclear to me...

Un dessin, un dessin, un dessin ;)

Acetronics2
- 25th July 2006, 14:52
Hi, Steve

No design needed .... just strong coffee.

You want a big lookup table ... how to fill automatically, from an existing text file, the values between the brackets ???

Of course with a PbP source program ...

1St way : a modifier in the LOOKUP statement, plus including the file at the right ASM line ???
2Nd way : include the text file between the brackets ...????
3Rd way : ????

Last way: Modify the Lookup routine !!!
Lazy way : Copy and Paste .....

PbP 's hard point is there is a L 00001 label that is inserted by the compiler just past the LOOKUP routine ... so, impossible to only use the ORG directive to make room !!! The brackets must contain the right number of constants ...

Alain

peterdeco1
- 25th July 2006, 18:03
Hi Alain. If you figure out a way to do this, it would help alot. Right now I'm using about 8K of code space that repeats the same opcode to an ISD5008 using the shiftout command. However, each opcode has a different address. To put these different addresses between the brackets into a lookup table re-using one opcode would shorten the code much.

Acetronics2
- 25th July 2006, 18:31
Hi,Peter

The only way I see at the moment is to create a simple program ( GW or QBasic ...) that gives your DATA bytes separated by a comma ... into a .txt file.

Then, you copy it and paste between the brackets. so simple as this !!!

Of course it must exist a mathematical relation between input and output ... or the loading can't be made else than by-hand !!!

I think I'll have a look to the SIN routine in the PbP libs ... to see if it's possible to modify it. ( or a similar routine )

Alain

peterdeco1
- 25th July 2006, 18:59
Hi Alain. I guess I wasn't being clear in my last post. For example, someone pushes a series of buttons. Each button is a different ISD address. Now comes playback time. What I have done that is memory intensive is this:

ShiftOut PORTC.5,PORTC.3,0,[FIRST\16] 'first is variable for 1st playback address
ShiftOut PORTC.5,PORTC.3,0,[SECOND\16] 'second is variable for 2nd playback address
ShiftOut PORTC.5,PORTC.3,0,[THIRD\16] 'third is variable for 3rd playback address

Now, if those variables were written into the program by itself such as [224,132,188] I could use the lookup command, put it into X and use something like:

ShiftOut PORTC.5,PORTC.3,0,[X\16] 'X is variable for all addresses
next X

Right now I have 20 address variables & 20 shiftout commands and a large block of code that says LET FIRST = 111, LET SECOND = 222, etc. I even thought of using read & write but the problem is getting those numbers into brackets. - Peter

mister_e
- 25th July 2006, 20:58
the only thing that spring to mind is the use of dt or da... for now. Kind of variation of embedded string in your codespace. But you'll have to use readcode instead... too bad


DEFINE LOADER_USED 1
DEFINE OSC 20
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 129 ' 9600 Bauds


@CSize=CODE_SIZE ; get the PIC Codespace size
CSize con ext ' make it available in PBP
LookupSize con 50
ZAData VAR word
ZAAddr VAR word
LookupStart var word

LookupStart=(CSize*1024)-512 ' get the Lookup first address
' As i used the bootloader i just move
' the adress to a x place

Start:
FOR ZAAddr=LOOKUPSTART TO LOOKUPSTART+lookupsize
READCODE zaaddr, zadata
zadata=zadata&$FF
HSEROUT [dec zadata,13,10]
pause 500
NEXT
pause 500
goto start



asm
org ((CODE_SIZE*D'1024')-D'512')
dt 10 ,20 ,30 ,40 ,50
dt 60 ,70 ,80 ,90 ,100
dt 110,120,130,140,150
dt 160,170,180,190,200
dt 210,220,230,240,250
dt 240,230,220,210,200
dt 190,180,170,160,150
dt 140,130,120,110,100
dt 90 ,80 ,70 ,60 ,50
dt 40 ,30 ,20 ,10 ,0
endasm

even there, there's no gain in time and on nothing about typing IMHO. You should do a cute app in VB or else who write the whole LOOKUP line for you and send it to the clipboard... then just paste it to your code. It's still easy to read any ACCESS or EXCEL speadsheet from VB.

Anyways, you can also export the excel sheet in text format and select the separator you want. No need fr a VB app or else OR once again i miss something?

BigWumpus
- 25th July 2006, 21:10
Use Excel!

the first column contains the data (numbers), the second a formula like ="RETLW " & A1


I prefer to use "@ DE" to put data inside the programcode and READBYTE to get them back.
Usind more than 8 bit is a little bit tricky - processor - pbp - assembler don't realy fit together in every combination.

mister_e
- 25th July 2006, 21:12
I prefer to use "@ DE" to put data inside the programcode and READBYTE to get them back.
Usind more than 8 bit is a little bit tricky - processor - pbp - assembler don't realy fit together in every combination.

As far as i'm aware of... @ DE store into the EEPROM, not the codespace at all. and there's not benefit to use it unless you want to specify some label. DATA do the same thing.

And READBYTE don't exist in PBP.. just READ

BigWumpus
- 25th July 2006, 22:27
Ups....

I have to return the last 4000 controllers tomorrow ? ;-)

Use READCODE instead of READBYTE (it's the name of my sub)

Acetronics2
- 26th July 2006, 10:54
Anyways, you can also export the excel sheet in text format and select the separator you want. No need fr a VB app or else OR once again i miss something?

Hi, Steve

I already do have such application .... LOL !!! May be I'll post you for a barrel of Maple syrup or two ...

I had a look to Lookup Macro .... Ayayaye, quel malheur !!! ... easier to write my own Assembler Macro locating the table(s) in the very high part of the memory.

Just a filter on Pic number or MAXRAM value to set the table address ... and that should be much,much,much,much faster than a Lookup !!! ( Stopwatch made me reddish ...)

Thinking also to add an interpolation between successive values ... but that can easily be made with PbP.

Readcode ...??? might have been nice ... if working with all common Pics.

Alain

mister_e
- 26th July 2006, 11:45
All i can say is usually when i need to use Lookup Table, i store them in a external EEPROM, using Excel or whatsoever else custom program make life easy. Well case by case i guess. I try to keep codespace for what it's suppose to be used... code.

What PIC do you plan to use? Any 18Fs? if so there's already some built-in TABLR plah plah stuff.


I already do have such application .... LOL !!! May be I'll post you for a barrel of Maple syrup or two ...
Hehe they're still some available 'round here. The best time is always in spring... after that it's mostely called Sirop de poteau ;)

Acetronics2
- 26th July 2006, 14:50
Hi,Steve

I do not use 18F devices to that day ... small 18 pins packages show too many bugs !!!

.... and EEPROMS are really too slow for what I do ... // FRam could be used !!!

Back to the subject,

the goal is just to add " include C:\ .... table.txt " to the listing !!!

here, a clean XL / VB Sheet, just the print-to-file work to add !!!

Cheese ...

Alain

mister_e
- 26th July 2006, 21:46
Neat! well done!

Acetronics2
- 31st July 2006, 14:47
Hi, Steve

After lots ( LOL ) of trails, I went to commit that ...

The table loads great !!! ... full Program hasn't been " live tested" yet ... ( re LOL )

Alain

PS: IF PIR1.2 THEN ... at the beginning, has being modified for simulation ( good read is : IF NOT PIR1.2 ... of course, dear Mr Watson ... )

mister_e
- 31st July 2006, 15:43
hehe... way to go Monsieur!