Why would the following line in C:
XRAM00 |= 0x01;
compile into this:
mov dptr, #XRAM00 movx a, @dptr mov r7, a mov a, r7 orl a, #1 mov r7, a mov dptr, #XRAM00 mov a, r7 movx @dptr, a
I would have expected this:
mov dptr, #XRAM00 movx a, @dptr orl a, #1 movx @dptr, a
And it turns out it's a lot easier to generate code that's correct, if inefficient, and then optimize away inefficiency than it is to try to write a code generator that is smarter in the first place. It's a form of modularity; the code generator is responsible for semantics, the optimizer for getting rid of the silliness that occurs when you don't pay global attention to that sort of thing
as to my post above and this
that "it's a lot easier ..." does not, in any way, hinder that what I described could be done by the compiler, maybe do compile - do optimize, instead of "compile to optimal", but that would not make any difference to the user.
Then, of course an optimizer would be needed to optimize after linking (e.g. combine identical execution strings in different modules for those that do not care about debugging).
Erik