2005-04-16 15:20:36 -07:00
|
| ssinh. s a 3 . 1 1 2 / 1 0 / 9 0
|
| The e n t r y p o i n t s S i n h c o m p u t e s t h e h y p e r b o l i c s i n e o f
| an i n p u t a r g u m e n t ; sSinhd 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 s i 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 S I N H t a k e s a p p r o x i m a t e l y 2 8 0 c y c l e s .
|
| Algorithm :
|
| SINH
| 1 . If | X | > 1 6 3 8 0 l o g 2 , g o t o 3 .
|
| 2 . ( | X| < = 1 6 3 8 0 l o g 2 ) S i n h ( X ) i s o b t a i n e d b y t h e f o r m u l a e
| y = | X | , s g n = s i g n ( X ) , a n d z = e x p m 1 ( Y ) ,
| sinh( X ) = s g n * ( 1 / 2 ) * ( z + z / ( 1 + z ) ) .
| Exit.
|
| 3 . If | X | > 1 6 4 8 0 l o g 2 , g o t o 5 .
|
| 4 . ( 1 6 3 8 0 log2 < | X | < = 1 6 4 8 0 l o g 2 )
| sinh( X ) = s i g n ( X ) * e x p ( | X | ) / 2 .
| However, i n v o k i n g e x p ( | X | ) m a y c a u s e p r e m a t u r e o v e r f l o w .
| Thus, w e c a l c u l a t e s i n h ( X ) a s f o l l o w s :
| Y : = | X |
| sgn : = s i g n ( X )
| sgnFact : = s g n * 2 * * ( 1 6 3 8 0 )
| Y' : = Y - 1 6 3 8 1 l o g 2
| sinh( X ) : = s g n F a c t * e x p ( Y ' ) .
| Exit.
|
| 5 . ( | X| > 1 6 4 8 0 l o g 2 ) s i n h ( X ) m u s t o v e r f l o w . R e t u r n
| sign( X ) * H u g e * H u g e t o g e n e r a t e o v e r f l o w a n d a n i n f i n i t y w i t h
| the a p p r o p r i a t e s i g n . H u g e i s t h e l a r g e s t f i n i t e n u m b e r i n
| extended f o r m a t . E x i t .
|
| 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-11 17:55:48 -08: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-16 15:20:36 -07:00
| SSINH 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
T1 : .long 0x40C62D38 , 0 xD3 D 6 4 6 3 4 | . . . 1 6 3 8 1 L O G 2 L E A D
T2 : .long 0x3D6F90AE , 0 xB1 E 7 5 C C 7 | . . . 1 6 3 8 1 L O G 2 T R A I L
| xref t _ f r c i n x
| xref t _ o v f l
| xref t _ e x t d n r m
| xref s e t o x
| xref s e t o x m 1
.global ssinhd
ssinhd :
| - - SINH( 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 ssinh
ssinh :
fmovex ( % a0 ) ,% f p0 | . . . L O A D I N P U T
movel ( % a0 ) ,% d0
movew 4 ( % a0 ) ,% d0
movel % d0 ,% a1 | s a v e a c o p y o f o r i g i n a l ( c o m p a c t e d ) o p e r a n d
andl #0x7FFFFFFF ,% d0
cmpl #0x400CB167 ,% d0
bgts S I N H B I G
| - - THIS I S T H E U S U A L C A S E , | X | < 1 6 3 8 0 L O G 2
| - - Y = | X | , Z = E X P M 1 ( Y ) , S I N H ( X ) = S I G N ( X ) * ( 1 / 2 ) * ( Z + Z / ( 1 + Z ) )
fabsx % f p0 | . . . Y = | X |
moveml % a1 / % d1 ,- ( % s p )
fmovemx % f p0 - % f p0 ,( % a0 )
clrl % d1
bsr s e t o x m 1 | . . . F P 0 I S Z = E X P M 1 ( Y )
fmovel #0 ,% f p c r
moveml ( % s p ) + ,% a1 / % d1
fmovex % f p0 ,% f p1
fadds #0x3F800000 ,% f p1 | . . . 1 + Z
fmovex % f p0 ,- ( % s p )
fdivx % f p1 ,% f p0 | . . . Z / ( 1 + Z )
movel % a1 ,% d0
andl #0x80000000 ,% d0
orl #0x3F000000 ,% d0
faddx ( % s p ) + ,% f p0
movel % d0 ,- ( % s p )
fmovel % d1 ,% f p c r
fmuls ( % s p ) + ,% f p0 | l a s t f p i n s t - p o s s i b l e e x c e p t i o n s s e t
bra t _ f r c i n x
SINHBIG :
cmpl #0x400CB2B3 ,% d0
bgt t _ o v f l
fabsx % f p0
fsubd T 1 ( % p c ) ,% f p0 | . . . ( | X | - 1 6 3 8 1 L O G 2 _ L E A D )
movel #0 ,- ( % s p )
movel #0x80000000 ,- ( % s p )
movel % a1 ,% d0
andl #0x80000000 ,% d0
orl #0x7FFB0000 ,% d0
movel % d0 ,- ( % s p ) | . . . E X T E N D E D F M T
fsubd T 2 ( % p c ) ,% f p0 | . . . | X | - 1 6 3 8 1 L O G 2 , A C C U R A T E
movel % d1 ,- ( % s p )
clrl % d1
fmovemx % f p0 - % f p0 ,( % a0 )
bsr s e t o x
fmovel ( % s p ) + ,% f p c r
fmulx ( % s p ) + ,% f p0 | p o s s i b l e e x c e p t i o n
bra t _ f r c i n x
| end