delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/26/03:19:40

Date: Fri, 26 Jan 1996 03:11:49 -0501 (EST)
From: Cuthalion / Sliced Bread <enrico AT max DOT tiac DOT net>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: djgpp AT delorie DOT com
Subject: Re: Waiting for retraces........................................
Message-ID: <Pine.NEB.3.91.960126030659.3980A-100000@max.tiac.net>
MIME-Version: 1.0

On Thu, 25 Jan 1996, Eli Zaretskii wrote:

> > 	Eventually I figured out what was wrong, after making a couple of 
> > really stupid mistakes (I tried a whole bunch of times, it stands to 
> > reason that some of the attempts will be really messed up.. :)   The 
> > problem was that I was using -O3.  Evidently, GCC took this to mean that 
> > I didn't expect the values of any hardware ports to change ever, and it 
> > was okay if it would cache them.  Is this a problem with GCC in general, 
> > or the port to the Intel chips?  (Can't it be told that some stuff, like 
> > hardware status, will change, without GCC changing it?)
> The PC motherboard chipset is built in a way that prevents the CPU from
> caching memory-mapped peripheral devices and I/O ports, so it cannot be a
> caching problem.  It might be that GCC has optimized out your code where
> you read the ports.  Usually, the way to tell it not to do this is to
> declare the variable `volatile'.  You didn't tell enough details to help
> you more.  For instance, what version of DJGPP are you using? did you use
> inport/outport library functions? can you post some code fragments where
> this happens? 
> 

	The basic code was while((inportb(0x3DA)&8)!=1); 

	I also tried:
int temp = 0;
while(temp & 8 != 1) temp = inportb(0x3DA); 

	So, how come Csaba Beigl uses his own inport_b(port)?  Does that 
have anything to do with this?

	Oh, I am using DJGPP v2.0b3, with (I think) beta 8 of CWSDPMI.

> One thing that you should know is that -O3 inlines functions which were 
> declared inline.  So if you, for example, are using inport/outport 
> function, it might be a problem with the way they are written or with the 
> way you use them (depends on your version of DJGPP and the actual code of 
> your program).
> 
	I have a near-satisfactory workaround - I isolated that function 
in a separate C file, which I can then compile on it's own.  So all of my 
code except for the waiting gets optimized, which is really fine.


/***********************************************************************
* Jesse Morris * cuth AT gryphon DOT ccs DOT brandeis DOT edu * jrmorris AT macalstr DOT edu *
****************   Cuthalion / Sliced Bread    *************************
              \*********************************/

- Raw text -


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