Mail Archives: djgpp/2000/04/02/12:11:05
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.
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.
The DJGPP wrappers don't save the FPU context (and neither do other DOS
compilers which support the interrupt keyword, AFAIK), so the handler
typically must do it.
- Raw text -