Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global product
- product:
- push %ebp
- mov %esp, %ebp
- mov 8(%ebp), %eax //n
- mov 12(%ebp), %ecx // *x
- mov 16(%ebp), %edx // *y
- push %edi
- xor %edi, %edi // ind
- pxor %xmm2, %xmm2
- loop:
- add $3, %edi
- cmp %eax, %edi
- jge calculate_remains
- sub $3, %edi
- movups (%ecx, %edi, 4), %xmm0
- movups (%edx, %edi, 4), %xmm1
- mulps %xmm0, %xmm1
- pxor %xmm0, %xmm0
- addsubps %xmm1, %xmm0
- subps %xmm1, %xmm2
- add $4, %edi
- jmp loop
- calculate_remains:
- sub $3, %edi
- loop_remains:
- cmp %edi, %eax
- je call_ret
- movss (%ecx, %edi, 4), %xmm3
- movss (%edx, %edi, 4), %xmm4
- mulss %xmm3, %xmm4
- test $1, %edi
- jz do_sub
- addss %xmm4, %xmm2
- inc %edi
- jmp loop_remains
- do_sub:
- subss %xmm4, %xmm2
- inc %edi
- jmp loop_remains
- call_ret:
- mov 20(%ebp), %eax
- movss %xmm2, (%eax)
- pop %edi
- mov %ebp, %esp
- pop %ebp
- ret
Add Comment
Please, Sign In to add comment