1# SSE2 assist routines for peakval 2# Copyright 2001 Phil Karn, KA9Q 3# May be used under the terms of the GNU Lesser General Public License (LGPL) 4 5 .text 6 7# Find peak absolute value in signed 16-bit input samples 8# int peakval_sse2_assist(signed short *in,int cnt); 9 .global peakval_sse2_assist 10 .type peakval_sse2_assist,@function 11 .align 16 12peakval_sse2_assist: 13 pushl %ebp 14 movl %esp,%ebp 15 pushl %esi 16 pushl %ecx 17 18 movl 8(%ebp),%esi 19 movl 12(%ebp),%ecx 20 21 pxor %xmm7,%xmm7 # clear peak 22 231: subl $8,%ecx 24 jl 2f 25 movaps (%esi),%xmm0 26 movaps %xmm0,%xmm1 27 psraw $15,%xmm1 # xmm1 = 1's if negative, 0's if positive 28 pxor %xmm1,%xmm0 # complement negatives 29 psubw %xmm1,%xmm0 # add 1 to negatives 30 pmaxsw %xmm0,%xmm7 # store peak 31 32 addl $16,%esi 33 jmp 1b 34 352: movaps %xmm7,%xmm0 36 psrldq $8,%xmm0 37 pmaxsw %xmm0,%xmm7 38 movaps %xmm7,%xmm0 39 psrlq $32,%xmm0 40 pmaxsw %xmm0,%xmm7 41 movaps %xmm7,%xmm0 42 psrlq $16,%xmm0 43 pmaxsw %xmm0,%xmm7 # min value in low word of %xmm7 44 45 movd %xmm7,%eax 46 andl $0xffff,%eax 47 48 popl %ecx 49 popl %esi 50 popl %ebp 51 ret 52