- #1
Dissident Dan
- 238
- 2
I'm writing a program in C++ in MS Visual Studio.NET, and I am using inline assembly to do some SSE instructions.
The trouble is that I am having a hard time getting the assembly to accep the addresses from my C++ from anyting other than explicitly-declared pointers (not even arrays work!). I end up putting extra variables on the stack so I can get pointers to my data, and I believe that this is causing a performance penalty (CPU time).
My code is this:
Is there any way that I can get the inline assembly to use the needed addresses without the extra Vector3 pointer variables? (And if you have any other optimization suggestions, I'll be glad to hear them. )
The trouble is that I am having a hard time getting the assembly to accep the addresses from my C++ from anyting other than explicitly-declared pointers (not even arrays work!). I end up putting extra variables on the stack so I can get pointers to my data, and I believe that this is causing a performance penalty (CPU time).
My code is this:
Code:
inline Vector3 operator +(Vector3 &v) const {
float result[4];
Vector3 *vout = (Vector3 *)result;
Vector3 *vin = &v;
_asm {
mov esi, vin;
mov edi, vout;
mov eax, this;
movups xmm0, [eax];
movups xmm1, [esi];
addps xmm0, xmm1;
movups [edi], xmm0;
}
return *(Vector3 *)result;
}
Is there any way that I can get the inline assembly to use the needed addresses without the extra Vector3 pointer variables? (And if you have any other optimization suggestions, I'll be glad to hear them. )