I as remember, volatile loops were discussed a while ago. Check the code below.
cheers ~d P.S. this is a bad programin' technique... i suppose... volatile short *pbuf, *plast; int main(void) { short buf[10]; pbuf = buf; plast = buf + 10; while(pbuf < plast) __asm__ __volatile__ ("; nop %0,%1" : "+m" (pbuf), "+m" (plast) : ); return 0; } On Tuesday 06 April 2004 21:43, Matthias Weingart wrote: > On Tue, Apr 06, 2004 at 11:33:28AM -0500, Sergei Sharonov wrote: > > volatile short *pbuf, *plast; > > > > pbuf = buf; > > plast = buf + 10; > > while(pbuf < plast); > > This compiles to > > 1494: 82 41 26 02 mov r1, &0x0226 ; > 1498: 0e 41 mov r1, r14 ; > 149a: 3e 50 14 00 add #20, r14 ;#0x0014 > 149e: 82 4e 28 02 mov r14, &0x0228 ; > 14a2: 0f 41 mov r1, r15 ; > 14a4: 0f 9e cmp r14, r15 ; > 14a6: fe 2b jnc $-2 ;abs 0x14a4 > > It does update pbuf and plast, but then use the values hold in the > registers to do the while loop - what is obviously wrong. When you change > plast in a int.routine the while loop will never get any notice of this. > Sergei was right. A little bit to much optimisation. ;-) > > Matthias > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users