This is a common mistake. Just declare ticks as volatile. ~d On Tuesday 22 October 2002 20:37, Paul Burke wrote: > I'm having a lot of trouble with the way GCC treats various objects. In > particular, if I want to pass falgs about in my program, unless I'm very > pernickety it optimeses them out, assuming they aren't wanted. For > example: (ticks is incremented by an interrupt) > > void wait_ticks( unsigned int nticks) > { > unsigned int t; > > t = ticks; > > while( (ticks-t) < nticks) > ; > } > > If I don't declare ticks as volatile, I get this: > > 000047d4 <wait_ticks>: > 47d4: 0e 43 clr r14 ; > 47d6: 0e 9f cmp r15, r14 ; > 47d8: fe 2b jnc $-2 ;abs dst addr > 0x47d6 > 47da: 30 41 ret > > which just hangs. > > Is there any way of forcing the compiler to assume everything is > volatile? Why does it do this anyway? > > Paul Burke > > > ------------------------------------------------------- > This sf.net emial is sponsored by: Influence the future > of Java(TM) technology. Join the Java Community > Process(SM) (JCP(SM)) program now. > http://ad.doubleclick.net/clk;4699841;7576301;v?http://www.sun.com/javavote > _______________________________________________ > Mspgcc-users mailing list > Mspgcc-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mspgcc-users
-- /******************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys (_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44 _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 3468202, 5585314 ********************************************************************/