Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
If seqNumber <> 0 Then
packet(2) = controllerType
packet(4) = HiByte(seqNumber)
Debug.Print CStrHex(seqNumber); " Sent"
packet(5) = LoByte(seqNumber)
Call sendPayload(packet, 5)
End If
In this second example if the Debug statement is commented out then the whole block is not executed. If the Debug statement is moved down a couple of lines then the whole block is not executed.
The generated code looks ok. The stack all seems ok. Trying to generate a simpler example is unsuccessful. It seems like this could be the GCC compiler. I have seen it generate "over-optimized" code before. Has anyone else seen "inexplicable" problems like this?
I've seen discussion of over-aggressive optimization on the AVR Freaks list but I've never observed it myself. It is difficult to diagnose the actual problem without a test case that exhibits the problem.
You mentioned that the generated C code looks OK so it is unlikely to be a ZBasic optimization problem. You can add an option to your .pjt file to see if it is a gcc optimization problem. For example, to turn off all optimization by the gcc back end, use the sequence below. The options that you specify are placed on the gcc compiler invocation line after all "standard" options.
mikep wrote:I am seeing some strange problems with some of my native mode code.
This problem was determined to be caused by incorrect code being generated (native mode only). A new version of the compiler has been posted (see the announcement at the top of this forum) that corrects the deficiency.
dkinzer wrote:This problem was determined to be caused by incorrect code being generated (native mode only). A new version of the compiler has been posted (see the announcement at the top of this forum) that corrects the deficiency.
To be exact, the new version of the compiler (2.6.1) resolves problem 1 as reported in this thread. Problem 2 may or may not still exist. For now let's close this thread and I will start a new one when I can find code that reproduces problem 2.