cognew weirdness
mpark
Posts: 1,305
The following code works (it displays a white "2" on a blue screen), but if I change the 64 to 65, it breaks (the screen remains black). I don't understand why an additional long should cause a problem. Any ideas?
_clkfreq = 80_000_000 _clkmode = xtal1 + pll8x obj term : "tv_text" pub blah | i term.start( 24 ) term.dec( cognew( @nada, 0 ) ) dat long 0[noparse][[/noparse] [b]64[/b] ] '<== change this to 65 nada org 0 jmp #nada
Comments
All DAT variables should be defined after any Propeller Assembly routines. This includes all res definitions which should proceed any long,word, or byte declarations.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
But things get weirder yet. If I use my tv_wtext or a different version of tv_text, it works okay, too, even with the label on the org. There's a really odd interaction going on here, but it's certainly not clear yet what it is.
Beau,
BTW, it's okay to declare variables ahead of an assembly program, as long as you include the org where it needs to be and don't try to use those variables in the assembly code: they won't be loaded into the cog.
This works:
This doesn't:
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 6/4/2009 8:29:11 PM GMT
The best rule to follow is this: Never put a label on an org. An org is not an executable assembly statement.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 6/4/2009 8:38:37 PM GMT
As we all know the COG-RAM is always filled with 512 longs. So it's unpredictable what code will be there. Or maybe you have NOPs up to the end of the COG-RAM where we find the special registers. At least the INA will give use a surprise instruction then ;o)
You could easily check if it jumps where you expect it to jump to by toggling an pin instead of doing nothing.
OK, that's embarrassing. I know and obey that rule. Except today.
Thank you, Phil!