用在FFT中还是不错的。
FSINCOS D9 FB 设置C1,C2 (C0,C3 未定义) SinCos函数: ST(0)←sine(ST(0)),PUSH cosine(ST(0))
============================================================
.386
.model flat,stdcall
option casemap:none
.data
ConsPi_180 real8 0.017453292519943295769
.code
;-----------------------------------------------------------
_Degree2SinCos proc deg:real4,lpcos:dword,lpsin:dword
mov esi,lpsin
mov edi,lpcos
finit
fld real4 ptr[deg]
fld qword ptr [ConsPi_180]
fmul st(0),st(1)
fsincos
fstp QWORD ptr[esi]
fst QWORD ptr[edi]
ret
_Degree2SinCos endp
;-----------------------------------------------------------
_Rad2SinCos proc rad:real8,lpcos:dword,lpsin:dword
mov esi,lpsin
mov edi,lpcos
finit
fld real8 ptr[rad]
fsincos
fstp QWORD ptr[esi]
fst QWORD ptr[edi]
ret
_Rad2SinCos endp
end
=========================================
c调用:
#include <stdio.h>
#define PI 3.1415926535897932
#ifdef __cplusplus
#include <windows.h>
extern "C" {
#endif
void _stdcall _Degree2SinCos(float degree,double *sin,double *cos);
void _stdcall _Rad2SinCos(double Rad,double *sin,double *cos);
#ifdef __cplusplus
}
#endif
int main()
{
float deg=30.0;
double rad=30.0*PI/180.0;
double sin,cos;
_Degree2SinCos(deg,&sin,&cos);
printf("_Degree2SinCos:/ncos(%.4f)=%18.16lf/nsin(%.4f)=%18.16lf/n",deg,cos,deg,sin);
_Rad2SinCos(rad,&sin,&cos);
printf("_Rad2SinCos:/ncos(%.4f)=%18.16lf/nsin(%.4f)=%18.16lf/n",rad,cos,rad,sin);
system("PAUSE");
return 0;
}
=================================
执行结果:
_Degree2SinCos:
cos(30.0000)=0.8660254037844386
sin(30.0000)=0.5000000000000000
_Rad2SinCos:
cos(0.5236)=0.8660254037844387
sin(0.5236)=0.4999999999999999