[Icc-430] Suggestions on ICC Code improvement
Wolfgang Schulze
Wolfgang.Schulze at myrealbox.com
Tue Mar 20 00:50:17 PST 2007
Sorry that I sent the same contents of the previous discussion
twice, but I thought I had the address wrong.
I did some more comparisons of the ICC code generated relative to the
IAR code. In some instances IAR is still better. Here are some more
results. Hope they can be used by the programmer:
Comparison to a constant is done using a register, although it could be
done directly:
0490 ; if (Uph_fi[0]>260) strcpy((char *)AnzStr,"L1 >260V ");
0490 3B400401 mov #260,R11
0494 1B900200 cmp _Uph_fi,R11
0498 0734 jge L42
It would be better to use
cmp _Uph_fi,#260
jge L42
Code of IAR
\ 000000 B2900501.... CMP.W #0x105, &Uph_fi
\ 000006 0638 JL ??Verarb221_0
____________________________________________________________
When a function ends on a call and there is no pop , then it could
branch to the function. This saves code and time
Example
09AC ; Copy(ZweiteZeile,AnzStr);
09AC 3F400400 mov #_AnzStr,R15
09B0 3E400000 mov #_ZweiteZeile,R14
09B4 B0120000 call #_Copy
09B8 .dbline -2
09B8 L175:
09B8 .dbline 0 ; func end
09B8 3041 ret
Call #_Copy
ret
can be replaced by BR #_Copy
IAR Code
764 Copy(ZweiteZeile,AnzStr);
\ ??Verarb71_1:
\ 000026 3E40.... MOV.W #AnzStr, R14
\ 00002A 3C40.... MOV.W #ZweiteZeile, R12
\ 00002E 3040.... BR #Copy
____________________________________________________________
Registers are used when it would be possible to store directly:
0AF2 ; AnzStr[n]=' ';
0AF2 3B400400 mov #_AnzStr,R11
0AF6 0A4E mov R14,R10
0AF8 0A5B add R11,R10
0AFA FA4020000000 mov.b #32,0(R10)
It would be better :
mov.b #32,#_AnzStr(R10)
IAR code
828 AnzStr[n]=' ';
\ 00004E FA402000.... MOV.B #0x20, AnzStr(R10)
_____________________________________________________________
We are always pushed for code space and would appreciate getting more
compact code (can't wait for the compatible 120k versions to be available).
We purchased the professional version but I have not understood the
method of global optimization yet. Is it done automatically during
compile and link time or must it be invoked manually. Some hints on
where to read about it would be appreciated.
Wolfgang
More information about the Icc-430
mailing list