Advertisement
pasholnahuy

Untitled

Dec 4th, 2023
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. .global product
  2.  
  3. product:
  4. push %ebp
  5. mov %esp, %ebp
  6. mov 8(%ebp), %eax //n
  7. mov 12(%ebp), %ecx // *x
  8. mov 16(%ebp), %edx // *y
  9. push %edi
  10. xor %edi, %edi // ind
  11. pxor %xmm2, %xmm2
  12.  
  13. loop:
  14. add $3, %edi
  15. cmp %eax, %edi
  16. jge calculate_remains
  17. sub $3, %edi
  18. movups (%ecx, %edi, 4), %xmm0
  19. movups (%edx, %edi, 4), %xmm1
  20. mulps %xmm0, %xmm1
  21. pxor %xmm0, %xmm0
  22. addsubps %xmm1, %xmm0
  23. subps %xmm1, %xmm2
  24. add $4, %edi
  25. jmp loop
  26.  
  27. calculate_remains:
  28. sub $3, %edi
  29. loop_remains:
  30. cmp %edi, %eax
  31. je call_ret
  32. movss (%ecx, %edi, 4), %xmm3
  33. movss (%edx, %edi, 4), %xmm4
  34. mulss %xmm3, %xmm4
  35. test $1, %edi
  36. jz do_sub
  37. addss %xmm4, %xmm2
  38. inc %edi
  39. jmp loop_remains
  40.  
  41. do_sub:
  42. subss %xmm4, %xmm2
  43. inc %edi
  44. jmp loop_remains
  45.  
  46. call_ret:
  47. mov 20(%ebp), %eax
  48. movss %xmm2, (%eax)
  49. pop %edi
  50. mov %ebp, %esp
  51. pop %ebp
  52. ret
  53.  
  54.  
  55.  
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement