Code: Select all
float sinu32(uint32_t phase)
{
return sinf((float)phase * (3.1415926536f / 2147483648.f))
}The above code executes 67108864 sine calculations in ~2.9 seconds on my Athlon 64 X2 @ 2.4GHz, my assembler sine does the same job in ~1.3 seconds:
Code: Select all
[bits 32]
[section .bss]
[section .data]
ALIGN 16
fpi: dd 0x3fc90fdb ; pi*0.5
frf3: dd 0xbe2aaaab ; -1 / 6
frf5: dd 0x3c088889 ; 1 / 120
frf7: dd 0xb9500d01 ; -1 / 5040
frf9: dd 0x3638ef1d ; 1 / 362880
[section .text]
global _nfastsin2
_nfastsin2:
push eax
push ebx
mov eax, dword[esp + 4 + 8]
mov ebx, eax
and ebx, 0x80000000
or ebx, 0x3f800000
push ebx
mov ebx, 0x00800000
bt eax, 30
sbb ebx, 0
shr eax, 7
xor ebx, eax
or ebx, 0x3f800000
push ebx
fld dword[esp]
fld1
fsubp
fmul dword[esp + 4]
fmul dword[fpi]
fld st0
fmul st0, st1
fld st0
fmul dword[frf9]
fadd dword[frf7]
fmul st0, st1
fadd dword[frf5]
fmul st0, st1
fadd dword[frf3]
fmulp st1, st0
fld1
faddp
fmulp st1, st0
add esp, 8
pop ebx
pop eax
retCode: Select all
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef WIN32
float _cdecl nfastsin2(unsigned __int32 p);
#else
# include <stdint.h>
# define _cdecl __attribute__((__cdecl__))
float _cdecl _nfastsin2(uint32_t p);
# define nfastsin2(x) _nfastsin2(x)
#endif
#ifdef __cplusplus
}
#endif(This routine is the 1-sine version of my SSE additive oscillator core ... I think I posted the sources to the 64 bands add-osc somewhere here in this forum ... but I'll repost it, if somebody is interested)

