1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
extern int __fastcall mod2(float *X, float *Y);
__declspec(naked) int __fastcall mod2(float *X, float *Y)
{
__asm {
; fascall Microsoft => arg1 dans ECX, arg2 dans EDX
movshdup xmm0,[ecx] ; multiplier imag (b1, b1, b0, b0)
movaps xmm1,[edx] ; multiplicand (d1, c1, d0, c0)
mulps xmm0, xmm1 ; temp1 (b1d1, b1c1, b0d0, b0c0)
shufps xmm1, xmm1, 0xb1 ; shuf multiplicand(c1, d1, c0, d0)
movsldup xmm2,[ecx] ; multiplier real (a1, a1,a0, a0 )
mulps xmm2, xmm1 ; temp2 (a1c1, a1d1, a0c0, a0d0)
addsubps xmm2, xmm0 ; a1c1+b1d1, a1d1-b1c1, a0c0+b0d0, a0d0-b0c0
movaps xmm3, xmm2;
; fascall Microsoft => valeur retour dans EAX si declaration en
movd eax, xmm3;
ret;
}
typdedef struct _CPLX
{
float r;
float i;
} complexe;
int main(void)
{
<div style="margin-left:40px">
complexe X,Y;
float module2;
...
*(int*) &module2 = mod2((float*) &X, (float*) &Y);
...
return 0;</div>} |
Partager