This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Another Optimization Problem

Greetings all,

I'm fairly new to the Keil Toolset and had a question regarding the C51 code optimization levels.

It seems that on Level 8: Reuse Common Entry Code (default), the main() entry function gets completely optimized out if the main() function grows too large. I can avoid this by either changing the optimization level, or by adding the debug flag in the Output tab.

The actual assembly is correct in the .LST file, but if I check the hex file, the main() function doesn't appear at the location specified by the map file.

Is this normal behaviour? Is there some setting I'm misinterpreting somewhere?


TIA,
JG.

Parents Reply Children
  • If you are referring to _my_ program, yes, it works when the main() isn't removed (i.e. when I compile with the debug flag set, or one of the other optimization options).

    It _doesn't_ work when it jumps to the main and executes a whole bunch of nops.

    Is that what you were asking?
    JG.

  • "Is that what you were asking?"

    Yes. If your program worked I'd have said the optimisation was normal. As it doesn't, I'd say the optimisation *may* not be normal.

    Can you try and reduce your program to the minimum that doesn't work at this particular optimisation level then post the .cod file?

    Have you tried levels 9, 10 or 11 alternately speed and size optimisation to see what happens?

    What version of compiler and linker are you using?

    Stefan