Home | History | Annotate | Line # | Download | only in fpsp
sasin.sa revision 1.1
      1 *	MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
      2 *	M68000 Hi-Performance Microprocessor Division
      3 *	M68040 Software Package 
      4 *
      5 *	M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
      6 *	All rights reserved.
      7 *
      8 *	THE SOFTWARE is provided on an "AS IS" basis and without warranty.
      9 *	To the maximum extent permitted by applicable law,
     10 *	MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
     11 *	INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
     12 *	PARTICULAR PURPOSE and any warranty against infringement with
     13 *	regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
     14 *	and any accompanying written materials. 
     15 *
     16 *	To the maximum extent permitted by applicable law,
     17 *	IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
     18 *	(INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
     19 *	PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
     20 *	OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
     21 *	SOFTWARE.  Motorola assumes no responsibility for the maintenance
     22 *	and support of the SOFTWARE.  
     23 *
     24 *	You are hereby granted a copyright license to use, modify, and
     25 *	distribute the SOFTWARE so long as this entire notice is retained
     26 *	without alteration in any modified and/or redistributed versions,
     27 *	and that such modified versions are clearly identified as such.
     28 *	No licenses are granted by implication, estoppel or otherwise
     29 *	under any patents or trademarks of Motorola, Inc.
     30 
     31 *
     32 *	sasin.sa 3.3 12/19/90
     33 *
     34 *	Description: The entry point sAsin computes the inverse sine of
     35 *		an input argument; sAsind does the same except for denormalized
     36 *		input.
     37 *
     38 *	Input: Double-extended number X in location pointed to
     39 *		by address register a0.
     40 *
     41 *	Output: The value arcsin(X) returned in floating-point register Fp0.
     42 *
     43 *	Accuracy and Monotonicity: The returned result is within 3 ulps in
     44 *		64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
     45 *		result is subsequently rounded to double precision. The 
     46 *		result is provably monotonic in double precision.
     47 *
     48 *	Speed: The program sASIN takes approximately 310 cycles.
     49 *
     50 *	Algorithm:
     51 *
     52 *	ASIN
     53 *	1. If |X| >= 1, go to 3.
     54 *
     55 *	2. (|X| < 1) Calculate asin(X) by
     56 *		z := sqrt( [1-X][1+X] )
     57 *		asin(X) = atan( x / z ).
     58 *		Exit.
     59 *
     60 *	3. If |X| > 1, go to 5.
     61 *
     62 *	4. (|X| = 1) sgn := sign(X), return asin(X) := sgn * Pi/2. Exit.
     63 *
     64 *	5. (|X| > 1) Generate an invalid operation by 0 * infinity.
     65 *		Exit.
     66 *
     67 
     68 SASIN	IDNT	2,1 Motorola 040 Floating Point Software Package
     69 
     70 	section	8
     71 
     72 PIBY2	DC.L $3FFF0000,$C90FDAA2,$2168C235,$00000000
     73 
     74 	xref	t_operr
     75 	xref	t_frcinx
     76 	xref	t_extdnrm
     77 	xref	satan
     78 
     79 	xdef	sasind
     80 sasind:
     81 *--ASIN(X) = X FOR DENORMALIZED X
     82 
     83 	bra		t_extdnrm
     84 
     85 	xdef	sasin
     86 sasin:
     87 	FMOVE.X		(a0),FP0	...LOAD INPUT
     88 
     89 	move.l		(a0),d0
     90 	move.w		4(a0),d0
     91 	ANDI.L		#$7FFFFFFF,D0
     92 	CMPI.L		#$3FFF8000,D0
     93 	BGE.B		asinbig
     94 
     95 *--THIS IS THE USUAL CASE, |X| < 1
     96 *--ASIN(X) = ATAN( X / SQRT( (1-X)(1+X) ) )
     97 
     98 	FMOVE.S		#:3F800000,FP1
     99 	FSUB.X		FP0,FP1		...1-X
    100 	fmovem.x	fp2,-(a7)
    101 	FMOVE.S		#:3F800000,FP2
    102 	FADD.X		FP0,FP2		...1+X
    103 	FMUL.X		FP2,FP1		...(1+X)(1-X)
    104 	fmovem.x	(a7)+,fp2
    105 	FSQRT.X		FP1		...SQRT([1-X][1+X])
    106 	FDIV.X		FP1,FP0	 	...X/SQRT([1-X][1+X])
    107 	fmovem.x	fp0,(a0)
    108 	bsr		satan
    109 	bra		t_frcinx
    110 
    111 asinbig:
    112 	FABS.X		FP0	 ...|X|
    113 	FCMP.S		#:3F800000,FP0
    114 	fbgt		t_operr		;cause an operr exception
    115 
    116 *--|X| = 1, ASIN(X) = +- PI/2.
    117 
    118 	FMOVE.X		PIBY2,FP0
    119 	move.l		(a0),d0
    120 	ANDI.L		#$80000000,D0	...SIGN BIT OF X
    121 	ORI.L		#$3F800000,D0	...+-1 IN SGL FORMAT
    122 	MOVE.L		D0,-(sp)	...push SIGN(X) IN SGL-FMT
    123 	FMOVE.L		d1,FPCR		
    124 	FMUL.S		(sp)+,FP0
    125 	bra		t_frcinx
    126 
    127 	end
    128