From: SourceForge.net <no...@so...> - 2003-08-14 01:44:15
|
Bugs item #788167, was opened at 2003-08-13 09:25 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=788167&group_id=599 Category: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: SDCC Compiler Bug... Initial Comment: ... or optimizer bug. My code void TransmitPacket() { unsigned char n; CE = 1; Delay100us(1); SpiReadWrite(shockbase[0x08]); SpiReadWrite(shockbase[0x09]); SpiReadWrite(shockbase[0x0A]); SpiReadWrite(shockbase[0x0B]); for(n=0;n<20;n++) { SpiReadWrite(n); } CE = 0; Delay100us(100); } Does not compile/optimize the FOR loop correct! However changing datatype for [n] to [char] will get the code to work. Both CHAR and UCHAR asmlisting for the loop is attached below. Compiler version [2.3.5] [Apr 21 2003] [MINGW32] //best regards //Jörgen Tapani //jo...@te... /////////////////////////////////////////////////// //with char n; ;pcu.c:95: for(n=0;n<20;n++) ; genAssign mov r2,#0x00 00101$: ; genCmpLt ; genCmp clr c mov a,r2 xrl a,#0x80 subb a,#0x94 ; genIfxJump ; Peephole 108 removed ljmp by inverse jump logic jnc 00104$ 00109$: ;pcu.c:97: SpiReadWrite(n); ; genCall mov dpl,r2 push ar2 lcall _SpiReadWrite pop ar2 ;pcu.c:95: for(n=0;n<20;n++) /////////////////////////////////////////////////// /////////////////////////////////////////////////// //with unsigned char n; ;pcu.c:95: for(n=0;n<20;n++) ; genAssign mov r2,#0x00 00101$: ; genCmpLt ; genCmp cjne r2,#0x14,00109$ 00109$: ; genIfxJump ; Peephole 108 removed ljmp by inverse jump logic jnc 00104$ 00110$: ;pcu.c:97: SpiReadWrite(n); ; genCall mov dpl,r2 push ar2 lcall _SpiReadWrite pop ar2 ;pcu.c:95: for(n=0;n<20;n++) /////////////////////////////////////////////////// ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=788167&group_id=599 |