2005-04-17 02:20:36 +04:00
|
| satanh. s a 3 . 3 1 2 / 1 9 / 9 0
|
| The e n t r y p o i n t s a t a n h c o m p u t e s t h e i n v e r s e
| hyperbolic t a n g e n t o f
| an i n p u t a r g u m e n t ; satanhd does the same except for denormalized
| input.
|
| Input : Double- e x t e n d e d n u m b e r X i n l o c a t i o n p o i n t e d t o
| by a d d r e s s r e g i s t e r a0 .
|
| Output : The v a l u e a r c t a n h ( X ) r e t u r n e d i n f l o a t i n g - p o i n t r e g i s t e r F p0 .
|
| Accuracy a n d M o n o t o n i c i t y : T h e r e t u r n e d r e s u l t i s w i t h i n 3 u l p s i n
| 6 4 significant b i t , i . e . w i t h i n 0 . 5 0 0 1 u l p t o 5 3 b i t s i f t h e
| result i s s u b s e q u e n t l y r o u n d e d t o d o u b l e p r e c i s i o n . T h e
| result i s p r o v a b l y m o n o t o n i c i n d o u b l e p r e c i s i o n .
|
| Speed : The p r o g r a m s a t a n h t a k e s a p p r o x i m a t e l y 2 7 0 c y c l e s .
|
| Algorithm :
|
| ATANH
| 1 . If | X | > = 1 , g o t o 3 .
|
| 2 . ( | X| < 1 ) C a l c u l a t e a t a n h ( X ) b y
| sgn : = s i g n ( X )
| y : = | X |
| z : = 2 y / ( 1 - y )
| atanh( X ) : = s g n * ( 1 / 2 ) * l o g p1 ( z )
| Exit.
|
| 3 . If | X | > 1 , g o t o 5 .
|
| 4 . ( | X| = 1 ) G e n e r a t e i n f i n i t y w i t h a n a p p r o p r i a t e s i g n a n d
| divide- b y - z e r o b y
| sgn : = s i g n ( X )
| atan( X ) : = s g n / ( + 0 ) .
| Exit.
|
| 5 . ( | X| > 1 ) G e n e r a t e a n i n v a l i d o p e r a t i o n b y 0 * i n f i n i t y .
| Exit.
|
| Copyright ( C ) M o t o r o l a , I n c . 1 9 9 0
| All R i g h t s R e s e r v e d
|
2006-02-12 04:55:48 +03:00
| For d e t a i l s o n t h e l i c e n s e f o r t h i s f i l e , p l e a s e s e e t h e
| file, R E A D M E , i n t h i s s a m e d i r e c t o r y .
2005-04-17 02:20:36 +04:00
| satanh i d n t 2 ,1 | M o t o r o l a 0 4 0 F l o a t i n g P o i n t S o f t w a r e P a c k a g e
| section 8
| xref t _ d z
| xref t _ o p e r r
| xref t _ f r c i n x
| xref t _ e x t d n r m
| xref s l o g n p1
.global satanhd
satanhd :
| - - ATANH( X ) = X F O R D E N O R M A L I Z E D X
bra t _ e x t d n r m
.global satanh
satanh :
movel ( % a0 ) ,% d0
movew 4 ( % a0 ) ,% d0
andil #0x7FFFFFFF ,% d0
cmpil #0x3FFF8000 ,% d0
bges A T A N H B I G
| - - THIS I S T H E U S U A L C A S E , | X | < 1
| - - Y = | X | , Z = 2 Y / ( 1 - Y ) , A T A N H ( X ) = S I G N ( X ) * ( 1 / 2 ) * L O G 1 P ( Z ) .
fabsx ( % a0 ) ,% f p0 | . . . Y = | X |
fmovex % f p0 ,% f p1
fnegx % f p1 | . . . - Y
faddx % f p0 ,% f p0 | . . . 2 Y
fadds #0x3F800000 ,% f p1 | . . . 1 - Y
fdivx % f p1 ,% f p0 | . . . 2 Y / ( 1 - Y )
movel ( % a0 ) ,% d0
andil #0x80000000 ,% d0
oril #0x3F000000 ,% d0 | . . . S I G N ( X ) * H A L F
movel % d0 ,- ( % s p )
fmovemx % f p0 - % f p0 ,( % a0 ) | . . . o v e r w r i t e i n p u t
movel % d1 ,- ( % s p )
clrl % d1
bsr s l o g n p1 | . . . L O G 1 P ( Z )
fmovel ( % s p ) + ,% f p c r
fmuls ( % s p ) + ,% f p0
bra t _ f r c i n x
ATANHBIG :
fabsx ( % a0 ) ,% f p0 | . . . | X |
fcmps #0x3F800000 ,% f p0
fbgt t _ o p e r r
bra t _ d z
| end