2005-04-17 02:20:36 +04:00
|
| get_ o p . s a 3 . 6 5 / 1 9 / 9 2
|
| get_ o p . s a 3 . 5 4 / 2 6 / 9 1
|
| Description : This r o u t i n e i s c a l l e d b y t h e u n s u p p o r t e d f o r m a t / d a t a
| type e x c e p t i o n h a n d l e r ( ' u n s u p p ' - v e c t o r 5 5 ) a n d t h e u n i m p l e m e n t e d
| instruction e x c e p t i o n h a n d l e r ( ' u n i m p ' - v e c t o r 1 1 ) . ' g e t _ o p '
| determines t h e o p c l a s s ( 0 , 2 , o r 3 ) a n d b r a n c h e s t o t h e
| opclass h a n d l e r r o u t i n e . S e e 6 8 8 8 1 / 2 U s e r ' s M a n u a l t a b l e 4 - 1 1
| for a d e s c r i p t i o n o f t h e o p c l a s s e s .
|
| For U N S U P P O R T E D d a t a / f o r m a t ( e x c e p t i o n v e c t o r 5 5 ) a n d f o r
| UNIMPLEMENTED i n s t r u c t i o n s ( e x c e p t i o n v e c t o r 1 1 ) t h e f o l l o w i n g
| applies :
|
| - For u n n o r m a l i z e d n u m b e r s ( o p c l a s s 0 , 2 , o r 3 ) t h e
| number( s ) i s n o r m a l i z e d a n d t h e o p e r a n d t y p e t a g i s u p d a t e d .
|
| - For a p a c k e d n u m b e r ( o p c l a s s 2 ) t h e n u m b e r i s u n p a c k e d a n d t h e
| operand t y p e t a g i s u p d a t e d .
|
| - For d e n o r m a l i z e d n u m b e r s ( o p c l a s s 0 o r 2 ) t h e n u m b e r ( s ) i s n o t
| changed b u t p a s s e d t o t h e n e x t m o d u l e . T h e n e x t m o d u l e f o r
| unimp i s d o _ f u n c , t h e n e x t m o d u l e f o r u n s u p p i s r e s _ f u n c .
|
| For U N S U P P O R T E D d a t a / f o r m a t ( e x c e p t i o n v e c t o r 5 5 ) o n l y t h e
| following a p p l i e s :
|
| - If t h e r e i s a m o v e o u t w i t h a p a c k e d n u m b e r ( o p c l a s s 3 ) t h e
| number i s p a c k e d a n d w r i t t e n t o u s e r m e m o r y . F o r t h e o t h e r
| opclasses t h e n u m b e r ( s ) a r e w r i t t e n b a c k t o t h e f s a v e s t a c k
| and t h e i n s t r u c t i o n i s t h e n r e s t o r e d b a c k i n t o t h e ' 0 4 0 . T h e
| ' 0 4 0 is t h e n a b l e t o c o m p l e t e t h e i n s t r u c t i o n .
|
| For e x a m p l e :
| fadd. x f p m ,f p n w h e r e t h e f p m c o n t a i n s a n u n n o r m a l i z e d n u m b e r .
| The ' 0 4 0 t a k e s a n u n s u p p o r t e d d a t a t r a p a n d g e t s t o t h i s
| routine. T h e n u m b e r i s n o r m a l i z e d , p u t b a c k o n t h e s t a c k a n d
| then a n f r e s t o r e i s d o n e t o r e s t o r e t h e i n s t r u c t i o n b a c k i n t o
| the ' 0 4 0 . T h e ' 0 4 0 t h e n r e - e x e c u t e s t h e f a d d . x f p m ,f p n w i t h
| a n o r m a l i z e d n u m b e r i n t h e s o u r c e a n d t h e i n s t r u c t i o n i s
| successful.
|
| Next c o n s i d e r i f i n t h e p r o c e s s o f n o r m a l i z i n g t h e u n -
| normalized n u m b e r i t b e c o m e s a d e n o r m a l i z e d n u m b e r . T h e
| routine w h i c h c o n v e r t s t h e u n n o r m t o a n o r m ( c a l l e d m k _ n o r m )
| detects t h i s a n d t a g s t h e n u m b e r a s a d e n o r m . T h e r o u t i n e
| res_ f u n c s e e s t h e d e n o r m t a g a n d c o n v e r t s t h e d e n o r m t o a
| norm. T h e i n s t r u c t i o n i s t h e n r e s t o r e d b a c k i n t o t h e ' 0 4 0
| which r e _ e x e c u t e s t h e i n s t r u c t i o n .
|
|
| 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
GET_OP : | idnt 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 "
.global PIRN,P I R Z R M ,P I R P
.global SMALRN,S M A L R Z R M ,S M A L R P
.global BIGRN,B I G R Z R M ,B I G R P
PIRN :
.long 0 x4 0 0 0 0 0 0 0 ,0 x c90 f d a a2 ,0 x21 6 8 c23 5 | p i
PIRZRM :
.long 0 x4 0 0 0 0 0 0 0 ,0 x c90 f d a a2 ,0 x21 6 8 c23 4 | p i
PIRP :
.long 0 x4 0 0 0 0 0 0 0 ,0 x c90 f d a a2 ,0 x21 6 8 c23 5 | p i
| round t o n e a r e s t
SMALRN :
.long 0 x3 f f d00 0 0 ,0 x9 a20 9 a84 ,0 x f b c f f79 8 | l o g 1 0 ( 2 )
.long 0 x4 0 0 0 0 0 0 0 ,0 x a d f85 4 5 8 ,0 x a2 b b4 a9 a | e
.long 0 x3 f f f00 0 0 ,0 x b8 a a3 b29 ,0 x5 c17 f0 b c | l o g 2 ( e )
.long 0 x3 f f d00 0 0 ,0 x d e 5 b d8 a9 ,0 x37 2 8 7 1 9 5 | l o g 1 0 ( e )
.long 0 x0 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 0 . 0
| round t o z e r o ;round to negative infinity
SMALRZRM :
.long 0 x3 f f d00 0 0 ,0 x9 a20 9 a84 ,0 x f b c f f79 8 | l o g 1 0 ( 2 )
.long 0 x4 0 0 0 0 0 0 0 ,0 x a d f85 4 5 8 ,0 x a2 b b4 a9 a | e
.long 0 x3 f f f00 0 0 ,0 x b8 a a3 b29 ,0 x5 c17 f0 b b | l o g 2 ( e )
.long 0 x3 f f d00 0 0 ,0 x d e 5 b d8 a9 ,0 x37 2 8 7 1 9 5 | l o g 1 0 ( e )
.long 0 x0 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 0 . 0
| round t o p o s i t i v e i n f i n i t y
SMALRP :
.long 0 x3 f f d00 0 0 ,0 x9 a20 9 a84 ,0 x f b c f f79 9 | l o g 1 0 ( 2 )
.long 0 x4 0 0 0 0 0 0 0 ,0 x a d f85 4 5 8 ,0 x a2 b b4 a9 b | e
.long 0 x3 f f f00 0 0 ,0 x b8 a a3 b29 ,0 x5 c17 f0 b c | l o g 2 ( e )
.long 0 x3 f f d00 0 0 ,0 x d e 5 b d8 a9 ,0 x37 2 8 7 1 9 5 | l o g 1 0 ( e )
.long 0 x0 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 0 . 0
| round t o n e a r e s t
BIGRN :
.long 0 x3 f f e 0 0 0 0 ,0 x b17 2 1 7 f7 ,0 x d1 c f79 a c | l n ( 2 )
.long 0 x4 0 0 0 0 0 0 0 ,0 x93 5 d8 d d d ,0 x a a a8 a c17 | l n ( 1 0 )
.long 0 x3 f f f00 0 0 ,0 x80 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 0
.global PTENRN
PTENRN :
.long 0 x4 0 0 2 0 0 0 0 ,0 x A 0 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 1
.long 0 x4 0 0 5 0 0 0 0 ,0 x C 8 0 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 2
.long 0 x4 0 0 C 0 0 0 0 ,0 x9 C 4 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 4
.long 0 x4 0 1 9 0 0 0 0 ,0 x B E B C 2 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 8
.long 0 x4 0 3 4 0 0 0 0 ,0 x8 E 1 B C 9 B F ,0 x04 0 0 0 0 0 0 | 1 0 ^ 1 6
.long 0 x4 0 6 9 0 0 0 0 ,0 x9 D C 5 A D A 8 ,0 x2 B 7 0 B 5 9 E | 1 0 ^ 3 2
.long 0 x4 0 D 3 0 0 0 0 ,0 x C 2 7 8 1 F 4 9 ,0 x F F C F A 6 D 5 | 1 0 ^ 6 4
.long 0 x4 1 A 8 0 0 0 0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0 0 0 0 ,0 x9 C 4 0 0 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 4
.long 0 x4 0 1 9 0 0 0 0 ,0 x B E B C 2 0 0 0 ,0 x00 0 0 0 0 0 0 | 1 0 ^ 8
.long 0 x4 0 3 4 0 0 0 0 ,0 x8 E 1 B C 9 B F ,0 x04 0 0 0 0 0 0 | 1 0 ^ 1 6
.long 0 x4 0 6 9 0 0 0 0 ,0 x9 D C 5 A D A 8 ,0 x2 B 7 0 B 5 9 E | 1 0 ^ 3 2
.long 0 x4 0 D 3 0 0 0 0 ,0 x C 2 7 8 1 F 4 9 ,0 x F F C F A 6 D 6 | 1 0 ^ 6 4
.long 0 x4 1 A 8 0 0 0 0 ,0 x93 B A 4 7 C 9 ,0 x80 E 9 8 C E 0 | 1 0 ^ 1 2 8
.long 0 x4 3 5 1 0 0 0 0 ,0 x A A 7 E E B F B ,0 x9 D F 9 D E 8 E | 1 0 ^ 2 5 6
.long 0 x4 6 A 3 0 0 0 0 ,0 x E 3 1 9 A 0 A E ,0 x A 6 0 E 9 1 C 7 | 1 0 ^ 5 1 2
.long 0 x4 D 4 8 0 0 0 0 ,0 x C 9 7 6 7 5 8 6 ,0 x81 7 5 0 C 1 8 | 1 0 ^ 1 0 2 4
.long 0 x5 A 9 2 0 0 0 0 ,0 x9 E 8 B 3 B 5 D ,0 x C 5 3 D 5 D E 6 | 1 0 ^ 2 0 4 8
.long 0 x7 5 2 5 0 0 0 0 ,0 x C 4 6 0 5 2 0 2 ,0 x8 A 2 0 9 7 9 B | 1 0 ^ 4 0 9 6
| xref n r m _ z e r o
| xref d e c b i n
| xref r o u n d
.global get_op
.global uns_getop
.global uni_getop
get_op :
clrb D Y _ M O _ F L G ( % a6 )
tstb U F L G _ T M P ( % a6 ) | t e s t f l a g f o r u n s u p p / u n i m p s t a t e
beq u n i _ g e t o p
uns_getop :
btstb #d i r e c t i o n _ b i t , C M D R E G 1 B ( % a6 )
bne o p c l a s s3 | b r a n c h i f a f m o v e o u t ( a n y k i n d )
btstb #6 ,C M D R E G 1 B ( % a6 )
beqs u n s _ n o t p a c k e d
bfextu C M D R E G 1 B ( % a6 ) { #3 : #3 } ,% d0
cmpb #3 ,% d0
beq p a c k _ s o u r c e | c h e c k f o r a p a c k e d s r c o p , b r a n c h i f s o
uns_notpacked :
bsr c h k _ d y _ m o | s e t t h e d y a d i c / m o n a d i c f l a g
tstb D Y _ M O _ F L G ( % a6 )
beqs s r c _ o p _ c k | i f m o n a d i c , g o c h e c k s r c o p
| ;else, check dst op (fall through)
btstb #7 ,D T A G ( % a6 )
beqs s r c _ o p _ c k | i f d s t o p i s n o r m , c h e c k s r c o p
bras d s t _ e x _ d n r m | e l s e , h a n d l e d e s t i n a t i o n u n n o r m / d n r m
uni_getop :
bfextu C M D R E G 1 B ( % a6 ) { #0 : #6 } ,% d0 | g e t o p c l a s s a n d s r c f i e l d s
cmpil #0x17 ,% d0 | i f o p c l a s s a n d s i z e f i e l d s a r e $ 1 7 ,
| ;it is FMOVECR; if not, continue
|
| If t h e i n s t r u c t i o n i s f m o v e c r , e x i t g e t _ o p . I t i s h a n d l e d
| in d o _ f u n c a n d s m o v e c r . s a .
|
bne n o t _ f m o v e c r | h a n d l e f m o v e c r a s a n u n i m p l e m e n t e d i n s t
rts
not_fmovecr :
btstb #E 1 ,E _ B Y T E ( % a6 ) | i f s e t , t h e r e i s a p a c k e d o p e r a n d
bne p a c k _ s o u r c e | c h e c k f o r p a c k e d s r c o p , b r a n c h i f s o
| The f o l l o w i n g l i n e s o f a r e c o d e d t o o p t i m i z e o n n o r m a l i z e d o p e r a n d s
moveb S T A G ( % a6 ) ,% d0
orb D T A G ( % a6 ) ,% d0 | c h e c k i f e i t h e r o f S T A G / D T A G m s b s e t
bmis d e s t _ o p _ c k | i f s o , s o m e o p n e e d s t o b e f i x e d
rts
dest_op_ck :
btstb #7 ,D T A G ( % a6 ) | c h e c k f o r u n s u p p o r t e d d a t a t y p e s i n
beqs s r c _ o p _ c k | t h e d e s t i n a t i o n , i f n o t , c h e c k s r c o p
bsr c h k _ d y _ m o | s e t d y a d i c / m o n a d i c f l a g
tstb D Y _ M O _ F L G ( % a6 ) |
beqs s r c _ o p _ c k | i f m o n a d i c , c h e c k s r c o p
|
| At t h i s p o i n t , d e s t i n a t i o n h a s a n e x t e n d e d d e n o r m o r u n n o r m .
|
dst_ex_dnrm :
movew F P T E M P _ E X ( % a6 ) ,% d0 | g e t d e s t i n a t i o n e x p o n e n t
andiw #0x7fff ,% d0 | m a s k s i g n , c h e c k i f e x p = 0 0 0 0
beqs s r c _ o p _ c k | i f d e n o r m t h e n c h e c k s o u r c e o p .
| ;denorms are taken care of in res_func
| ;(unsupp) or do_func (unimp)
| ;else unnorm fall through
leal F P T E M P ( % a6 ) ,% a0 | p o i n t a0 t o d o p - u s e d i n m k _ n o r m
bsr m k _ n o r m | g o n o r m a l i z e - m k _ n o r m r e t u r n s :
| ;L_SCR1{7:5} = operand tag
| ; (000 = norm, 100 = denorm)
| ;L_SCR1{4} = fpte15 or ete15
| ; 0 = exp > $3fff
| ; 1 = exp <= $3fff
| ;and puts the normalized num back
| ;on the fsave stack
|
moveb L _ S C R 1 ( % a6 ) ,D T A G ( % a6 ) | w r i t e t h e n e w t a g & f p t e 1 5
| ;to the fsave stack and fall
| ;through to check source operand
|
src_op_ck :
btstb #7 ,S T A G ( % a6 )
beq e n d _ g e t o p | c h e c k f o r u n s u p p o r t e d d a t a t y p e s o n t h e
| ;source operand
btstb #5 ,S T A G ( % a6 )
bnes s r c _ s d _ d n r m | i f b i t 5 s e t , h a n d l e s g l / d b l d e n o r m s
|
| At t h i s p o i n t o n l y u n n o r m s o r e x t e n d e d d e n o r m s a r e p o s s i b l e .
|
src_ex_dnrm :
movew E T E M P _ E X ( % a6 ) ,% d0 | g e t s o u r c e e x p o n e n t
andiw #0x7fff ,% d0 | m a s k s i g n , c h e c k i f e x p = 0 0 0 0
beq e n d _ g e t o p | i f d e n o r m t h e n e x i t , d e n o r m s a r e
| ;handled in do_func
leal E T E M P ( % a6 ) ,% a0 | p o i n t a0 t o s o p - u s e d i n m k _ n o r m
bsr m k _ n o r m | g o n o r m a l i z e - m k _ n o r m r e t u r n s :
| ;L_SCR1{7:5} = operand tag
| ; (000 = norm, 100 = denorm)
| ;L_SCR1{4} = fpte15 or ete15
| ; 0 = exp > $3fff
| ; 1 = exp <= $3fff
| ;and puts the normalized num back
| ;on the fsave stack
|
moveb L _ S C R 1 ( % a6 ) ,S T A G ( % a6 ) | w r i t e t h e n e w t a g & e t e 1 5
rts | e n d _ g e t o p
|
| At t h i s p o i n t , o n l y s i n g l e o r d o u b l e d e n o r m s a r e p o s s i b l e .
| If t h e i n s t i s n o t f m o v e , n o r m a l i z e t h e s o u r c e . I f i t i s ,
| do n o t h i n g t o t h e i n p u t .
|
src_sd_dnrm :
btstb #4 ,C M D R E G 1 B ( % a6 ) | d i f f e r e n t i a t e b e t w e e n s g l / d b l d e n o r m
bnes i s _ d o u b l e
is_single :
movew #0x3f81 ,% d1 | w r i t e b i a s f o r s g l d e n o r m
bras c o m m o n | g o t o t h e c o m m o n c o d e
is_double :
movew #0x3c01 ,% d1 | w r i t e t h e b i a s f o r a d b l d e n o r m
common :
btstb #s i g n _ b i t , E T E M P _ E X ( % a 6 ) | g r a b s i g n b i t o f m a n t i s s a
beqs p o s
bset #15 ,% d1 | s e t s i g n b i t b e c a u s e i t i s n e g a t i v e
pos :
movew % d1 ,E T E M P _ E X ( % a6 )
| ;put exponent on stack
movew C M D R E G 1 B ( % a6 ) ,% d1
andw #0xe3ff ,% d1 | c l e a r o u t s o u r c e s p e c i f i e r
orw #0x0800 ,% d1 | s e t s o u r c e s p e c i f i e r t o e x t e n d e d p r e c
movew % d1 ,C M D R E G 1 B ( % a6 ) | w r i t e b a c k t o t h e c o m m a n d w o r d i n s t a c k
| ;this is needed to fix unsupp data stack
leal E T E M P ( % a6 ) ,% a0 | p o i n t a0 t o s o p
bsr m k _ n o r m | c o n v e r t s g l / d b l d e n o r m t o n o r m
moveb L _ S C R 1 ( % a6 ) ,S T A G ( % a6 ) | p u t t a g i n t o s o u r c e t a g r e g - d0
rts | e n d _ g e t o p
|
| At t h i s p o i n t , t h e s o u r c e i s d e f i n i t e l y p a c k e d , w h e t h e r
| instruction i s d y a d i c o r m o n a d i c i s s t i l l u n k n o w n
|
pack_source :
movel F P T E M P _ L O ( % a6 ) ,E T E M P ( % a6 ) | w r i t e m s p a r t o f p a c k e d
| ;number to etemp slot
bsr c h k _ d y _ m o | s e t d y a d i c / m o n a d i c f l a g
bsr u n p a c k
tstb D Y _ M O _ F L G ( % a6 )
beqs e n d _ g e t o p | i f m o n a d i c , e x i t
| ;else, fix FPTEMP
pack_dya :
bfextu C M D R E G 1 B ( % a6 ) { #6 : #3 } ,% d0 | e x t r a c t d e s t f p r e g
movel #7 ,% d1
subl % d0 ,% d1
clrl % d0
bsetl % d1 ,% d0 | s e t u p d0 a s a d y n a m i c r e g i s t e r m a s k
fmovemx % d0 ,F P T E M P ( % a6 ) | w r i t e t o F P T E M P
btstb #7 ,D T A G ( % a6 ) | c h e c k d e s t t a g f o r u n n o r m o r d e n o r m
bne d s t _ e x _ d n r m | e l s e , h a n d l e t h e u n n o r m o r e x t d e n o r m
|
| Dest i s n o t d e n o r m a l i z e d . C h e c k f o r n o r m , a n d s e t f p t e 1 5
| accordingly.
|
moveb D T A G ( % a6 ) ,% d0
andib #0xf0 ,% d0 | s t r i p t o o n l y d t a g : f p t e 1 5
tstb % d0 | c h e c k f o r n o r m a l i z e d v a l u e
bnes e n d _ g e t o p | i f i n f / n a n / z e r o l e a v e g e t _ o p
movew F P T E M P _ E X ( % a6 ) ,% d0
andiw #0x7fff ,% d0
cmpiw #0x3fff ,% d0 | c h e c k i f f p t e 1 5 n e e d s s e t t i n g
bges e n d _ g e t o p | i f > = $ 3 f f f , l e a v e f p t e 1 5 =0
orb #0x10 ,D T A G ( % a6 )
bras e n d _ g e t o p
|
| At t h i s p o i n t , i t i s e i t h e r a n f m o v e o u t p a c k e d , u n n o r m o r d e n o r m
|
opclass3 :
clrb D Y _ M O _ F L G ( % a6 ) | s e t d y a d i c / m o n a d i c f l a g t o m o n a d i c
bfextu C M D R E G 1 B ( % a6 ) { #4 : #2 } ,% d0
cmpib #3 ,% d0
bne s r c _ e x _ d n r m | i f n o t e q u a l , m u s t b e u n n o r m o r d e n o r m
| ;else it is a packed move out
| ;exit
end_getop :
rts
|
| Sets t h e D Y _ M O _ F L G c o r r e c t l y . T h i s i s u s e d o n l y o n i f i t i s a n
| unsupported d a t a t y p e e x c e p t i o n . S e t i f d y a d i c .
|
chk_dy_mo :
movew C M D R E G 1 B ( % a6 ) ,% d0
btstl #5 ,% d0 | t e s t i n g e x t e n s i o n c o m m a n d w o r d
beqs s e t _ m o n | i f b i t 5 = 0 t h e n m o n a d i c
btstl #4 ,% d0 | k n o w t h a t b i t 5 = 1
beqs s e t _ d y a | i f b i t 4 = 0 t h e n d y a d i c
andiw #0x007f ,% d0 | g e t r i d o f a l l b u t e x t e n s i o n b i t s { 6 : 0 }
cmpiw #0x0038 ,% d0 | i f e x t e n s i o n = $ 3 8 t h e n f c m p ( d y a d i c )
bnes s e t _ m o n
set_dya :
st D Y _ M O _ F L G ( % a6 ) | s e t t h e i n s t f l a g t y p e t o d y a d i c
rts
set_mon :
clrb D Y _ M O _ F L G ( % a6 ) | s e t t h e i n s t f l a g t y p e t o m o n a d i c
rts
|
| MK_ N O R M
|
| Normalizes u n n o r m a l i z e d n u m b e r s , s e t s t a g t o n o r m o r d e n o r m , s e t s u n f l
| exception i f d e n o r m .
|
| CASE o p c l a s s 0 x0 u n s u p p
| mk_ n o r m t i l l m s b s e t
| set t a g = n o r m
|
| CASE o p c l a s s 0 x0 u n i m p
| mk_ n o r m t i l l m s b s e t o r e x p = 0
| if i n t e g e r b i t = 0
| tag = d e n o r m
| else
| tag = n o r m
|
| CASE o p c l a s s 0 1 1 u n s u p p
| mk_ n o r m t i l l m s b s e t o r e x p = 0
| if i n t e g e r b i t = 0
| tag = d e n o r m
| set u n f l _ n m c e x e = 1
| else
| tag = n o r m
|
| if e x p < = $ 3 f f f
| set e t e 1 5 o r f p t e 1 5 = 1
| else s e t e t e 1 5 o r f p t e 1 5 = 0
| input :
| a0 = p o i n t s t o o p e r a n d t o b e n o r m a l i z e d
| output :
| L_ S C R 1 { 7 : 5 } = o p e r a n d t a g ( 0 0 0 = n o r m , 1 0 0 = d e n o r m )
| L_ S C R 1 { 4 } = f p t e 1 5 o r e t e 1 5 ( 0 = e x p > $ 3 f f f , 1 = e x p < = $ 3 f f f )
| the n o r m a l i z e d o p e r a n d i s p l a c e d b a c k o n t h e f s a v e s t a c k
mk_norm :
clrl L _ S C R 1 ( % a6 )
bclrb #s i g n _ b i t , L O C A L _ E X ( % a 0 )
sne L O C A L _ S G N ( % a0 ) | t r a n s f o r m i n t o i n t e r n a l e x t e n d e d f o r m a t
cmpib #0x2c ,1 + E X C _ V E C ( % a6 ) | c h e c k i f u n i m p
bnes u n s _ d a t a | b r a n c h i f u n s u p p
bsr u n i _ i n s t | c a l l i f u n i m p ( o p c l a s s 0 x0 )
bras r e l o a d
uns_data :
btstb #d i r e c t i o n _ b i t , C M D R E G 1 B ( % a6 ) | c h e c k t r a n s f e r d i r e c t i o n
bnes b i t _ s e t | b r a n c h i f s e t ( o p c l a s s 0 1 1 )
bsr u n s _ o p x | c a l l i f o p c l a s s 0 x0
bras r e l o a d
bit_set :
bsr u n s _ o p3 | o p c l a s s 0 1 1
reload :
cmpw #0x3fff ,L O C A L _ E X ( % a0 ) | i f e x p > $ 3 f f f
bgts e n d _ m k | f p t e 1 5 / e t e 1 5 a l r e a d y s e t t o 0
bsetb #4 ,L _ S C R 1 ( % a6 ) | e l s e s e t f p t e 1 5 / e t e 1 5 t o 1
| ;calling routine actually sets the
| ;value on the stack (along with the
| ;tag), since this routine doesn't
| ;know if it should set ete15 or fpte15
| ;ie, it doesn't know if this is the
| ;src op or dest op.
end_mk :
bfclr L O C A L _ S G N ( % a0 ) { #0 : #8 }
beqs e n d _ m k _ p o s
bsetb #s i g n _ b i t , L O C A L _ E X ( % a 0 ) | c o n v e r t b a c k t o I E E E f o r m a t
end_mk_pos :
rts
|
| CASE o p c l a s s 0 1 1 u n s u p p
|
uns_op3 :
bsr n r m _ z e r o | n o r m a l i z e t i l l m s b = 1 o r e x p = z e r o
btstb #7 ,L O C A L _ H I ( % a0 ) | i f m s b = 1
bnes n o _ u n f l | t h e n b r a n c h
set_unfl :
orw #d n r m _ t a g , L _ S C R 1 ( % a6 ) | s e t d e n o r m t a g
bsetb #u n f l _ b i t , F P S R _ E X C E P T ( % a 6 ) | s e t u n f l e x c e p t i o n b i t
no_unfl :
rts
|
| CASE o p c l a s s 0 x0 u n s u p p
|
uns_opx :
bsr n r m _ z e r o | n o r m a l i z e t h e n u m b e r
btstb #7 ,L O C A L _ H I ( % a0 ) | c h e c k i f i n t e g e r b i t ( j - b i t ) i s s e t
beqs u n s _ d e n | i f c l e a r t h e n n o w h a v e a d e n o r m
uns_nrm :
orb #n o r m _ t a g , L _ S C R 1 ( % a6 ) | s e t t a g t o n o r m
rts
uns_den :
orb #d n r m _ t a g , L _ S C R 1 ( % a6 ) | s e t t a g t o d e n o r m
rts
|
| CASE o p c l a s s 0 x0 u n i m p
|
uni_inst :
bsr n r m _ z e r o
btstb #7 ,L O C A L _ H I ( % a0 ) | c h e c k i f i n t e g e r b i t ( j - b i t ) i s s e t
beqs u n i _ d e n | i f c l e a r t h e n n o w h a v e a d e n o r m
uni_nrm :
orb #n o r m _ t a g , L _ S C R 1 ( % a6 ) | s e t t a g t o n o r m
rts
uni_den :
orb #d n r m _ t a g , L _ S C R 1 ( % a6 ) | s e t t a g t o d e n o r m
rts
|
| Decimal t o b i n a r y c o n v e r s i o n
|
| Special c a s e s o f i n f a n d N a N s a r e c o m p l e t e d o u t s i d e o f d e c b i n .
| If t h e i n p u t i s a n s n a n , t h e s n a n b i t i s n o t s e t .
|
| input :
| ETEMP( a6 ) - p o i n t s t o p a c k e d d e c i m a l s t r i n g i n m e m o r y
| output :
| fp0 - c o n t a i n s p a c k e d s t r i n g c o n v e r t e d t o e x t e n d e d p r e c i s i o n
| ETEMP - s a m e a s f p0
unpack :
movew C M D R E G 1 B ( % a6 ) ,% d0 | e x a m i n e c o m m a n d w o r d , l o o k i n g f o r f m o v e ' s
andw #0x3b ,% d0
beq m o v e _ u n p a c k | s p e c i a l h a n d l i n g f o r f m o v e : m u s t s e t F P S R _ C C
movew E T E M P ( % a6 ) ,% d0 | g e t w o r d w i t h i n f i n f o r m a t i o n
bfextu % d0 { #20 : #12 } ,% d1 | g e t e x p o n e n t i n t o d1
cmpiw #0x0fff ,% d1 | t e s t f o r i n f o r N a N
bnes t r y _ z e r o | i f n o t e q u a l , i t i s n o t s p e c i a l
bfextu % d0 { #17 : #3 } ,% d1 | g e t S E a n d y b i t s i n t o d1
cmpiw #7 ,% d1 | S E a n d y b i t s m u s t b e o n f o r s p e c i a l
bnes t r y _ z e r o | i f n o t o n , i t i s n o t s p e c i a l
| input i s o f t h e s p e c i a l c a s e s o f i n f a n d N a N
tstl E T E M P _ H I ( % a6 ) | c h e c k m s m a n t i s s a
bnes f i x _ n a n | i f n o n - z e r o , i t i s a N a N
tstl E T E M P _ L O ( % a6 ) | c h e c k l s m a n t i s s a
bnes f i x _ n a n | i f n o n - z e r o , i t i s a N a N
bra f i n i s h | s p e c i a l a l r e a d y o n s t a c k
fix_nan :
btstb #s i g n a n _ b i t , E T E M P _ H I ( % a 6 ) | t e s t f o r s n a n
bne f i n i s h
orl #s n a n i o p _ m a s k , U S E R _ F P S R ( % a 6 ) | a l w a y s s e t s n a n i f i t i s s o
bra f i n i s h
try_zero :
movew E T E M P _ E X + 2 ( % a6 ) ,% d0 | g e t w o r d 4
andiw #0x000f ,% d0 | c l e a r a l l b u t l a s t n i ( y ) b b l e
tstw % d0 | c h e c k f o r z e r o .
bne n o t _ s p e c
tstl E T E M P _ H I ( % a6 ) | c h e c k w o r d s 3 a n d 2
bne n o t _ s p e c
tstl E T E M P _ L O ( % a6 ) | c h e c k w o r d s 1 a n d 0
bne n o t _ s p e c
tstl E T E M P ( % a6 ) | t e s t s i g n o f t h e z e r o
bges p o s _ z e r o
movel #0x80000000 ,E T E M P ( % a6 ) | w r i t e n e g z e r o t o e t e m p
clrl E T E M P _ H I ( % a6 )
clrl E T E M P _ L O ( % a6 )
bra f i n i s h
pos_zero :
clrl E T E M P ( % a6 )
clrl E T E M P _ H I ( % a6 )
clrl E T E M P _ L O ( % a6 )
bra f i n i s h
not_spec :
fmovemx % f p0 - % f p1 ,- ( % a7 ) | s a v e f p0 - d e c b i n r e t u r n s i n i t
bsr d e c b i n
fmovex % f p0 ,E T E M P ( % a6 ) | p u t t h e u n p a c k e d s o p i n t h e f s a v e s t a c k
fmovemx ( % a7 ) + ,% f p0 - % f p1
fmovel #0 ,% F P S R | c l r f p s r f r o m d e c b i n
bra f i n i s h
|
| Special h a n d l i n g f o r p a c k e d m o v e i n : S a m e r e s u l t s a s a l l o t h e r
| packed c a s e s , b u t w e m u s t s e t t h e F P S R c o n d i t i o n c o d e s p r o p e r l y .
|
move_unpack :
movew E T E M P ( % a6 ) ,% d0 | g e t w o r d w i t h i n f i n f o r m a t i o n
bfextu % d0 { #20 : #12 } ,% d1 | g e t e x p o n e n t i n t o d1
cmpiw #0x0fff ,% d1 | t e s t f o r i n f o r N a N
bnes m t r y _ z e r o | i f n o t e q u a l , i t i s n o t s p e c i a l
bfextu % d0 { #17 : #3 } ,% d1 | g e t S E a n d y b i t s i n t o d1
cmpiw #7 ,% d1 | S E a n d y b i t s m u s t b e o n f o r s p e c i a l
bnes m t r y _ z e r o | i f n o t o n , i t i s n o t s p e c i a l
| input i s o f t h e s p e c i a l c a s e s o f i n f a n d N a N
tstl E T E M P _ H I ( % a6 ) | c h e c k m s m a n t i s s a
bnes m f i x _ n a n | i f n o n - z e r o , i t i s a N a N
tstl E T E M P _ L O ( % a6 ) | c h e c k l s m a n t i s s a
bnes m f i x _ n a n | i f n o n - z e r o , i t i s a N a N
| input i s i n f
orl #i n f _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t I b i t
tstl E T E M P ( % a6 ) | c h e c k s i g n
bge f i n i s h
orl #n e g _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t N b i t
bra f i n i s h | s p e c i a l a l r e a d y o n s t a c k
mfix_nan :
orl #n a n _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t N a N b i t
moveb #n a n _ t a g , S T A G ( % a 6 ) | s e t s t a g t o N a N
btstb #s i g n a n _ b i t , E T E M P _ H I ( % a 6 ) | t e s t f o r s n a n
bnes m n _ s n a n
orl #s n a n i o p _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t s n a n b i t
btstb #s n a n _ b i t , F P C R _ E N A B L E ( % a 6 ) | t e s t f o r s n a n e n a b l e d
bnes m n _ s n a n
bsetb #s i g n a n _ b i t , E T E M P _ H I ( % a 6 ) | f o r c e s n a n s t o q n a n s
mn_snan :
tstl E T E M P ( % a6 ) | c h e c k f o r s i g n
bge f i n i s h | i f c l r , g o o n
orl #n e g _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t N b i t
bra f i n i s h
mtry_zero :
movew E T E M P _ E X + 2 ( % a6 ) ,% d0 | g e t w o r d 4
andiw #0x000f ,% d0 | c l e a r a l l b u t l a s t n i ( y ) b b l e
tstw % d0 | c h e c k f o r z e r o .
bnes m n o t _ s p e c
tstl E T E M P _ H I ( % a6 ) | c h e c k w o r d s 3 a n d 2
bnes m n o t _ s p e c
tstl E T E M P _ L O ( % a6 ) | c h e c k w o r d s 1 a n d 0
bnes m n o t _ s p e c
tstl E T E M P ( % a6 ) | t e s t s i g n o f t h e z e r o
bges m p o s _ z e r o
orl #n e g _ m a s k + z _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t N a n d Z
movel #0x80000000 ,E T E M P ( % a6 ) | w r i t e n e g z e r o t o e t e m p
clrl E T E M P _ H I ( % a6 )
clrl E T E M P _ L O ( % a6 )
bras f i n i s h
mpos_zero :
orl #z _ m a s k , U S E R _ F P S R ( % a 6 ) | s e t Z
clrl E T E M P ( % a6 )
clrl E T E M P _ H I ( % a6 )
clrl E T E M P _ L O ( % a6 )
bras f i n i s h
mnot_spec :
fmovemx % f p0 - % f p1 ,- ( % a7 ) | s a v e f p0 ,f p1 - d e c b i n r e t u r n s i n f p0
bsr d e c b i n
fmovex % f p0 ,E T E M P ( % a6 )
| ;put the unpacked sop in the fsave stack
fmovemx ( % a7 ) + ,% f p0 - % f p1
finish :
movew C M D R E G 1 B ( % a6 ) ,% d0 | g e t t h e c o m m a n d w o r d
andw #0xfbff ,% d0 | c h a n g e t h e s o u r c e s p e c i f i e r f i e l d t o
| ;extended (was packed).
movew % d0 ,C M D R E G 1 B ( % a6 ) | w r i t e c o m m a n d w o r d b a c k t o f s a v e s t a c k
| ;we need to do this so the 040 will
| ;re-execute the inst. without taking
| ;another packed trap.
fix_stag :
| Converted r e s u l t i s n o w i n e t e m p o n f s a v e s t a c k , n o w s e t t h e s o u r c e
| tag ( s t a g )
| if ( e t e = $ 7 f f f ) t h e n I N F o r N A N
| if ( e t e m p = $ x . 0 - - - - 0 ) t h e n
| stag = I N F
| else
| stag = N A N
| else
| if ( e t e = $ 0 0 0 0 ) t h e n
| stag = Z E R O
| else
| stag = N O R M
|
| Note a l s o t h a t t h e e t e m p _ 1 5 b i t ( j u s t r i g h t o f t h e s t a g ) m u s t
| be s e t a c c o r d i n g l y .
|
movew E T E M P _ E X ( % a6 ) ,% d1
andiw #0x7fff ,% d1 | s t r i p s i g n
cmpw #0x7fff ,% d1
bnes z _ o r _ n r m
movel E T E M P _ H I ( % a6 ) ,% d1
bnes i s _ n a n
movel E T E M P _ L O ( % a6 ) ,% d1
bnes i s _ n a n
is_inf :
moveb #0x40 ,S T A G ( % a6 )
movel #0x40 ,% d0
rts
is_nan :
moveb #0x60 ,S T A G ( % a6 )
movel #0x60 ,% d0
rts
z_or_nrm :
tstw % d1
bnes i s _ n r m
is_zro :
| For a z e r o , s e t e t e m p _ 1 5
moveb #0x30 ,S T A G ( % a6 )
movel #0x20 ,% d0
rts
is_nrm :
| For a n o r m , c h e c k i f t h e e x p < = $ 3 f f f ; if so, set etemp_15
cmpiw #0x3fff ,% d1
bles s e t _ b i t 1 5
moveb #0 ,S T A G ( % a6 )
bras e n d _ i s _ n r m
set_bit15 :
moveb #0x10 ,S T A G ( % a6 )
end_is_nrm :
movel #0 ,% d0
end_fix :
rts
end_get :
rts
| end