Date: Sun, 2 Apr 2000 17:56:46 +0600 (LKT) From: Kalum Somaratna aka Grendel X-Sender: root AT darkstar DOT grendel DOT net To: Eli Zaretskii cc: djgpp AT delorie DOT com Subject: Re: Allegro and interrupts In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 2 Apr 2000, Eli Zaretskii wrote: > > On Thu, 30 Mar 2000, Kalum Somaratna aka Grendel wrote: > > > On Wed, 29 Mar 2000 night DOT walker AT tiscalinet DOT it wrote: > > > > > I must call sin() inside an timer function (i can't use a LUT, would > > > be too inaccurate...) I don't know how can i lock the function code > > > (without knowing the size) > > > > IMHO the code executed in a timer interrupt function should be as little > > as possible (like setting a flag) and should not hog up too much cpu, > > otherwise the whole system will slow down > > > > Slow instructions like sin should IMHO not be used in a interrupt > > function > > I fail to see how FSIN could be classified as too slow in this context. > Even on an i486 it takes less than 300 cycles, which is less than 10 > microseconds on a DX-33, 5 usec on DX2-66. I must confess that my panic at using FPU insns in game programming comes from the fact that I learnt game programming in the time when using the FPU was slooow, and everyone wrote code using sin and cos lookup tables etc. FWIW Even the allegro game programming library comes with a integer based floating point emulation rountines. I certainly agree that speed of FPU rountines vs integer rountines are norrowing. I once read that on a certain processor the fmul was faster than the imul... > The *real* problem is not with using FSIN, but with using any FP > instructions at all. If a hardware interrupt handler does that, it needs > to save and restore the FPU state (with FNSAVE/FRSTOR instructions), or > else the foreground program might produce erroneous results, if it also > uses FP instructions. Thanks for this important clarification. Grendel Hi, I'm a signature virus. plz set me as your signature and help me spread :)