[PicForth] Large amounts of text seem to cause PicForth to
generate bad code
Alex Holden
alex at linuxhacker.org
Thu Dec 2 14:29:38 CET 2004
David McNab wrote:
> There's several things that could be causing this. No idea which, unless
> you can post some code.
Unfortunately there's about 1200 lines of it and creating a minimal
example which demonstrates this particular problem is easier said than done.
> One thing I could suggest is to create one word for each line, something
> like:
> : line1 c" this is the first line" type ;
> : line2 c" this is the second line" type ;
> ...
That didn't help.
Note that it's not crashing when it tries to 'type' the help text; in
fact it crashes even if the program doesn't call 'type' at all. And the
crash symptoms are different every time I reset it, but always
exceptionally weird. Sometimes (usually) it prints random jibberish to
the serial port; sometimes it doesn't. Sometimes the ISR dies (as
evidenced by the 'heartbeat' LED stopping); sometimes it doesn't.
Sometimes it even starts printing the bootloader question mark prompt
over and over again in an infinite loop.
> Also, generate the disassembly file and have a look inside to see if
> there's anything suspicious, such as banks or pclath not being set right.
Always the first thing I try when I think I might have found a PicForth
bug (about half the time it turns out to be a problem in my code
instead, but I have found several problems that way). This time it's
proving exceptionally difficult, largely due to the randomness of the
symptoms (giving me no clue where to look) and the amount of code
involved (over 2000 instructions).
I think I'm going to have to try harder to come up with a minimal
example, but I suspect 'minimal' will still require something that uses
more than 2Kwords of program memory.
> BTW - I notice that with more recent PicForth versions, the bootloader
> is using 512 words of prog mem, so instead of [1]e30, sermon.fs needs to
> org to [1]e00.
I found that 1e14 fits nicely, but I am using a slightly modified
version of sermon because I only have one LED on my board and I'm using
a 4Mhz crystal (as a result the timeout code needed modifying as well as
the baud rate constant). I've been planning to modify it some more to
use a spare switch I have on my board instead of a timeout for choosing
whether to enter the bootloader or start the main program. Or I may
write a new one that uses a more efficient transfer protocol and an
uploader program which works on OSX.
--
------------ Alex Holden - http://www.linuxhacker.org ------------
If it doesn't work, you're not hitting it with a big enough hammer
More information about the PicForth
mailing list