The compiler tries to optimize the code the best it can however the programmer can help by using some of the special register variables. Currently the compiler writes parameter variable back to parameter RAM when they have been modified. Sometime this means that intermediate data is saved to parameter RAM. This increases code size and access to parameter RAM needlessly. Try to structure code to minimize parameter RAM accesses. [NOTE: this does not generally apply to the ETEC compiler, which will tend to eliminate unecessary RAM accesses unless the variable has the volatile type qualifier.]
For example try changing from:
int24 Period1, Period2;
Period2 = erta + 0x1000;
if(flag == 1)
Period2 += 0x1000;
Period2 += Period1;
erta = Period2;
To something like:
int24 Period1, Period2;
erta = erta + 0x1000;
if(flag == 1)
erta += 0x1000;
erta += Period1;
Period2 = erta;