I have a thought that would make many processes much more effective and, being only one voice, I would like to know if there is a demand before I propose it to Keil. This is the result of me having to change a switch statement to a series of IFs to make an ISR process fast enough. I realize, and thus do not complain, that Keil caould not implemet an ANSI-C switch more efficient than the way it is done. 'n' below will be either 2 or 3 (if Keil decide to implement, they can choose) a Proposal: if #pragma QUICKSWITCH then a) no case value can be more than 255 b) all case values must be multiples of n c) the switch will be implemented as a jump table Erik
Which OPTIMIZE level are you using? 2, just to get the variable overlaying. I do not and will not use optimizers, they defeat the NASA principle "we fly what we test" which, since some testing for unforseen events is done by pegging values in the emulator makes working with 'optimized' code an impossibility. doing 'quickswitch' should be a compiler issue, not an optimizer issue. Erik
Two things to consider: - almost everyone uses the default optimization 8. You can still 'fly' what you 'test' since full debug information is provided. Therefore this is also the best tested compiler mode. - switch/case optimzation requires some other information that is generated by optimizers that need to run. switch/case optimzation is enabled with OT(4) and above.
- almost everyone uses the default optimization 8. You can still 'fly' what you 'test' since full debug information is provided. there is with any optimization (I do not consider overlaid variables optimization) several disadvantages: a) there will be many mismatches between source and actual code b) I know the Keil compiler is so excellent that I do not need to check the assembler, but I do anyhow, see also d). c) 'merged' sequences makes reasonable breakpointing impossible. d) often a fault in the c source is revealed by what is assembled from it and .. finally .. e) I am not "almost everyone" and have no desire to be. Therefore this is also the best tested compiler mode why 'tested' this is not about 'testing' it is functionality. switch/case optimzation requires some other information that is generated by optimizers that need to run. I am VERY curious, which added information would be required to make my example above into a jump table. Erik
a footnote to the above: I once had a timing error that only did show when the optimizer was active. Debugging it, by any 'helped means' (emulation) was impossible beacuse the critical sections were 'combined' with frequent operations by the optimizer. For that reason it took 6 weeks to find a problem that, had it shown in non-optimized, would have been a matter of a day or two. It turned out to be a subtle bug in a (then) recently released Atmel derivative, not the design. Erik