2005-04-17 02:20:36 +04:00
|
| sasin. s a 3 . 3 1 2 / 1 9 / 9 0
|
| Description : The e n t r y p o i n t s A s i n c o m p u t e s t h e i n v e r s e s i n e o f
| an i n p u t a r g u m e n t ; sAsind 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 s i n ( 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 S I N t a k e s a p p r o x i m a t e l y 3 1 0 c y c l e s .
|
| Algorithm :
|
| ASIN
| 1 . If | X | > = 1 , g o t o 3 .
|
| 2 . ( | X| < 1 ) C a l c u l a t e a s i n ( X ) b y
| z : = s q r t ( [ 1 - X ] [ 1 + X ] )
| asin( X ) = a t a n ( x / z ) .
| Exit.
|
| 3 . If | X | > 1 , g o t o 5 .
|
| 4 . ( | X| = 1 ) s g n : = s i g n ( X ) , r e t u r n a s i n ( X ) : = s g n * P i / 2 . E x i t .
|
| 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
| SASIN 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
PIBY2 : .long 0x3FFF0000 , 0 xC9 0 F D A A 2 ,0 x21 6 8 C 2 3 5 ,0 x00 0 0 0 0 0 0
| 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 a t a n
.global sasind
sasind :
| - - ASIN( 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 sasin
sasin :
fmovex ( % a0 ) ,% f p0 | . . . L O A D I N P U T
movel ( % a0 ) ,% d0
movew 4 ( % a0 ) ,% d0
andil #0x7FFFFFFF ,% d0
cmpil #0x3FFF8000 ,% d0
bges a s i n b i g
| - - THIS I S T H E U S U A L C A S E , | X | < 1
| - - ASIN( X ) = A T A N ( X / S Q R T ( ( 1 - X ) ( 1 + X ) ) )
fmoves #0x3F800000 ,% f p1
fsubx % f p0 ,% f p1 | . . . 1 - X
fmovemx % f p2 - % f p2 ,- ( % a7 )
fmoves #0x3F800000 ,% f p2
faddx % f p0 ,% f p2 | . . . 1 + X
fmulx % f p2 ,% f p1 | . . . ( 1 + X ) ( 1 - X )
fmovemx ( % a7 ) + ,% f p2 - % f p2
fsqrtx % f p1 | . . . S Q R T ( [ 1 - X ] [ 1 + X ] )
fdivx % f p1 ,% f p0 | . . . X / S Q R T ( [ 1 - X ] [ 1 + X ] )
fmovemx % f p0 - % f p0 ,( % a0 )
bsr s a t a n
bra t _ f r c i n x
asinbig :
fabsx % f p0 | . . . | X |
fcmps #0x3F800000 ,% f p0
fbgt t _ o p e r r | c a u s e a n o p e r r e x c e p t i o n
| - - | X| = 1 , A S I N ( X ) = + - P I / 2 .
fmovex P I B Y 2 ,% f p0
movel ( % a0 ) ,% d0
andil #0x80000000 ,% d0 | . . . S I G N B I T O F X
oril #0x3F800000 ,% d0 | . . . + - 1 I N S G L F O R M A T
movel % d0 ,- ( % s p ) | . . . p u s h S I G N ( X ) I N S G L - F M T
fmovel % d1 ,% F P C R
fmuls ( % s p ) + ,% f p0
bra t _ f r c i n x
| end