Home | History | Annotate | Line # | Download | only in fpsp
satanh.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 *	satanh.sa 3.3 12/19/90
     33 *
     34 *	The entry point satanh computes the inverse
     35 *	hyperbolic tangent of
     36 *	an input argument; satanhd does the same except for denormalized
     37 *	input.
     38 *
     39 *	Input: Double-extended number X in location pointed to
     40 *		by address register a0.
     41 *
     42 *	Output: The value arctanh(X) returned in floating-point register Fp0.
     43 *
     44 *	Accuracy and Monotonicity: The returned result is within 3 ulps in
     45 *		64 significant bit, i.e. within 0.5001 ulp to 53 bits if the
     46 *		result is subsequently rounded to double precision. The 
     47 *		result is provably monotonic in double precision.
     48 *
     49 *	Speed: The program satanh takes approximately 270 cycles.
     50 *
     51 *	Algorithm:
     52 *
     53 *	ATANH
     54 *	1. If |X| >= 1, go to 3.
     55 *
     56 *	2. (|X| < 1) Calculate atanh(X) by
     57 *		sgn := sign(X)
     58 *		y := |X|
     59 *		z := 2y/(1-y)
     60 *		atanh(X) := sgn * (1/2) * logp1(z)
     61 *		Exit.
     62 *
     63 *	3. If |X| > 1, go to 5.
     64 *
     65 *	4. (|X| = 1) Generate infinity with an appropriate sign and
     66 *		divide-by-zero by	
     67 *		sgn := sign(X)
     68 *		atan(X) := sgn / (+0).
     69 *		Exit.
     70 *
     71 *	5. (|X| > 1) Generate an invalid operation by 0 * infinity.
     72 *		Exit.
     73 *
     74 
     75 satanh	IDNT	2,1 Motorola 040 Floating Point Software Package
     76 
     77 	section	8
     78 
     79 	xref	t_dz
     80 	xref	t_operr
     81 	xref	t_frcinx
     82 	xref	t_extdnrm
     83 	xref	slognp1
     84 
     85 	xdef	satanhd
     86 satanhd:
     87 *--ATANH(X) = X FOR DENORMALIZED X
     88 
     89 	bra		t_extdnrm
     90 
     91 	xdef	satanh
     92 satanh:
     93 	move.l		(a0),d0
     94 	move.w		4(a0),d0
     95 	ANDI.L		#$7FFFFFFF,D0
     96 	CMPI.L		#$3FFF8000,D0
     97 	BGE.B		ATANHBIG
     98 
     99 *--THIS IS THE USUAL CASE, |X| < 1
    100 *--Y = |X|, Z = 2Y/(1-Y), ATANH(X) = SIGN(X) * (1/2) * LOG1P(Z).
    101 
    102 	FABS.X		(a0),FP0	...Y = |X|
    103 	FMOVE.X		FP0,FP1
    104 	FNEG.X		FP1		...-Y
    105 	FADD.X		FP0,FP0		...2Y
    106 	FADD.S		#:3F800000,FP1	...1-Y
    107 	FDIV.X		FP1,FP0		...2Y/(1-Y)
    108 	move.l		(a0),d0
    109 	ANDI.L		#$80000000,D0
    110 	ORI.L		#$3F000000,D0	...SIGN(X)*HALF
    111 	move.l		d0,-(sp)
    112 
    113 	fmovem.x	fp0,(a0)	...overwrite input
    114 	move.l		d1,-(sp)
    115 	clr.l		d1
    116 	bsr		slognp1		...LOG1P(Z)
    117 	fmove.l		(sp)+,fpcr
    118 	FMUL.S		(sp)+,FP0
    119 	bra		t_frcinx
    120 
    121 ATANHBIG:
    122 	FABS.X		(a0),FP0	...|X|
    123 	FCMP.S		#:3F800000,FP0
    124 	fbgt		t_operr
    125 	bra		t_dz
    126 
    127 	end
    128