flat assembler
Message board for the users of flat assembler.
Index
> Main > Fast Fourier sse for wav sound? I looking for example |
Author |
|
Roman 14 Sep 2024, 13:33
I looking example.
Fast Fourier transform – FFT |
|||
14 Sep 2024, 13:33 |
|
Roman 15 Sep 2024, 09:03
write to fasm
Code: macro ExitMsg a { invoke MessageBox,0,a,'ExitToWin',0 invoke ExitProcess,0 } section '.code' code readable writeable executable align 16 p2 dd 1.0,0,0,0 p3 dd 2.0,0,0,0 point dd 8.0,0,0,0 Start: push 2 ;size_data push xmDbgTxt ;out_data push p2 ;in_data call FFT_SSE2 ExitMsg 'exit' in_data equ dword [ebp+8] out_data equ dword [ebp+12] size_data equ dword [ebp+16] ; local dtemp equ dword [ebp-4] ;dd 0 ftemp equ qword [ebp-12] ;dq 0.0 wr equ qword [ebp-20] ;dq 0.0 wi equ qword [ebp-28] ;dq 0.0 FFT_SSE2: push ebp mov ebp, esp sub esp, 28 push ebx push esi push edi ; memcpy(out_Buffer, in_Buffer, fftFrameSize*2*sizeof(double)); mov ecx, size_data shl ecx, 2 ; * 2 * sizeof(double) mov esi, in_data mov edi, out_data rep movsd mov ecx, 2 ; ecx - i _l0: mov edx, 2 ; edx - bitm xor ebx, ebx ; ebx - j _l1: mov eax, ecx and eax, edx jz _l3 inc ebx _l3: shl ebx, 1 shl edx, 1 mov eax, size_data shl eax, 1 cmp edx, eax jb _l1 cmp ecx, ebx jnb _l4 mov eax, out_data movapd xmm0, dqword [eax+ecx*8] ; p1 = out_Buffer+i movapd xmm1, dqword [eax+ebx*8] ; p2 = out_Buffer+j movapd dqword [eax+ecx*8], xmm1 movapd dqword [eax+ebx*8], xmm0 _l4: add ecx, 2 mov eax, size_data shl eax, 1 sub eax, 2 cmp ecx, eax jb _l0 fld1 fild size_data fyl2x frndint fistp dtemp ; (long)log2(size) mov edx, dtemp xor ecx, ecx ; ecx - k mov ebx, 2 ; ebx - le main_loop: push edx mov eax, ebx shl ebx, 1 fldpi shr eax, 1 mov dtemp, eax fidiv dtemp ; st(0): arg = pi / (le2>>1) fsincos ; st(0)=cos(arg) st(1)=sin(arg) fstp wr fchs fstp wi xorpd xmm2, xmm2 ; ur|ui fld1 fstp ftemp movlps xmm2, ftemp xor esi, esi ; esi - j _loop1: mov eax, out_data mov edx, esi shl edx, 3 add eax, edx ; eax = out_data + j mov edi, esi _loop2: movapd xmm3, xmm2 ; push xmm2 movapd xmm0, xmm2 movddup xmm1, qword [eax+ebx*4+8] movddup xmm2, qword [eax+ebx*4] mulpd xmm2, xmm0 shufpd xmm0, xmm0, 1 mulpd xmm1, xmm0 addsubpd xmm2, xmm1 movapd xmm0, dqword [eax] ; *p1 subpd xmm0, xmm2 movapd dqword [eax+ebx*4], xmm0 movapd xmm0, dqword [eax] addpd xmm0, xmm2 movapd dqword [eax], xmm0 movapd xmm2, xmm3 ; pop xmm2 push ebx shl ebx, 3 add eax, ebx pop ebx add edi, ebx mov edx, size_data shl edx, 1 cmp edi, edx jb _loop2 movapd xmm0, xmm2 movddup xmm1, wi movddup xmm2, wr mulpd xmm2, xmm0 shufpd xmm0, xmm0, 1 mulpd xmm1, xmm0 addsubpd xmm2, xmm1 add esi, 2 mov eax, ebx shr eax, 1 cmp esi, eax jb _loop1 inc ecx pop edx cmp ecx, edx jb main_loop pop edi pop esi pop ebx mov esp, ebp pop ebp ret SECTION '.idata' IMPORT DATA READABLE WRITEABLE library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL',\ winmm, 'WINMM.DLL',\ msvcrt, 'MSVCRT.DLL' include 'fasmAPI\kernel32.inc' include 'fasmAPI\user32.inc' include 'fasmAPI\winmm.inc' include 'fasmAPI\msvcrt.inc' section '.bss' readable writeable align 16 xmDbgTxt rd 8000 |
|||
15 Sep 2024, 09:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.