Hello Vincent, The reason for this behaviour is that SDCC turns polling and then clearing a bit/sbit into an atomic action (using JBC). This is very useful when the bit is a semaphore or is set inside an interrupt handler.
Maarten > Hi. > > I'm looking at asm generated for the following loop (8051, a CYCFX2LP > actually) with sdcc 3.1.0#7066: > > __sbit __at 0x98+1 TI; > void main() { > while (!TI); > TI = 0; > } > > I get this: > > 00101$: > jbc _TI,00115$ > sjmp 00101$ > 00115$: > > Wouldn't it be more efficient, for such bit polling loop, to use instead: > > 00101$: > jnb _TI,00101$ > clr _TI > > The first version polls _TI every 7 cycles. > The second version polls _TI every 4 cycles. > If _TI is set on loop entry, the first version exits after 4 cycles while > the > second exits after 6 cycles. I believe it's sane to assume this is an > unlikely > event, so it shouldn't matter too much. > > Regards, > -- > Vincent Pelletier ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122912 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user