At 14:44 7/10/99 -0400, you wrote: >At 11:16 AM 10/7/1999 -0800, you wrote: >>>Hi Guys, >>>HiTech compiler, what is the different between optimization level 1 to 9 ? >>>Thanks, >> >>I run with all the optimizations, and level 5. The difference between that >>and no optimizations whatsoever is about a 15-20% reduction in codesize. > Andy Kunz wrote >I just compiled my application with both Zg1 and Zg9 settings. Exact same >results. Andrew Kalman wrote >I run with all the optimizations, and level 5. The difference between that >and no optimizations whatsoever is about a 15-20% reduction in codesize. So what does this all mean? Ok it is quite simple (simple explaination will be given) As you can see Andy like myself does not get any code size change, or often very little, where Andrew gets a large change. For most of the time Andrew is quite correct, a large change can be found with just the first 3 levels of optimisation, after this point very little. In his case the code will have large numbers of routines and many variables being past between functions. This makes the code flowery as the complier will do the compilation in a *Safe mode* where it will not look for dead code and will use fixed variables etc. Where in Andys and my case we both have proberably taken the time to see how the compiler works and to see what code produces the best result eg. unsigned *ptr; *ptr = a; if (*ptr++ == 3) do some stuff; OK simple C But not very good code in a machine that is only 8 bits and is not the best at 16 bit type functions, ok how to make it better:- unsigned i unsigned* ptr; i = a; *ptr = a; ptr++; if (i == 3) do some stuff; OK this can be even better!, but becomes non portable and you have to start watching what you do:- unsigned i near unsigned *ptr; i = a; *ptr = i; (Not A) ptr++; if (i == 3) do some stuff; Take a look at loops, which is best? while (1) for (;;) Take a look at these and see which is best do while (i--) do i-- while (i) while (i--) while (i) i-- for (i=0; i<5l; i++) These are all important! Watch pointers they chew up code space like it is free There are many other things to look for but take a look at your coding style if you want the best from this compiler Dennis