This is the miscellaneous floating point package. This contains some important floating point routines that are missing from the vxWorks libraries mathALib and fppLib. D'Anne Thompson National Optical Astronomy Observatories P.O. Box 26732 Tucson, AZ 85726 (602)325-9335 dat@noao.edu {...}!uunet!noao.edu!dat -----------------SHAR ARCHIVE FOLLOWS-------------------------------- #!/bin/sh cat >Makefile <<'------ EOF ------' # Support for '.s' files run through the C pre-processor. .SUFFIXES : .lint .s .c .s.o : @/bin/rm -f $@ $(ASM_P1) $< >tmp.c $(CC) -E $(INCLUDES) -DASMLANGUAGE tmp.c >tmp.i $(ASM_P2) tmp.i >tmp.s $(AS) -o $@ tmp.s @/bin/rm -f tmp.c tmp.i tmp.s VW = /vw ASM_P1 = cat ASM_P2 = cat AS = as INCLUDES = -I$(VW)/h OBJS = fmisc.o all : $(OBJS) docs docs : .docs .docs : fmisc.s $(VW)/bin/mangen $(VW)/bin/msplit $(VW)/bin/xp mangen -n lib fmisc.s mv mg.out fmisc.nr msplit -s .nr file.names nroff -mangen `sort file.names` | lpr /bin/rm -f file.names shar : fmisc.shar.Z fmisc.shar.Z : Makefile fmisc.s .docs /bin/rm -f fmisc.shar.Z shar -v -o fmisc.shar Makefile fmisc.s *.nr compress -v fmisc.shar clean : /bin/rm -f *.o core a.out *.nr .docs *.shar* ------ EOF ------ ls -l Makefile cat >fmisc.s <<'------ EOF ------' /* fmisc.s - miscellaneous floating point support */ /* written by, D'Anne Thompson National Optical Astronomy Observatories, P.O. Box 26732 Tucson, AZ 85726 (602) 325-9335 dat@noao.edu {...}!uunet!noao.edu!dat */ /* modification history -------------------- 01a 25may89,dat - prepared for archive export */ /* DESCRIPTION This library provides miscellaneous floating point support not provided by the Wind River library modules mathALib and fppLib. The code of this module is specific to the MC68881 and MC68882 floating point coprocessors. The functionality provided is universal to applications requiring floating point support. These routines are all provided in assembly language. The format is that of the Sun Microsystems assembler system. */ #ifdef ASMLANGUAGE /********************************************************** * * atan2 - compute arctangent of cartesian data pair * * Computes the arctangent of an input cartesian coordinate pair. * The output is normalized in the range from -pi to +pi. */ /* double atan2 (y,x) double y; /* y component * double x; /* x component * */ .data .text .proc .globl _atan2 _atan2: link a6,#0 fmovem fp6/fp7,sp@- fmoved a6@(0x08),fp7 /* fp7 = y */ fmoved a6@(0x10),fp6 /* fp6 = x */ fdivx fp6,fp7 /* fp7 = y/x */ fatanx fp7,fp7 /* fp7 = atan(y/x) */ ftstx fp6 fbge L002 fmovecrx #0,fp6 /* fp6 = pi */ ftstx fp7 fblt L001 fnegx fp6,fp6 L001: faddx fp6,fp7 /* fp7 = atan(y/x) +/- pi */ L002: fmoved fp7,sp@- movel sp@+,d0 movel sp@+,d1 fmovem sp@+,fp6/fp7 unlk a6 rts /*************************************************************** * * sincos - compute both sine and cosine of an angle * * Simultaneous computation of both sin and cosine values. * Using sincos is very much faster than separate calls to * sin and cos. */ /* VOID sincos (rads, pSin, pCos) double rads; /* input angle * double *pSin; /* ptr to sin result * double *pCos; /* ptr to cos result * */ .globl _sincos _sincos: link a6,#0 fmovem fp6/fp7,sp@- fsincosd a6@(0x8),fp6:fp7 /* fp6 = cos, fp7 = sin */ fmoved fp6,sp@- movel a6@(0x14),a0 /* store cos */ movel sp@+,a0@+ movel sp@+,a0@ fmoved fp7,sp@- /* store sin */ movel a6@(0x10),a0 movel sp@+,a0@+ movel sp@+,a0@ fmovem sp@+,fp6/fp7 clrl d0 unlk a6 rts /***************************************************************** * * fppReset - reset floating point processor to null state * * The floating point coprocessor is placed into the null state. * This speeds up context switching greatly for tasks that only * use the coprocessor occasionally. If the coprocessor is in * the null state, the floating pointer registers and internal * state information are not saved/restored when switching from/to * the current task. */ /* VOID fppReset () */ .globl _fppReset _fppReset: link a6,#0 frestore L003 clrl d0 unlk a6 rts .data L003: .long 0 /* A 'null' state frame */ /***************************************************************** * * floor - round towards minus infinity * * Rounds the input argument to an integer value less than or equal * to the original. Rounding is done towards minus infinity. * * Standard 'C' conversion from float to integer is done by * rounding towards zero (truncation). */ /* double floor (dbl) double dbl; /* input argument * */ .globl _floor _floor: link a6,#0 fmovex fp7,sp@- fmovel fpcr,d1 movl d1,d0 andb #0xcf,d0 orb #0x20,d0 /* round to minus infinity */ fmovel d0,fpcr fintd a6@(0x8),fp7 fmoved fp7,sp@- fmovel d1,fpcr /* restore old rounding mode */ movl sp@+,d0 movl sp@+,d1 fmovex sp@+,fp7 unlk a6 rts /***************************************************************** * * anint - round towards nearest integer * * This routine rounds towards the nearest integer * (normal mathematical rounding). * The name anint is from the new POSIX standard. * * Standard 'C' conversion from float to integer is done by * rounding towards zero (truncation). */ /* double anint (dval) double dval; /* input value * */ .globl _anint _anint: link a6,#0 fmovex fp7,sp@- fmovel fpcr,d1 movl d1,d0 andb #0xcf,d0 /* 00 = round to nearest */ fmovel d0,fpcr fintd a6@(0x8),fp7 fmoved fp7,sp@- fmovel d1,fpcr /* restore old rounding mode */ movl sp@+,d0 movl sp@+,d1 fmovex sp@+,fp7 unlk a6 rts /***************************************************************** * * ceil - round towards positive infinity * * Rounds the input argument to an integer value greater than or equal * to the original. Rounding is done towards positive infinity. * * Standard 'C' conversion from float to integer is done by * rounding towards zero (truncation). */ /* double ceil (dval) double dval; /* input argument * */ .globl _ceil _ceil: link a6,#0 fmovex fp7,sp@- fmovel fpcr,d1 movl d1,d0 andb #0xcf,d0 orb #0x30,d0 /* round to plus infinity */ fmovel d0,fpcr fintd a6@(0x8),fp7 fmoved fp7,sp@- fmovel d1,fpcr /* restore old rounding mode */ movl sp@+,d0 movl sp@+,d1 fmovex sp@+,fp7 unlk a6 rts /***************************************************************** * * piTimes - pi multiplied by a value * * This routine returns pi multiplied by some value, in the greatest * possible precision. * * This routine takes advantage of the MC68881 and MC68882 coprocessors * internal extended precision representation of pi. * It is more accurate than any compiled representation of pi. */ /* double piTimes (dval) double dval; /* multiplier value * */ .globl _piTimes _piTimes: link a6,#0 fmovex fp7,sp@- /* save fp7 */ fmovecrx #0,fp7 /* fp7 = pi */ fmuld a6@(0x8),fp7 /* fp7 = n * pi */ fmoved fp7,sp@- movl sp@+,d0 movl sp@+,d1 fmovex sp@+,fp7 /* restore fp7 */ unlk a6 rts #endif /*ASMLANGUAGE*/ ------ EOF ------ ls -l fmisc.s cat >anint.nr <<'------ EOF ------' .TH anint 2 "" "VxWorks Reference Manual" .ad b .SH NAME anint - round towards nearest integer .SH SYNOPSIS .CS .nf double anint (dval) double dval; /* input value * .fi .CE .SH DESCRIPTION This routine rounds towards the nearest integer (normal mathematical rounding). The name anint is from the new POSIX standard. Standard 'C' conversion from float to integer is done by rounding towards zero (truncation). .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l anint.nr cat >atan2.nr <<'------ EOF ------' .TH atan2 2 "" "VxWorks Reference Manual" .ad b .SH NAME atan2 - compute arctangent of cartesian data pair .SH SYNOPSIS .CS .nf double atan2 (y,x) double y; /* y component * double x; /* x component * .fi .CE .SH DESCRIPTION Computes the arctangent of an input cartesian coordinate pair. The output is normalized in the range from -pi to +pi. .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l atan2.nr cat >ceil.nr <<'------ EOF ------' .TH ceil 2 "" "VxWorks Reference Manual" .ad b .SH NAME ceil - round towards positive infinity .SH SYNOPSIS .CS .nf double ceil (dval) double dval; /* input argument * .fi .CE .SH DESCRIPTION Rounds the input argument to an integer value greater than or equal to the original. Rounding is done towards positive infinity. Standard 'C' conversion from float to integer is done by rounding towards zero (truncation). .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l ceil.nr cat >floor.nr <<'------ EOF ------' .TH floor 2 "" "VxWorks Reference Manual" .ad b .SH NAME floor - round towards minus infinity .SH SYNOPSIS .CS .nf double floor (dbl) double dbl; /* input argument * .fi .CE .SH DESCRIPTION Rounds the input argument to an integer value less than or equal to the original. Rounding is done towards minus infinity. Standard 'C' conversion from float to integer is done by rounding towards zero (truncation). .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l floor.nr cat >fmisc.nr <<'------ EOF ------' .TH fmisc 1 "" "VxWorks Reference Manual" .ad b .SH NAME fmisc.s - miscellaneous floating point support .SH SYNOPSIS .nf atan2 - compute arctangent of cartesian data pair sincos - compute both sine and cosine of an angle fppReset - reset floating point processor to null state floor - round towards minus infinity anint - round towards nearest integer ceil - round towards positive infinity piTimes - pi multiplied by a value double atan2 (y,x) VOID sincos (rads, pSin, pCos) VOID fppReset () double floor (dbl) double anint (dval) double ceil (dval) double piTimes (dval) .fi .SH DESCRIPTION This library provides miscellaneous floating point support not provided by the Wind River library modules mathALib and fppLib. The code of this module is specific to the MC68881 and MC68882 floating point coprocessors. The functionality provided is universal to applications requiring floating point support. These routines are all provided in assembly language. The format is that of the Sun Microsystems assembler system. ------ EOF ------ ls -l fmisc.nr cat >fppReset.nr <<'------ EOF ------' .TH fppReset 2 "" "VxWorks Reference Manual" .ad b .SH NAME fppReset - reset floating point processor to null state .SH SYNOPSIS .CS .nf VOID fppReset () .fi .CE .SH DESCRIPTION The floating point coprocessor is placed into the null state. This speeds up context switching greatly for tasks that only use the coprocessor occasionally. If the coprocessor is in the null state, the floating pointer registers and internal state information are not saved/restored when switching from/to the current task. .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l fppReset.nr cat >piTimes.nr <<'------ EOF ------' .TH piTimes 2 "" "VxWorks Reference Manual" .ad b .SH NAME piTimes - pi multiplied by a value .SH SYNOPSIS .CS .nf double piTimes (dval) double dval; /* multiplier value * .fi .CE .SH DESCRIPTION This routine returns pi multiplied by some value, in the greatest possible precision. This routine takes advantage of the MC68881 and MC68882 coprocessors internal extended precision representation of pi. It is more accurate than any compiled representation of pi. .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l piTimes.nr cat >sincos.nr <<'------ EOF ------' .TH sincos 2 "" "VxWorks Reference Manual" .ad b .SH NAME sincos - compute both sine and cosine of an angle .SH SYNOPSIS .CS .nf VOID sincos (rads, pSin, pCos) double rads; /* input angle * double *pSin; /* ptr to sin result * double *pCos; /* ptr to cos result * .fi .CE .SH DESCRIPTION Simultaneous computation of both sin and cosine values. Using sincos is very much faster than separate calls to sin and cos. .SH SEE ALSO fmisc(1) ------ EOF ------ ls -l sincos.nr