Julien, Have you looked really sharp? I expect f1() to generate a JBC (instead of JB or JNB) and that includes the clearing of the sbit.
Maarten > > Hi, > > I am currently having an issue (or a misunderstanding) with sdcc > mcs51 with a sbit clearing instruction being erroneously (IMHO) > removed. > > I am using sdcc-3.0.0 (as shipped in Fedora 14 repository). sdcc -v > SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.0 > #6037 (Mar 20 2011) (Linux) > > I have also tested with the svn development version rev 6473. sdcc -v > SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.2 > #6470 (Apr 30 2011) (Linux) > > The code is targeted for a 8051 included in a TI cc1110. The > following code is a simplified version of the issue: > > /* compile with "sdcc -mmcs51 file.c" */ > > #include <mcs51/cc1110.h> > > void f1(void) { > UTX0IF = 0; > U0DBUF = 'X'; > while ( !UTX0IF ) ; > UTX0IF = 0; > } > > void f2(void) { > UTX0IF = 0; > U0DBUF = 'X'; > while ( !UTX0IF ) { > __asm > nop > __endasm; > } > UTX0IF = 0; > } > > void f3(void) { > IRCON2 &= ~0x02; > U0DBUF = 'X'; > while ( (IRCON2 & 0x02) == 0 ) ; > IRCON2 &= ~0x02; > } > > void main(void) { > f1(); f2(); f3(); > } > > /* End of code */ > > When looking at the assembler code of the f1() function, the second > sbit affectation "UTX0IF = 0;" (which should be compiled with a "clr > _UTX0IF") has been removed (apparently by the label optimization). > > The f2() and f3() are alternate versions of f1(). f2() add a NOP > into the while() statement. f3() uses the sfr instead of the sbit. > These alternate versions are not affected by this issue. > > As a final note, the instruction is not removed in > f1() when the code is compiled with the --nolabelopt option. > > I would expect that these three functions has the same behavior. > Did I miss something or is this some kind of a bug? > > Thanks, > > -- Julien Olivain. > > ------------------------------------------------------------------------------ > WhatsUp Gold - Download Free Network Management Software > The most intuitive, comprehensive, and cost-effective network > management toolset available today. Delivers lowest initial > acquisition cost and overall TCO of any competing solution. > http://p.sf.net/sfu/whatsupgold-sd > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user