Xref: news-dnh.mv.net comp.os.msdos.djgpp:1628 Path: news-dnh.mv.net!mv!news.NH.Destek.Net!news2.net99.net!news.cais.net!ringer.cs.utsa.edu!swrinde!howland.reston.ans.net!Germany.EU.net!zib-berlin.de!solid.theo-physik.uni-kiel.de!news.informatik.uni-kiel.de!news.techfak.uni-kiel.de!news From: Hartmut Schirmer Newsgroups: comp.os.msdos.djgpp Subject: Re: optimization.bug Date: 18 Aug 1995 06:33:57 GMT Organization: Technische Fakultaet Lines: 33 References: Nntp-Posting-Host: zora.techfak.uni-kiel.de To: brendan AT rdt DOT monash DOT edu DOT au Dj-Gateway: from newsgroup comp.os.msdos.djgpp Brendan Simon wrote: > > >I have some kind of wierd optimization bug in V2. When reading an I/O status >port on my A2D card, the BUSY bit seems to get stuck on after the first read >of this port. The code is :- > >short get_A2D(char channel) >{ > channel = channel % 8; > outportb(CONTROL_REG, channel); /** select A2D channel to convert **/ > > while( (inportb(STATUS_REG) & BUSY_BIT) ); /** wait for not busy **/ > > outportb(START_CONVERSION, 0xff); /** start A2D conversion **/ > > while( (inportb(STATUS_REG) & BUSY_BIT) ); /** wait for not busy **/ > > return( inportw(A2D_DATA) ); >} > >With any of the optimizations selected, the 2nd while loop never terminates >as the busy bit always appears high. With no optimization the code works >as expected. > >Any ideas. Is it a bug or is it a silly mistake somewhere??? > Check the assembly output (gcc -S ...) and compare optimized and plain code. Maybe the optimized version is just to quick and overrunning your A/D hardware. Hartmut