Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. .intel_syntax noprefix
  2. .text
  3. .global dot_product
  4. dot_product:
  5. push ebp
  6. mov ebp, esp
  7. push ebx
  8. mov ebx, [esp + 8]
  9. mov edx, [esp + 12]
  10. mov eax, [esp + 8]
  11. cycle:
  12. cmp eax, 4
  13. jb add_last
  14. sub eax, 4
  15.  
  16. movups xmm1, [ebx + 4 * eax]
  17. movups xmm2, [edx + 4 * eax]
  18. mulps xmm1, xmm2
  19. haddps xmm1, xmm1
  20. haddps xmm1, xmm1
  21. addss xmm0, xmm1
  22. jmp cycle
  23. add_last:
  24. cmp eax, 0
  25. je exit
  26. sub eax, 1
  27. movss xmm1, [ebx + 4 * eax]
  28. movss xmm2, [edx + 4 * eax]
  29. mulss xmm1, xmm2
  30. addss xmm0, xmm1
  31. jmp add_last
  32. exit:
  33. sub esp, 4
  34. movss [esp], xmm0
  35. fld dword ptr [esp]
  36. add esp, 4
  37. pop ebx
  38. mov esp, ebp
  39. pop ebp
  40. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement