Xref: news2.mv.net comp.os.msdos.djgpp:5038 From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: How to tell djgpp NOT to optimate a line of code Date: Thu, 13 Jun 1996 17:44:34 +0100 Organization: The University of York, UK Lines: 26 Message-ID: References: NNTP-Posting-Host: tower.york.ac.uk Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Thu, 13 Jun 1996, Lennart Steinke wrote: > I wrote a ISR which hook into the timer interrupt and updates > a global variable. > > b=g; > while (b==g); > > this loop is always optimazed to > while(1); > > ist there a possibilty to tell gcc not to touch the code > (similar to the __volatile__ keyword)? Yes, the volatile keyword :-) That's what it means... The global variable that you alter in your IRQ handler should be declared as 'volatile int', to tell the optimiser that it may be changed by things outside the current block of code (eg. your interrupt). /* * Shawn Hargreaves. Why is 'phonetic' spelt with a ph? * Check out Allegro and FED on http://www.york.ac.uk/~slh100/ */