2005-04-17 02:20:36 +04:00
|
| slogn. s a 3 . 1 1 2 / 1 0 / 9 0
|
| slogn c o m p u t e s t h e n a t u r a l l o g a r i t h m o f a n
| input v a l u e . s l o g n d d o e s t h e s a m e e x c e p t t h e i n p u t v a l u e i s a
| denormalized n u m b e r . s l o g n p1 c o m p u t e s l o g ( 1 + X ) , a n d s l o g n p1 d
| computes l o g ( 1 + X ) f o r d e n o r m a l i z e d X .
|
| Input : Double- e x t e n d e d v a l u e i n m e m o r y l o c a t i o n p o i n t e d t o b y a d d r e s s
| register a0 .
|
| Output : log( X ) o r l o g ( 1 + 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 2 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 l o g n t a k e s a p p r o x i m a t e l y 1 9 0 c y c l e s f o r i n p u t
| argument X s u c h t h a t | X - 1 | > = 1 / 1 6 , w h i c h i s t h e u s u a l
| situation. F o r t h o s e a r g u m e n t s , s l o g n p1 t a k e s a p p r o x i m a t e l y
| 2 1 0 cycles. F o r t h e l e s s c o m m o n a r g u m e n t s , t h e p r o g r a m w i l l
| run n o w o r s e t h a n 1 0 % s l o w e r .
|
| Algorithm :
| LOGN :
| Step 1 . I f | X - 1 | < 1 / 1 6 , a p p r o x i m a t e l o g ( X ) b y a n o d d p o l y n o m i a l i n
| u, w h e r e u = 2 ( X - 1 ) / ( X + 1 ) . O t h e r w i s e , m o v e o n t o S t e p 2 .
|
| Step 2 . X = 2 * * k * Y w h e r e 1 < = Y < 2 . D e f i n e F t o b e t h e f i r s t s e v e n
| significant b i t s o f Y p l u s 2 * * ( - 7 ) , i . e . F = 1 . x x x x x x1 i n b a s e
| 2 where t h e s i x " x " m a t c h t h o s e o f Y . N o t e t h a t | Y - F | < = 2 * * ( - 7 ) .
|
| Step 3 . D e f i n e u = ( Y - F ) / F . A p p r o x i m a t e l o g ( 1 + u ) b y a p o l y n o m i a l i n u ,
| log( 1 + u ) = p o l y .
|
| Step 4 . R e c o n s t r u c t l o g ( X ) = l o g ( 2 * * k * Y ) = k * l o g ( 2 ) + l o g ( F ) + l o g ( 1 + u )
| by k * l o g ( 2 ) + ( l o g ( F ) + p o l y ) . T h e v a l u e s o f l o g ( F ) a r e c a l c u l a t e d
| beforehand a n d s t o r e d i n t h e p r o g r a m .
|
| lognp1 :
| Step 1 : I f | X | < 1 / 1 6 , a p p r o x i m a t e l o g ( 1 + X ) b y a n o d d p o l y n o m i a l i n
| u w h e r e u = 2 X / ( 2 + X ) . O t h e r w i s e , m o v e o n t o S t e p 2 .
|
| Step 2 : L e t 1 + X = 2 * * k * Y , w h e r e 1 < = Y < 2 . D e f i n e F a s d o n e i n S t e p 2
| of t h e a l g o r i t h m f o r L O G N a n d c o m p u t e l o g ( 1 + X ) a s
| k* l o g ( 2 ) + l o g ( F ) + p o l y w h e r e p o l y a p p r o x i m a t e s l o g ( 1 + u ) ,
| u = ( Y - F ) / F .
|
| Implementation N o t e s :
| Note 1 . T h e r e a r e 6 4 d i f f e r e n t p o s s i b l e v a l u e s f o r F , t h u s 6 4 l o g ( F ) ' s
| need t o b e t a b u l a t e d . M o r e o v e r , t h e v a l u e s o f 1 / F a r e a l s o
| tabulated s o t h a t t h e d i v i s i o n i n ( Y - F ) / F c a n b e p e r f o r m e d b y a
| multiplication.
|
| Note 2 . I n S t e p 2 o f l o g n p1 , i n o r d e r t o p r e s e r v e d a c c u r a c y , t h e v a l u e
| Y- F h a s t o b e c a l c u l a t e d c a r e f u l l y w h e n 1 / 2 < = X < 3 / 2 .
|
| Note 3 . T o f u l l y e x p l o i t t h e p i p e l i n e , p o l y n o m i a l s a r e u s u a l l y s e p a r a t e d
| into t w o p a r t s e v a l u a t e d i n d e p e n d e n t l y b e f o r e b e i n g a d d e d u p .
|
| 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
| slogn 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
# include " f p s p . h "
BOUNDS1 : .long 0x3FFEF07D , 0 x3 F F F 8 8 4 1
BOUNDS2 : .long 0x3FFE8000 , 0 x3 F F F C 0 0 0
LOGOF2 : .long 0x3FFE0000 , 0 xB1 7 2 1 7 F 7 ,0 x D 1 C F 7 9 A C ,0 x00 0 0 0 0 0 0
one : .long 0x3F800000
zero : .long 0x00000000
infty : .long 0x7F800000
negone : .long 0xBF800000
LOGA6 : .long 0x3FC2499A , 0 xB5 E 4 0 4 0 B
LOGA5 : .long 0xBFC555B5 , 0 x8 4 8 C B 7 D B
LOGA4 : .long 0x3FC99999 , 0 x9 8 7 D 8 7 3 0
LOGA3 : .long 0xBFCFFFFF , 0 xFF6 F 7 E 9 7
LOGA2 : .long 0x3FD55555 , 0 x5 5 5 5 5 5 a4
LOGA1 : .long 0xBFE00000 , 0 x0 0 0 0 0 0 0 8
LOGB5 : .long 0x3F175496 , 0 xADD7 D A D 6
LOGB4 : .long 0x3F3C71C2 , 0 xFE8 0 C 7 E 0
LOGB3 : .long 0x3F624924 , 0 x9 2 8 B C C F F
LOGB2 : .long 0x3F899999 , 0 x9 9 9 9 9 5 E C
LOGB1 : .long 0x3FB55555 , 0 x5 5 5 5 5 5 5 5
TWO : .long 0x40000000 , 0 x0 0 0 0 0 0 0 0
LTHOLD : .long 0x3f990000 , 0 x8 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0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 2 C 5 F C D ,0 x72 5 6 A 8 C 5 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x C 1 E 4 B B D 5 ,0 x95 F 6 E 9 4 7 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x8 E 4 4 C 6 0 B ,0 x4 C C F D 7 D E ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B F A 0 2 F E 8 ,0 x0 B F A 0 2 F F ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x94 4 A D 0 9 E ,0 x F 4 3 5 1 A F 6 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B D 6 9 1 0 4 7 ,0 x07 6 6 1 A A 3 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x9 A 3 E E C D 4 ,0 x C 3 E A A 6 B 2 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B B 3 E E 7 2 1 ,0 x A 5 4 D 8 8 0 C ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x A 0 2 1 8 4 3 4 ,0 x35 3 F 1 D E 8 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B 9 2 1 4 3 F A ,0 x36 F 5 E 0 2 E ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x A 5 F 2 F C A B ,0 x B B C 5 0 6 D A ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B 7 0 F B B 5 A ,0 x19 B E 3 6 5 9 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F D 0 0 0 0 ,0 x A B B 3 B 8 B A ,0 x2 A D 3 6 2 A 5 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B 5 0 9 E 6 8 A ,0 x9 B 9 4 8 2 1 F ,0 x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0
.long 0 x3 F F E 0 0 0 0 ,0 x8 B 7 0 3 4 4 A ,0 x13 9 B C 7 5 A ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x9 B 8 8 B D A A ,0 x3 A 3 D A E 2 F ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x8 A 4 2 F 8 7 0 ,0 x56 6 9 D B 4 6 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x9 D B 4 2 2 4 F ,0 x F F E 1 1 5 7 C ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x89 1 A C 7 3 A ,0 x E 9 8 1 9 B 5 0 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x9 F D A D C 2 6 ,0 x8 B 7 A 1 2 D A ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x87 F 7 8 0 8 7 ,0 x F 7 8 0 8 7 F 8 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A 1 F C F F 1 7 ,0 x C E 7 3 3 B D 4 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x86 D 9 0 5 4 4 ,0 x7 A 3 4 A C C 6 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A 4 1 A 9 E 8 F ,0 x54 4 6 F B 9 F ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x85 B F 3 7 6 1 ,0 x2 C E E 3 C 9 B ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A 6 3 3 C D 7 E ,0 x67 7 1 C D 8 B ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x84 A 9 F 9 C 8 ,0 x08 4 A 9 F 9 D ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A 8 4 8 9 E 6 0 ,0 x0 B 4 3 5 A 5 E ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x83 9 9 3 0 5 2 ,0 x3 F B E 3 3 6 8 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A A 5 9 2 3 3 C ,0 x C C A 4 B D 4 9 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x82 8 C B F B E ,0 x B 9 A 0 2 0 A 3 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A C 6 5 6 D A E ,0 x6 B C C 4 9 8 5 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x81 8 4 8 D A 8 ,0 x F A F 0 D 2 7 7 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x A E 6 D 8 E E 3 ,0 x60 B B 2 4 6 8 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x80 8 0 8 0 8 0 ,0 x80 8 0 8 0 8 1 ,0 x00 0 0 0 0 0 0
.long 0 x3 F F E 0 0 0 0 ,0 x B 0 7 1 9 7 A 2 ,0 x3 C 4 6 C 6 5 4 ,0 x00 0 0 0 0 0 0
.set ADJK,L _ S C R 1
.set X,F P _ S C R 1
.set XDCARE,X + 2
.set XFRAC,X + 4
.set F,F P _ S C R 2
.set FFRAC,F + 4
.set KLOG2 ,F P _ S C R 3
.set SAVEU,F P _ S C R 4
| xref t _ f r c i n x
| xref t _ e x t d n r m
| xref t _ o p e r r
| xref t _ d z
.global slognd
slognd :
| - - ENTRY P O I N T F O R L O G ( X ) F O R D E N O R M A L I Z E D I N P U T
movel #- 100 ,A D J K ( % a6 ) | . . . I N P U T = 2 ^ ( A D J K ) * F P 0
| - - - - normalize t h e i n p u t v a l u e b y l e f t s h i f t i n g k b i t s ( k t o b e d e t e r m i n e d
| - - - - below) , a d j u s t i n g e x p o n e n t a n d s t o r i n g - k t o A D J K
| - - - - the v a l u e T W O T O 1 0 0 i s n o l o n g e r n e e d e d .
| - - - - Note t h a t t h i s c o d e a s s u m e s t h e d e n o r m a l i z e d i n p u t i s N O N - Z E R O .
moveml % d2 - % d7 ,- ( % a7 ) | . . . s a v e s o m e r e g i s t e r s
movel #0x00000000 ,% d3 | . . . D 3 i s e x p o n e n t o f s m a l l e s t n o r m . #
movel 4 ( % a0 ) ,% d4
movel 8 ( % a0 ) ,% d5 | . . . ( D 4 ,D 5 ) i s ( H i _ X ,L o _ X )
clrl % d2 | . . . D 2 u s e d f o r h o l d i n g K
tstl % d4
bnes H i X _ n o t 0
HiX_0 :
movel % d5 ,% d4
clrl % d5
movel #32 ,% d2
clrl % d6
bfffo % d4 { #0 : #32 } ,% d6
lsll % d6 ,% d4
addl % d6 ,% d2 | . . . ( D 3 ,D 4 ,D 5 ) i s n o r m a l i z e d
movel % d3 ,X ( % a6 )
movel % d4 ,X F R A C ( % a6 )
movel % d5 ,X F R A C + 4 ( % a6 )
negl % d2
movel % d2 ,A D J K ( % a6 )
fmovex X ( % a6 ) ,% f p0
moveml ( % a7 ) + ,% d2 - % d7 | . . . r e s t o r e r e g i s t e r s
lea X ( % a6 ) ,% a0
bras L O G B G N | . . . b e g i n r e g u l a r l o g ( X )
HiX_not0 :
clrl % d6
bfffo % d4 { #0 : #32 } ,% d6 | . . . f i n d f i r s t 1
movel % d6 ,% d2 | . . . g e t k
lsll % d6 ,% d4
movel % d5 ,% d7 | . . . a c o p y o f D 5
lsll % d6 ,% d5
negl % d6
addil #32 ,% d6
lsrl % d6 ,% d7
orl % d7 ,% d4 | . . . ( D 3 ,D 4 ,D 5 ) n o r m a l i z e d
movel % d3 ,X ( % a6 )
movel % d4 ,X F R A C ( % a6 )
movel % d5 ,X F R A C + 4 ( % a6 )
negl % d2
movel % d2 ,A D J K ( % a6 )
fmovex X ( % a6 ) ,% f p0
moveml ( % a7 ) + ,% d2 - % d7 | . . . r e s t o r e r e g i s t e r s
lea X ( % a6 ) ,% a0
bras L O G B G N | . . . b e g i n r e g u l a r l o g ( X )
.global slogn
slogn :
| - - ENTRY P O I N T F O R L O G ( X ) F O R X F I N I T E , N O N - Z E R O , N O T N A N ' S
fmovex ( % a0 ) ,% f p0 | . . . L O A D I N P U T
movel #0x00000000 ,A D J K ( % a6 )
LOGBGN :
| - - FPCR S A V E D A N D C L E A R E D , I N P U T I S 2 ^ ( A D J K ) * F P 0 , F P 0 C O N T A I N S
| - - A F I N I T E , N O N - Z E R O , N O R M A L I Z E D N U M B E R .
movel ( % a0 ) ,% d0
movew 4 ( % a0 ) ,% d0
movel ( % a0 ) ,X ( % a6 )
movel 4 ( % a0 ) ,X + 4 ( % a6 )
movel 8 ( % a0 ) ,X + 8 ( % a6 )
cmpil #0 ,% d0 | . . . C H E C K I F X I S N E G A T I V E
blt L O G N E G | . . . L O G O F N E G A T I V E A R G U M E N T I S I N V A L I D
cmp2 l B O U N D S 1 ,% d0 | . . . X I S P O S I T I V E , C H E C K I F X I S N E A R 1
bcc L O G N E A R 1 | . . . B O U N D S I S R O U G H L Y [ 1 5 / 1 6 , 1 7 / 1 6 ]
LOGMAIN :
| - - THIS S H O U L D B E T H E U S U A L C A S E , X N O T V E R Y C L O S E T O 1
| - - X = 2 ^ ( K ) * Y , 1 < = Y < 2 . T H U S , Y = 1 . X X X X X X X X . . . . X X I N B I N A R Y .
| - - WE D E F I N E F = 1 . X X X X X X 1 , I . E . F I R S T 7 B I T S O F Y A N D A T T A C H A 1 .
| - - THE I D E A I S T H A T L O G ( X ) = K * L O G 2 + L O G ( Y )
| - - = K* L O G 2 + L O G ( F ) + L O G ( 1 + ( Y - F ) / F ) .
| - - NOTE T H A T U = ( Y - F ) / F I S V E R Y S M A L L A N D T H U S A P P R O X I M A T I N G
| - - LOG( 1 + U ) C A N B E V E R Y E F F I C I E N T .
| - - ALSO N O T E T H A T T H E V A L U E 1 / F I S S T O R E D I N A T A B L E S O T H A T N O
| - - DIVISION I S N E E D E D T O C A L C U L A T E ( Y - F ) / F .
| - - GET K , Y , F , A N D A D D R E S S O F 1 / F .
asrl #8 ,% d0
asrl #8 ,% d0 | . . . S H I F T E D 1 6 B I T S , B I A S E D E X P O . O F X
subil #0x3FFF ,% d0 | . . . T H I S I S K
addl A D J K ( % a6 ) ,% d0 | . . . A D J U S T K , O R I G I N A L I N P U T M A Y B E D E N O R M .
lea L O G T B L ,% a0 | . . . B A S E A D D R E S S O F 1 / F A N D L O G ( F )
fmovel % d0 ,% f p1 | . . . C O N V E R T K T O F L O A T I N G - P O I N T F O R M A T
| - - WHILE T H E C O N V E R S I O N I S G O I N G O N , W E G E T F A N D A D D R E S S O F 1 / F
movel #0x3FFF0000 ,X ( % a6 ) | . . . X I S N O W Y , I . E . 2 ^ ( - K ) * X
movel X F R A C ( % a6 ) ,F F R A C ( % a6 )
andil #0xFE000000 ,F F R A C ( % a6 ) | . . . F I R S T 7 B I T S O F Y
oril #0x01000000 ,F F R A C ( % a6 ) | . . . G E T F : A T T A C H A 1 A T T H E E I G H T H B I T
movel F F R A C ( % a6 ) ,% d0 | . . . R E A D Y T O G E T A D D R E S S O F 1 / F
andil #0x7E000000 ,% d0
asrl #8 ,% d0
asrl #8 ,% d0
asrl #4 ,% d0 | . . . S H I F T E D 2 0 , D 0 I S T H E D I S P L A C E M E N T
addal % d0 ,% a0 | . . . A 0 I S T H E A D D R E S S F O R 1 / F
fmovex X ( % a6 ) ,% f p0
movel #0x3fff0000 ,F ( % a6 )
clrl F + 8 ( % a6 )
fsubx F ( % a6 ) ,% f p0 | . . . Y - F
fmovemx % f p2 - % f p2 / % f p3 ,- ( % s p ) | . . . S A V E F P 2 W H I L E F P 0 I S N O T R E A D Y
| - - SUMMARY : FP0 I S Y - F , A 0 I S A D D R E S S O F 1 / F , F P 1 I S K
| - - REGISTERS S A V E D : F P C R , F P 1 , F P 2
LP1CONT1 :
| - - AN R E - E N T R Y P O I N T F O R L O G N P 1
fmulx ( % a0 ) ,% f p0 | . . . F P 0 I S U = ( Y - F ) / F
fmulx L O G O F 2 ,% f p1 | . . . G E T K * L O G 2 W H I L E F P 0 I S N O T R E A D Y
fmovex % f p0 ,% f p2
fmulx % f p2 ,% f p2 | . . . F P 2 I S V =U * U
fmovex % f p1 ,K L O G 2 ( % a6 ) | . . . P U T K * L O G 2 I N M E M O R Y , F R E E F P 1
| - - LOG( 1 + U ) I S A P P R O X I M A T E D B Y
| - - U + V * ( A 1 + U * ( A 2 + U * ( A 3 + U * ( A 4 + U * ( A 5 + U * A 6 ) ) ) ) ) W H I C H I S
| - - [ U + V * ( A 1 + V * ( A 3 + V * A 5 ) ) ] + [ U * V * ( A 2 + V * ( A 4 + V * A 6 ) ) ]
fmovex % f p2 ,% f p3
fmovex % f p2 ,% f p1
fmuld L O G A 6 ,% f p1 | . . . V * A 6
fmuld L O G A 5 ,% f p2 | . . . V * A 5
faddd L O G A 4 ,% f p1 | . . . A 4 + V * A 6
faddd L O G A 3 ,% f p2 | . . . A 3 + V * A 5
fmulx % f p3 ,% f p1 | . . . V * ( A 4 + V * A 6 )
fmulx % f p3 ,% f p2 | . . . V * ( A 3 + V * A 5 )
faddd L O G A 2 ,% f p1 | . . . A 2 + V * ( A 4 + V * A 6 )
faddd L O G A 1 ,% f p2 | . . . A 1 + V * ( A 3 + V * A 5 )
fmulx % f p3 ,% f p1 | . . . V * ( A 2 + V * ( A 4 + V * A 6 ) )
addal #16 ,% a0 | . . . A D D R E S S O F L O G ( F )
fmulx % f p3 ,% f p2 | . . . V * ( A 1 + V * ( A 3 + V * A 5 ) ) , F P 3 R E L E A S E D
fmulx % f p0 ,% f p1 | . . . U * V * ( A 2 + V * ( A 4 + V * A 6 ) )
faddx % f p2 ,% f p0 | . . . U + V * ( A 1 + V * ( A 3 + V * A 5 ) ) , F P 2 R E L E A S E D
faddx ( % a0 ) ,% f p1 | . . . L O G ( F ) + U * V * ( A 2 + V * ( A 4 + V * A 6 ) )
fmovemx ( % s p ) + ,% f p2 - % f p2 / % f p3 | . . . R E S T O R E F P 2
faddx % f p1 ,% f p0 | . . . F P 0 I S L O G ( F ) + L O G ( 1 + U )
fmovel % d1 ,% f p c r
faddx K L O G 2 ( % a6 ) ,% f p0 | . . . F I N A L A D D
bra t _ f r c i n x
LOGNEAR1 :
| - - REGISTERS S A V E D : F P C R , F P 1 . F P 0 C O N T A I N S T H E I N P U T .
fmovex % f p0 ,% f p1
fsubs o n e ,% f p1 | . . . F P 1 I S X - 1
fadds o n e ,% f p0 | . . . F P 0 I S X + 1
faddx % f p1 ,% f p1 | . . . F P 1 I S 2 ( X - 1 )
| - - LOG( X ) = L O G ( 1 + U / 2 ) - L O G ( 1 - U / 2 ) W H I C H I S A N O D D P O L Y N O M I A L
| - - IN U , U = 2 ( X - 1 ) / ( X + 1 ) = F P 1 / F P 0
LP1CONT2 :
| - - THIS I S A N R E - E N T R Y P O I N T F O R L O G N P 1
fdivx % f p0 ,% f p1 | . . . F P 1 I S U
fmovemx % f p2 - % f p2 / % f p3 ,- ( % s p ) | . . . S A V E F P 2
| - - REGISTERS S A V E D A R E N O W F P C R ,F P 1 ,F P 2 ,F P 3
| - - LET V =U * U , W =V * V , C A L C U L A T E
| - - U + U * V * ( B 1 + V * ( B 2 + V * ( B 3 + V * ( B 4 + V * B 5 ) ) ) ) B Y
| - - U + U * V * ( [ B 1 + W * ( B 3 + W * B 5 ) ] + [ V * ( B 2 + W * B 4 ) ] )
fmovex % f p1 ,% f p0
fmulx % f p0 ,% f p0 | . . . F P 0 I S V
fmovex % f p1 ,S A V E U ( % a6 ) | . . . S T O R E U I N M E M O R Y , F R E E F P 1
fmovex % f p0 ,% f p1
fmulx % f p1 ,% f p1 | . . . F P 1 I S W
fmoved L O G B 5 ,% f p3
fmoved L O G B 4 ,% f p2
fmulx % f p1 ,% f p3 | . . . W * B 5
fmulx % f p1 ,% f p2 | . . . W * B 4
faddd L O G B 3 ,% f p3 | . . . B 3 + W * B 5
faddd L O G B 2 ,% f p2 | . . . B 2 + W * B 4
fmulx % f p3 ,% f p1 | . . . W * ( B 3 + W * B 5 ) , F P 3 R E L E A S E D
fmulx % f p0 ,% f p2 | . . . V * ( B 2 + W * B 4 )
faddd L O G B 1 ,% f p1 | . . . B 1 + W * ( B 3 + W * B 5 )
fmulx S A V E U ( % a6 ) ,% f p0 | . . . F P 0 I S U * V
faddx % f p2 ,% f p1 | . . . B 1 + W * ( B 3 + W * B 5 ) + V * ( B 2 + W * B 4 ) , F P 2 R E L E A S E D
fmovemx ( % s p ) + ,% f p2 - % f p2 / % f p3 | . . . F P 2 R E S T O R E D
fmulx % f p1 ,% f p0 | . . . U * V * ( [ B 1 + W * ( B 3 + W * B 5 ) ] + [ V * ( B 2 + W * B 4 ) ] )
fmovel % d1 ,% f p c r
faddx S A V E U ( % a6 ) ,% f p0
bra t _ f r c i n x
rts
LOGNEG :
| - - REGISTERS S A V E D F P C R . L O G ( - V E ) I S I N V A L I D
bra t _ o p e r r
.global slognp1d
slognp1d :
| - - ENTRY P O I N T F O R L O G ( 1 + Z ) F O R D E N O R M A L I Z E D I N P U T
| Simply r e t u r n t h e d e n o r m
bra t _ e x t d n r m
.global slognp1
slognp1 :
| - - ENTRY P O I N T F O R L O G ( 1 + X ) F O R X F I N I T E , N O N - Z E R O , N O T N A N ' S
fmovex ( % a0 ) ,% f p0 | . . . L O A D I N P U T
fabsx % f p0 | t e s t m a g n i t u d e
fcmpx L T H O L D ,% f p0 | c o m p a r e w i t h m i n t h r e s h o l d
fbgt L P 1 R E A L | i f g r e a t e r , c o n t i n u e
fmovel #0 ,% f p s r | c l r N f l a g f r o m c o m p a r e
fmovel % d1 ,% f p c r
fmovex ( % a0 ) ,% f p0 | r e t u r n s i g n e d a r g u m e n t
bra t _ f r c i n x
LP1REAL :
fmovex ( % a0 ) ,% f p0 | . . . L O A D I N P U T
movel #0x00000000 ,A D J K ( % a6 )
fmovex % f p0 ,% f p1 | . . . F P 1 I S I N P U T Z
fadds o n e ,% f p0 | . . . X : = R O U N D ( 1 + Z )
fmovex % f p0 ,X ( % a6 )
movew X F R A C ( % a6 ) ,X D C A R E ( % a6 )
movel X ( % a6 ) ,% d0
cmpil #0 ,% d0
ble L P 1 N E G 0 | . . . L O G O F Z E R O O R - V E
cmp2 l B O U N D S 2 ,% d0
bcs L O G M A I N | . . . B O U N D S 2 I S [ 1 / 2 ,3 / 2 ]
| - - IF 1 + Z > 3 / 2 O R 1 + Z < 1 / 2 , T H E N X , W H I C H I S R O U N D I N G 1 + Z ,
| - - CONTAINS A T L E A S T 6 3 B I T S O F I N F O R M A T I O N O F Z . I N T H A T C A S E ,
| - - SIMPLY I N V O K E L O G ( X ) F O R L O G ( 1 + Z ) .
LP1NEAR1 :
| - - NEXT S E E I F E X P ( - 1 / 1 6 ) < X < E X P ( 1 / 1 6 )
cmp2 l B O U N D S 1 ,% d0
bcss L P 1 C A R E
LP1ONE16 :
| - - EXP( - 1 / 1 6 ) < X < E X P ( 1 / 1 6 ) . L O G ( 1 + Z ) = L O G ( 1 + U / 2 ) - L O G ( 1 - U / 2 )
| - - WHERE U = 2 Z / ( 2 + Z ) = 2 Z / ( 1 + X ) .
faddx % f p1 ,% f p1 | . . . F P 1 I S 2 Z
fadds o n e ,% f p0 | . . . F P 0 I S 1 + X
| - - U = F P 1 / F P 0
bra L P 1 C O N T 2
LP1CARE :
| - - HERE W E U S E T H E U S U A L T A B L E D R I V E N A P P R O A C H . C A R E H A S T O B E
| - - TAKEN B E C A U S E 1 + Z C A N H A V E 6 7 B I T S O F I N F O R M A T I O N A N D W E M U S T
| - - PRESERVE A L L T H E I N F O R M A T I O N . B E C A U S E 1 + Z I S I N [ 1 / 2 ,3 / 2 ] ,
| - - THERE A R E O N L Y T W O C A S E S .
| - - CASE 1 : 1 + Z < 1 , T H E N K = - 1 A N D Y - F = ( 2 - F ) + 2 Z
| - - CASE 2 : 1 + Z > 1 , T H E N K = 0 A N D Y - F = ( 1 - F ) + Z
| - - ON R E T U R N I N G T O L P 1 C O N T 1 , W E M U S T H A V E K I N F P 1 , A D D R E S S O F
| - - ( 1 / F) I N A 0 , Y - F I N F P 0 , A N D F P 2 S A V E D .
movel X F R A C ( % a6 ) ,F F R A C ( % a6 )
andil #0xFE000000 ,F F R A C ( % a6 )
oril #0x01000000 ,F F R A C ( % a6 ) | . . . F O B T A I N E D
cmpil #0x3FFF8000 ,% d0 | . . . S E E I F 1 + Z > 1
bges K I S Z E R O
KISNEG1 :
fmoves T W O ,% f p0
movel #0x3fff0000 ,F ( % a6 )
clrl F + 8 ( % a6 )
fsubx F ( % a6 ) ,% f p0 | . . . 2 - F
movel F F R A C ( % a6 ) ,% d0
andil #0x7E000000 ,% d0
asrl #8 ,% d0
asrl #8 ,% d0
asrl #4 ,% d0 | . . . D 0 C O N T A I N S D I S P L A C E M E N T F O R 1 / F
faddx % f p1 ,% f p1 | . . . G E T 2 Z
fmovemx % f p2 - % f p2 / % f p3 ,- ( % s p ) | . . . S A V E F P 2
faddx % f p1 ,% f p0 | . . . F P 0 I S Y - F = ( 2 - F ) + 2 Z
lea L O G T B L ,% a0 | . . . A 0 I S A D D R E S S O F 1 / F
addal % d0 ,% a0
fmoves n e g o n e ,% f p1 | . . . F P 1 I S K = - 1
bra L P 1 C O N T 1
KISZERO :
fmoves o n e ,% f p0
movel #0x3fff0000 ,F ( % a6 )
clrl F + 8 ( % a6 )
fsubx F ( % a6 ) ,% f p0 | . . . 1 - F
movel F F R A C ( % a6 ) ,% d0
andil #0x7E000000 ,% d0
asrl #8 ,% d0
asrl #8 ,% d0
asrl #4 ,% d0
faddx % f p1 ,% f p0 | . . . F P 0 I S Y - F
fmovemx % f p2 - % f p2 / % f p3 ,- ( % s p ) | . . . F P 2 S A V E D
lea L O G T B L ,% a0
addal % d0 ,% a0 | . . . A 0 I S A D D R E S S O F 1 / F
fmoves z e r o ,% f p1 | . . . F P 1 I S K = 0
bra L P 1 C O N T 1
LP1NEG0 :
| - - FPCR S A V E D . D 0 I S X I N C O M P A C T F O R M .
cmpil #0 ,% d0
blts L P 1 N E G
LP1ZERO :
fmoves n e g o n e ,% f p0
fmovel % d1 ,% f p c r
bra t _ d z
LP1NEG :
fmoves z e r o ,% f p0
fmovel % d1 ,% f p c r
bra t _ o p e r r
| end