www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/16/10:09:41

Xref: news2.mv.net comp.os.msdos.djgpp:5038
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
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: <Pine.SGI.3.91.960613174235.17500B-100000@tower.york.ac.uk>
References: <Pine DOT VUL DOT 3 DOT 91 DOT 960613123358 DOT 3422E-100000 AT zeus DOT adv-boeblingen DOT de>
NNTP-Posting-Host: tower.york.ac.uk
Mime-Version: 1.0
In-Reply-To: <Pine.VUL.3.91.960613123358.3422E-100000@zeus.adv-boeblingen.de>
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/
 */

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019