Original Post
Hello, Community I was just porting my inline assembler code for code in MASM, but when I run my program, the 'this' pointer seems to change very eratically. Thanks for any help, and thanks for the help in previous posts. It's been great![smile] exorcist_bob
.686P
.MMX
.XMM
.MODEL FLAT, C
.CODE
Matrix3Add PROC mat1:DWORD, mat2:DWORD, mat3:DWORD
mov eax, dword ptr[mat1]
mov ebx, dword ptr[mat3]
mov ecx, dword ptr[mat2]
movaps xmm0, dword ptr[ecx]
movaps xmm1, dword ptr[ecx + 10h]
addps xmm0, dword ptr[eax]
addps xmm1, dword ptr[eax + 10h]
movaps [ebx], xmm0
movaps [ebx + 10h], xmm1
fld dword ptr [ecx+20h]
fadd dword ptr [eax+20h]
fstp dword ptr [ebx+20h]
mov ecx, dword ptr[mat2]
ret
Matrix3Add ENDP
END
extern "C" void Matrix3Add( Matrix3* mat1, Matrix3* mat2, Matrix3* mat3 );
inline Matrix3 Matrix3::operator+ ( const Matrix3& mat )
{
Matrix3 matReturn;
Matrix3Add((Matrix3*)&mat, this, &matReturn);
return matReturn; // mat, this and matReturn are still valid
};
inline Matrix3(const Matrix3& mat)
{
__asm
{
mov ecx, 0x9
mov esi, dword ptr[mat]
mov edi, this //'this' now points to some random value
rep movsd
};
};