Storing String Constants with PicBasic Pro?

Started by gettingalongwouldbenice October 30, 2004

I need to store a few dozen variable length strings
containing GPIB commands for a demo aid using PicBasic Pro
in a PIC16F877A.

First try was to use Lookup. Works, but I have to wrap
a loop around each lookup function.

Second try was to use the readcode function and store
the strings with inline assembler:

@ db "this is the String",10

Problem with this is determining where the Nth string starts.
Manually entering addresses from the listing works, but makes
changing the text tedious and error prone.

I can build one BIG string and scan the whole thing for linefeeds
every time I need the Nth string. The readcode function is
slow. It seems to behave itself when the
string crosses a page boundary.

Is there a way to address strings in rom symbolically?
I can scan for linefeeds and build a pointer table at run time...
Can't the compiler/assembler do this for me?

Need something like an "address of label" operator.

Thanks, mike





I not sure I got you - but maybe you can try store the strings in a
big array - what every and have other array like "index" that hold
the positions of the line feed - so when you need the Nth string
begin from IndexPos[N], and scan till the line feed.

--- In , "gettingalongwouldbenice"
<gettingalongwouldbenice@y...> wrote:
>
> I need to store a few dozen variable length strings
> containing GPIB commands for a demo aid using PicBasic Pro
> in a PIC16F877A.
>
> First try was to use Lookup. Works, but I have to wrap
> a loop around each lookup function.
>
> Second try was to use the readcode function and store
> the strings with inline assembler:
>
> @ db "this is the String",10
>
> Problem with this is determining where the Nth string starts.
> Manually entering addresses from the listing works, but makes
> changing the text tedious and error prone.
>
> I can build one BIG string and scan the whole thing for linefeeds
> every time I need the Nth string. The readcode function is
> slow. It seems to behave itself when the
> string crosses a page boundary.
>
> Is there a way to address strings in rom symbolically?
> I can scan for linefeeds and build a pointer table at run time...
> Can't the compiler/assembler do this for me?
>
> Need something like an "address of label" operator.
>
> Thanks, mike





Thanks for the input. That's basically, pun intended, what I did.
But it's slow, ugly and hard to maintain. Would be nice to address the
strings symbolically without having to scan the whole range every time.
Shouldn't I be able to set a pointer to S1??? Thought about generating
a pointer table, but didn't have the energy, cause it's working. Nice
thing about this approach is that it seems not to get excited at memory page boundaries.

mike

'calling sequence
stringstart = 29
gosub doastring
'more stuff here ....
end

doastring:
'search string table for the stringstart[th] string and send it out the GPIB port
stringnum = 1
stringpoint = $1000
testme10:
readcode stringpoint, cb
if cb = 1 then
hserout[10,13,"ERROR endofstrings",10,13]
return
endif
if cb <> 0 then
if stringnum = stringstart then
gosub gbo 'handshake cb out the gpib port
endif
else
stringnum = stringnum + 1
endif
if (stringnum > stringstart) then
stringstart = stringnum
return
endif 'data strings for demo output starting at 0x1000
data1:
@ org 0x1000
s1:
@ db "message:box 35,45,400,80",10,0
s2:
@ db "message:show ",34,"Channel 4 AutoSetup",34,10,0
s3:
@ db "message:show ",34,"Look At All The Cool Stuff We Can Measure!",34,10,0
s4:
@ db "message:show ",34,"Expanding Horizontal Scale",34,10,0
s5:
@ db "horizontal:main:scale 10E-9",10,
@ db 1 ;terminates series of strings in message box put 1 in last char of last string for error checking

--- In , "einavha" <einavha@y...> wrote:
>
> I not sure I got you - but maybe you can try store the strings in a
> big array - what every and have other array like "index" that hold
> the positions of the line feed - so when you need the Nth string
> begin from IndexPos[N], and scan till the line feed.
>
> --- In , "gettingalongwouldbenice"
> <gettingalongwouldbenice@y...> wrote:
> >
> > I need to store a few dozen variable length strings
> > containing GPIB commands for a demo aid using PicBasic Pro
> > in a PIC16F877A.
> >
> > First try was to use Lookup. Works, but I have to wrap
> > a loop around each lookup function.
> >
> > Second try was to use the readcode function and store
> > the strings with inline assembler:
> >
> > @ db "this is the String",10
> >
> > Problem with this is determining where the Nth string starts.
> > Manually entering addresses from the listing works, but makes
> > changing the text tedious and error prone.
> >
> > I can build one BIG string and scan the whole thing for linefeeds
> > every time I need the Nth string. The readcode function is
> > slow. It seems to behave itself when the
> > string crosses a page boundary.
> >
> > Is there a way to address strings in rom symbolically?
> > I can scan for linefeeds and build a pointer table at run time...
> > Can't the compiler/assembler do this for me?
> >
> > Need something like an "address of label" operator.
> >
> > Thanks, mike