Re: [Sdcc-user] Code generated for small loop

2013-01-19 Thread Maarten Brock
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 (80

Re: [Sdcc-user] Code generated for small loop

2013-01-19 Thread Vincent Pelletier
Le samedi 19 janvier 2013 06:48:41, Erik Petrich a écrit : > The compiler is thinking you are trying to use TI as a binary semaphore > and so implements the sequence with an atomic test and clear to eliminate > the possibility that an interrupt might occur between the while loop and > the assignmen

Re: [Sdcc-user] Code generated for small loop

2013-01-18 Thread Erik Petrich
On Fri, 18 Jan 2013, Vincent Pelletier wrote: > 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$ >