c++ inline assembler and oop



Hi,

I have a problem when using inline assembler in Visual C++ .NET:

I have a vector-class and try to implement the vector operations with SSE. My problem is, that I don't exactly know, how to access class-members within an asm-block.

Here's how I try to do it - and I don't know if it's correct:

class Vec3 {
public:
  ... //some member-functions
  float x, y, z;
};

class SomeClassUsingVec3 {
public:
  ...
  void calcSomething() {
    ...
    __asm {
      ;load v1 in xmm0
      mov     ebx, this
      lea     eax, [ebx].v1
      movaps  xmm0, eax
      ;load v2 in xmm1
      lea     eax, [ebx].v2
      movaps  xmm0, eax
      ...
      ;write xmm0 back to v1
      movaps  eax, xmm0
      ...
    }
    ...
  }

  __declspec(align(16)) Vec3 v1, v2;
};



Thanks in advance!

Frank

.



Relevant Pages