I'm using several interrupts and strangely enough when I change optimize to another level then 4 the program will crash.
Also I made a some floating point calculation converting it back to 2 words, I do that twice right between each other (exactly the same code) but the outcome is different. (what should be impossible)
When I pass variables to a procedure, the program gets unstable, when I use global variables with the same procedure, but not passing it to the variables, it is more stable.
It seems like the compiler makes a mess of the stack..
the piece of code with different result is paste below:
Code: Select all
TPos:=TPos*(extended(1930464.7111111111));
if (TPos >= 0) then
begin
DPos := dword(TPos);
end
else
begin
TPos:=TPos*-1;
DPos := dword(TPos);
//DPos := ((DPos xor $FFFFFFFF)+1) and $FFFFFFFF;
DPos := not(DPos);
DPos := LoDword(DPos);
DPos := DPos + 1;
end;
LATLONWord1 := HiWord(Dpos);
LATLONWord2 := LoWord(Dpos);
When running this twice with the same value for tpos LATLONWord1 and LATLONWord2 have different values.
Also code in a dummy procedure (never get called) can make the program crash (when commented out all lines in the procedure will get a running program, otherwise it will crash right away)
Update:
I have upgraded to 3.0.0 that gave even worse result, program crashes right away.
After downgraded to 2.5.5 the same code (same settings) runs stable, only with some strange outcome (see above)
Changing optimize in version 2.5.5 won't change anything on the stability.