SSE, Inline assembler, Structs, ...

Audun Wilhelmsen seronor at gmail.com
Tue Apr 1 05:33:53 PDT 2008


I want to use SSE to create a fast vector/matrix library (if anyone has done this already I'd like to know). 

It seems that there's quite a bit of overhead with operator overloading, so I'd probably want to write some of the algorithms in my final app in assembly, but I'd still like to have optimized operators too. But I'm having some problems. I can't get this to work for instance:
align struct Vec 4 {
  float x,y,z,w;
  ....
Vec4 opAdd(Vec4 v) {
  Vec4 res;
  asm {
    movaps XMM0, [this]; 
    addps XMM0, v[EBP];
    movaps res[EBP], XMM0;
  }
  return res;
}
}

if i add Vec4  *me = this and replace this with me it compiles, but it crashes.

Also, this confuses me:
	Vec4 v1 = Vec4(1,2,3,4);
//	Vec4* p = &v1;
	asm {
		movaps XMM1, v1[EBP]; 
	}

if I remove the comment, the program crashes.









More information about the Digitalmars-d-learn mailing list