Bill Yi | 4e213d5 | 2015-06-23 13:53:11 -0700 | [diff] [blame] | 1 | # SSE 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_sse(signed short *in,int cnt); |
| 9 | .global peakval_sse |
| 10 | .type peakval_sse,@function |
| 11 | .align 16 |
| 12 | peakval_sse: |
| 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 %mm7,%mm7 # clear peak |
| 22 | |
| 23 | 1: subl $4,%ecx |
| 24 | jl 2f |
| 25 | movq (%esi),%mm0 |
| 26 | movq %mm0,%mm1 |
| 27 | psraw $15,%mm1 # mm1 = 1's if negative, 0's if positive |
| 28 | pxor %mm1,%mm0 # complement negatives |
| 29 | psubw %mm1,%mm0 # add 1 to negatives |
| 30 | pmaxsw %mm0,%mm7 # store peak |
| 31 | |
| 32 | addl $8,%esi |
| 33 | jmp 1b |
| 34 | |
| 35 | 2: movq %mm7,%mm0 |
| 36 | psrlq $32,%mm0 |
| 37 | pmaxsw %mm0,%mm7 |
| 38 | movq %mm7,%mm0 |
| 39 | psrlq $16,%mm0 |
| 40 | pmaxsw %mm0,%mm7 # min value in low word of %mm7 |
| 41 | |
| 42 | movd %mm7,%eax |
| 43 | andl $0xffff,%eax |
| 44 | |
| 45 | emms |
| 46 | popl %ecx |
| 47 | popl %esi |
| 48 | popl %ebp |
| 49 | ret |