We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Compiler produces different code for same line
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