2011-03-11 13:57:03 +03:00
/ *
decode_ M M X . s : M M X o p t i m i z e d s y n t h
copyright ? - 2 0 0 6 b y t h e m p g 1 2 3 p r o j e c t - f r e e s o f t w a r e u n d e r t h e t e r m s o f t h e L G P L 2 . 1
see C O P Y I N G a n d A U T H O R S f i l e s i n d i s t r i b u t i o n o r h t t p : / / m p g 1 2 3 . o r g
initially w r i t t e n b y t h e m y s t e r i o u s h i g w a y ( a p p a r e n t l y )
Thomas' w o r d s a b o u t a n o t e :
Initially, I f o u n d t h e n o t e " t h i s c o d e c o m e s u n d e r G P L " i n t h i s f i l e .
After a s k i n g M i c h a e l a b o u t l e g a l s t a t u s o f t h e M M X f i l e s , h e s a i d t h a t h e g o t t h e m w i t h o u t a n y c o m m e n t a n d t h u s I b e l i e v e t h a t t h e G P L c o m m e n t w a s m a d e b y M i c h a e l , s i n c e h e m a d e m p g 1 2 3 G P L a t s o m e t i m e - a n d m a r k e d s o m e f i l e s t h a t w a y , b u t n o t a l l .
Based o n t h a t t h o u g h t , I n o w c o n s i d e r t h i s f i l e a l o n g w i t h t h e o t h e r p a r t s o f h i g w a y ' s M M X o p t i m i z a t i o n t o b e l i c e n s e d u n d e r L G P L 2 . 1 b y M i c h a e l ' s d e c i s i o n .
* /
# include " m a n g l e . h "
.text
.globl ASM_ N A M E ( s y n t h _ 1 t o 1 _ M M X )
/* int synth_1to1_MMX(real *bandPtr, int channel, short *out, short *buffs, int *bo, float *decwins); */
ASM_ N A M E ( s y n t h _ 1 t o 1 _ M M X ) :
pushl % e b p
pushl % e d i
pushl % e s i
pushl % e b x
/* stack: 0=ebx, 4=esi, 8=edi, 12=ebp, 16=back, 20=bandPtr, 24=channel, 28=out, 32=buffs, 36=bo, 40=decwins */
movl 2 4 ( % e s p ) ,% e c x
movl 2 8 ( % e s p ) ,% e d i
movl $ 1 5 ,% e b x
movl 3 6 ( % e s p ) ,% e d x
leal ( % e d i ,% e c x ,2 ) ,% e d i
decl % e c x
movl 3 2 ( % e s p ) ,% e s i
movl ( % e d x ) ,% e a x
jecxz . L 1
decl % e a x
andl % e b x ,% e a x
leal 1 0 8 8 ( % e s i ) ,% e s i
movl % e a x ,( % e d x )
.L1 :
leal ( % e s i ,% e a x ,2 ) ,% e d x
movl % e a x ,% e b p
incl % e a x
pushl 2 0 ( % e s p )
andl % e b x ,% e a x
leal 5 4 4 ( % e s i ,% e a x ,2 ) ,% e c x
incl % e b x
testl $ 1 , % e a x
jnz . L 2
xchgl % e d x ,% e c x
incl % e b p
leal 5 4 4 ( % e s i ) ,% e s i
.L2 :
pushl % e d x
pushl % e c x
call A S M _ N A M E ( d c t 6 4 _ M M X )
addl $ 1 2 ,% e s p
/* stack like before, pushed 3, incremented again */
leal 1 ( % e b x ) , % e c x
subl % e b p ,% e b x
pushl % e a x
movl 4 4 ( % e s p ) ,% e a x / * d e c w i n s * /
leal ( % e a x ,% e b x ,2 ) , % e d x
popl % e a x
.L3 :
movq ( % e d x ) ,% m m 0
pmaddwd ( % e s i ) ,% m m 0
movq 8 ( % e d x ) ,% m m 1
pmaddwd 8 ( % e s i ) ,% m m 1
movq 1 6 ( % e d x ) ,% m m 2
pmaddwd 1 6 ( % e s i ) ,% m m 2
movq 2 4 ( % e d x ) ,% m m 3
pmaddwd 2 4 ( % e s i ) ,% m m 3
paddd % m m 1 ,% m m 0
paddd % m m 2 ,% m m 0
paddd % m m 3 ,% m m 0
movq % m m 0 ,% m m 1
psrlq $ 3 2 ,% m m 1
paddd % m m 1 ,% m m 0
psrad $ 1 3 ,% m m 0
packssdw % m m 0 ,% m m 0
movd % m m 0 ,% e a x
movw % a x , ( % e d i )
leal 3 2 ( % e s i ) ,% e s i
leal 6 4 ( % e d x ) ,% e d x
leal 4 ( % e d i ) ,% e d i
loop . L 3
subl $ 6 4 ,% e s i
movl $ 1 5 ,% e c x
.L4 :
movq ( % e d x ) ,% m m 0
pmaddwd ( % e s i ) ,% m m 0
movq 8 ( % e d x ) ,% m m 1
pmaddwd 8 ( % e s i ) ,% m m 1
movq 1 6 ( % e d x ) ,% m m 2
pmaddwd 1 6 ( % e s i ) ,% m m 2
movq 2 4 ( % e d x ) ,% m m 3
pmaddwd 2 4 ( % e s i ) ,% m m 3
paddd % m m 1 ,% m m 0
paddd % m m 2 ,% m m 0
paddd % m m 3 ,% m m 0
movq % m m 0 ,% m m 1
psrlq $ 3 2 ,% m m 1
paddd % m m 0 ,% m m 1
psrad $ 1 3 ,% m m 1
packssdw % m m 1 ,% m m 1
psubd % m m 0 ,% m m 0
psubsw % m m 1 ,% m m 0
movd % m m 0 ,% e a x
movw % a x ,( % e d i )
subl $ 3 2 ,% e s i
addl $ 6 4 ,% e d x
leal 4 ( % e d i ) ,% e d i
loop . L 4
emms
popl % e b x
popl % e s i
popl % e d i
popl % e b p
ret
2013-10-02 20:44:03 +04:00
NONEXEC_ S T A C K