Compiler produces different code for same line
I set the optimize to 0, problem went away. thanks all.
GEAG said:I set the optimize to 0, problem went away
So there wasn't any actual problem in the first place!
The compiler was just doing a perfectly valid optimisation - omitting an unnecessary re-load of the DPTR - exactly as any assembler programmer would have done if writing this manually!
Andy Neil said:So there wasn't any actual problem in the first place!
There was: the source code was implicitly making an incorrect assumption, causing incorrect behaviour. And that problem remains unsolved.
On top of that, there are probably quite a number of even worse problems of similar kinds lurking in that source base.
The morale: if you observe a problem goes away by changing optimization levels, the actual problem is pretty much guaranteed not to be with the compiler, but rather with your source code.
Broeker said:if you observe a problem goes away by changing optimization levels, the actual problem is pretty much guaranteed not to be with the compiler, but rather with your source code
+1