Hi all,
I am using Keil version "Vision3v3.53". It has 10(0-9) levels of optimization during compiling. I am working on a project where requirement is to reduce the code size. In default settings when i compile code, the code size comes around 62k and when i use optimization options the code side reduces as per my requirement. When i use the 9th level optimization option i.e. COMMON BLOCK SUBROUTINES, the code size comes to around 49k. Now my query is...
Is there any side effect of using these optimization level? If so what can be that effect? which level of optimization i can use so that it doesn't has any side effect on code. Also if any one knows better optimization(in terms of code size) technique then this, please suggest me...
Thanks in Advance. Antriksh
The biggest side effect is that your code will be much, much harder to debug - because the generated code will look very different from the source!
It is also likely to show up any false assumptions in your code.
"better optimization (in terms of code size) technique"
http://www.keil.com/support/man/docs/c51/c51_xc.htm
You should also think carefully about whether moving to another architecture could be more appropriate...
Also if any one knows better optimization(in terms of code size) technique then this, please suggest me...
"hand optimizing" may give great results. make sure nothing that fit in 8 bits use more carefully locate variables so that most frequently used are in DATA and rarely used variables in XDATA avoid the large memory model
the above has, as opposed to tool optimizing above level 2 no effect on debugging.
it is very 'easy' to ignore all concern "I use the 'large' model because it saves me a lot of work" "I always use 'int' that saves me evaluating sizes" etc will cost you more than the optimizer can get back.
Erik
Boolean variables as one-bit variables tends to give huge improvements, when moving code from standard C. The 8051 processor loves boolean expressions like hardly any other processor.
On the other hand - it absolutely hates anything larger than 8 bits. That includes use of pointers - especially function pointers.
And it hates recursive functions.