On 11/08/15 17:25, Daniel Beer wrote: Thanks guys I knew that I could count on you all for help. volatile, that's new to me I'll look it up. Kernighan and Ritchie say what you all say but ANSI C says it's implementation dependent, as long as it works. Thanks Ian. > On Sun, Nov 08, 2015 at 05:01:34PM -0500, Ian Chapman wrote: >> Hi all, >> I'm having difficulty understanding this situation. >> flag = 1; >> while ( 0 != flag ) >> { >> code; >> } >> generates strange assembly code till I commented out >> // flag = 1; >> it looked to me like the optimizer realized that from then on the code >> would be planted in a " $ jmp $; " situation. I intended flag to be >> cleared after an ADC interrupt. ie set flag and wait for it to be cleared. >> Test code snippet and Makefile follow. > The compiler is allowed to assume that flag won't spontaneously change, > because you haven't told it otherwise. Either declare flag as volatile > (probably the simplest), or insert a memory barrier before checking its > value. > > Cheers, > Daniel >
------------------------------------------------------------------------------ Presto, an open source distributed SQL query engine for big data, initially developed by Facebook, enables you to easily query your data on Hadoop in a more interactive manner. Teradata is also now providing full enterprise support for Presto. Download a free open source copy now. http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140 _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users