Advertisement
RaWRCoder

Vector sum v2

Oct 10th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 1.
  2. static float4 operator+(const float4& A, const float4& B)
  3. {
  4.     float4 C;
  5.     auto a = _mm_load_ps(&A.x);
  6.     auto b = _mm_load_ps(&B.x);
  7.     _mm_store_ps(&C.x, _mm_add_ps(a, b));
  8.     return C;
  9. }
  10.  
  11. //2.
  12. static void summ(const float4* A, const float4* B, float4* C)
  13. {
  14.     __asm
  15.     {
  16.         lea eax, A;
  17.         lea ebx, B;
  18.  
  19.         mov eax, [eax];
  20.         mov ebx, [ebx];
  21.  
  22.         movaps xmm0, [eax];
  23.         movaps xmm1, [ebx];
  24.         addps xmm0, xmm1;
  25.         movaps[edx], xmm0;
  26.  
  27.         mov C, edx;
  28.     }
  29. }
  30.  
  31. //3.
  32. static void ssumm(const float4* A, const float4* B, float4* C)
  33. {
  34.     C->x = A->x + B->x;
  35.     C->y = A->y + B->y;
  36.     C->z = A->z + B->z;
  37.     C->w = A->w + B->w;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement