Bug with IDE compiler
I found, that with the following setup, the compiler generates an incorrect base address when using the @ operator in spin.
in a DAT section
MyByteDat byte 99
MyLongDat long $12345678
in spin
MyPtr·:= @MyLongDat
MyPtr will be three bytes off the real address of MylongDat.
I know the reason is because the system padded out the byte block to a long so that MyLongDat could be long aligned but I would have thought the compiler/IDE would know about this and report the correct address for MyLongDat
I have to put a dummy LONG before the MyLongDat label.
MyByteDat byte 99
long
MyLongDat long $12345678
Thanks,
Bob
in a DAT section
MyByteDat byte 99
MyLongDat long $12345678
in spin
MyPtr·:= @MyLongDat
MyPtr will be three bytes off the real address of MylongDat.
I know the reason is because the system padded out the byte block to a long so that MyLongDat could be long aligned but I would have thought the compiler/IDE would know about this and report the correct address for MyLongDat
I have to put a dummy LONG before the MyLongDat label.
MyByteDat byte 99
long
MyLongDat long $12345678
Thanks,
Bob
Comments
The way the variable space handles packing is to declare all longs, then words, then bytes then pad the last location so that following code lies on a LONG boundry.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 8/23/2007 10:50:47 PM GMT
·
Still, it would seem to me that using @label sould always return the correct address when using it at run time.
Thanks!
-Bob
I post this test program, which shows no issues of the kind discussed...
N.B.: DAT is allocated at the start of the memory, before the mas of code...
Post Edited (deSilva) : 8/24/2007 10:17:00 AM GMT
The Compiler cannot know the value of a RES label in it's first pass; the reason beeing the length of the defined area can be an arbitrary constant, thus recursion is possible, example:
For this reason it is not allowed to evaluate the address of a RES label as a constant! Example
Post Edited (deSilva) : 8/24/2007 10:53:55 AM GMT