Page 1 of 1

sum of xmm register

Posted: Wed Mar 08, 2023 4:22 pm
by jack
suppose that xmm0 has 4 floats, how would you sum-up the values into the lowest part of xmm0 ?
pseudo code xmm0\0 = xmm0\0 + xmm0\1 + xmm0\2 + xmm0\3
and likewise if xmm0 had 2 doubles

// Moved from "Coding Questions" to "Assembly Programming" (Kiffi)

Re: sum of xmm register

Posted: Wed Mar 08, 2023 4:48 pm
by STARGÅTE
https://www.felixcloutier.com/x86/haddps

Code: Select all

! HADDPS  xmm0, xmm0
! HADDPS  xmm0, xmm0

Re: sum of xmm register

Posted: Wed Mar 08, 2023 4:51 pm
by jack
thanks STARGÅTE :)
I was hoping for a single instruction