Compilation oddity?
Erik Friesen
Posts: 1,071
I have a problem with come code here, that doesn't make too much sense to me. I can create a non working program by adding code to an unreachable location. In the attached code, adding the line - inhg:=inhgdif - below Mainscreen in PUB Start in my attached program toggles it to a nonworking program.
I believe all my stacks are sufficient size, as changing them makes no difference.
What can I look for, in a situation like this? Why would shifting the compiled output 4 bytes do something like this?
I believe all my stacks are sufficient size, as changing them makes no difference.
What can I look for, in a situation like this? Why would shifting the compiled output 4 bytes do something like this?
Comments
This is a large, complex program. You're going to have to do a bit of work describing what it does and its structure to reasonably expect any kind of specific help with it. You've already brought up one of the possible problems, that being stack overflow. Another possibility is access to an array or via a pointer (address) that's out of range. Both would cause the type of behavior you've described. If this were my program, I'd try to isolate the portion of the program involved by using a spare I/O pin or several I/O pins to provide some kind of debug output, either using something like ViewPort or a serial LCD or even just a few LEDs. I'd insert statements to provide an indication of where the initialization routine has gotten to before "blowup". That's not always useful, but it's a start.
I don't expect folks to decipher my code, but rather I am combing for ideas on what type of things to look for.
Have you put debugging information in various bits to see where the program fails? or does it just appear to not do anything at all? Got a spare output somewhere you can connect a led to?
You have 950 longs free as far as I can tell. Compiling with bst and optimisations turned on makes that 1232 free. I'm pretty sure in either case you are not running out of stack. There are some pretty deep calls there but nothing that should use 950 longs. All your stack for secondary cogs is allocated in VAR space anyway so it's only the main cog that might use all that stack.
I suspect there is something more sinister going on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
Your construct there adds 6 bytes to the end of the routine. A basic String() with one character in it will give you 2 bytes of padding, and you can stretch it out from there to see what happens.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
Because I just had to debug my own issue, I get a little nervous about defining things as "bytes" in the var section (like data[noparse][[/noparse]1029])
and then addressing them as long (like long[noparse][[/noparse]@data]).
Now, you may not have the same trouble as me, but I find that it's much less risky to define everything as longs, even if you intend to
address them as bytes.· Especially, if you intend to give the address to an assembly cog...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
I have a niggling suspicion that it is in my lcd code however.
I was under the impression that the compiler arranged it in this order - All longs first, then words, with the first aligned on a long boundary, then bytes, with the first on a long boundary.(within each object) I may be wrong on this point, which could be my problem.
Yeah, I'm afraid you are quite wrong. The reason for packing them the way it does is so there are no alignment requirements for the start of words or bytes.
You can guarantee a long is always on a long boundary. Likewise, the first word is always aligned on a long boundary (as it follows the longs) and the first byte is always on a word boundary.
Now, having said that, in your ALLV203.spin you have no word allocations, so your byte will always start on a long boundary (and it does)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
if_z jmp printchar_ret
....
printchar_ret ret
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz