1 * $NetBSD: sasin.sa,v 1.2 1994/10/26 07:49:29 cgd Exp $
3 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 * M68000 Hi-Performance Microprocessor Division
5 * M68040 Software Package
7 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
10 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 * To the maximum extent permitted by applicable law,
12 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 * PARTICULAR PURPOSE and any warranty against infringement with
15 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 * and any accompanying written materials.
18 * To the maximum extent permitted by applicable law,
19 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 * and support of the SOFTWARE.
26 * You are hereby granted a copyright license to use, modify, and
27 * distribute the SOFTWARE so long as this entire notice is retained
28 * without alteration in any modified and/or redistributed versions,
29 * and that such modified versions are clearly identified as such.
30 * No licenses are granted by implication, estoppel or otherwise
31 * under any patents or trademarks of Motorola, Inc.
34 * sasin.sa 3.3 12/19/90
36 * Description: The entry point sAsin computes the inverse sine of
37 * an input argument; sAsind does the same except for denormalized
40 * Input: Double-extended number X in location pointed to
41 * by address register a0.
43 * Output: The value arcsin(X) returned in floating-point register Fp0.
45 * Accuracy and Monotonicity: The returned result is within 3 ulps in
46 * 64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
47 * result is subsequently rounded to double precision. The
48 * result is provably monotonic in double precision.
50 * Speed: The program sASIN takes approximately 310 cycles.
55 * 1. If |X| >= 1, go to 3.
57 * 2. (|X| < 1) Calculate asin(X) by
58 * z := sqrt( [1-X][1+X] )
59 * asin(X) = atan( x / z ).
62 * 3. If |X| > 1, go to 5.
64 * 4. (|X| = 1) sgn := sign(X), return asin(X) := sgn * Pi/2. Exit.
66 * 5. (|X| > 1) Generate an invalid operation by 0 * infinity.
70 SASIN IDNT 2,1 Motorola 040 Floating Point Software Package
74 PIBY2 DC.L $3FFF0000,$C90FDAA2,$2168C235,$00000000
83 *--ASIN(X) = X FOR DENORMALIZED X
89 FMOVE.X (a0),FP0 ...LOAD INPUT
97 *--THIS IS THE USUAL CASE, |X| < 1
98 *--ASIN(X) = ATAN( X / SQRT( (1-X)(1+X) ) )
100 FMOVE.S #:3F800000,FP1
101 FSUB.X FP0,FP1 ...1-X
103 FMOVE.S #:3F800000,FP2
104 FADD.X FP0,FP2 ...1+X
105 FMUL.X FP2,FP1 ...(1+X)(1-X)
107 FSQRT.X FP1 ...SQRT([1-X][1+X])
108 FDIV.X FP1,FP0 ...X/SQRT([1-X][1+X])
115 FCMP.S #:3F800000,FP0
116 fbgt t_operr ;cause an operr exception
118 *--|X| = 1, ASIN(X) = +- PI/2.
122 ANDI.L #$80000000,D0 ...SIGN BIT OF X
123 ORI.L #$3F800000,D0 ...+-1 IN SGL FORMAT
124 MOVE.L D0,-(sp) ...push SIGN(X) IN SGL-FMT