I want to multiply the data stored in one xmm register with a single float value and save the result in a xmm register. I made a little graphic to explain it a bit better.
As you see I got a xmm0 register with my data in it. For example it contains:
xmm0 = |4.0|2.5|3.5|2.0|
Each floating point is stored in 4 bytes. My xmm0 register is 128 bits, 16 bytes long.
That works pretty good. Now I want to store 0.5 in another xmm register, e.g. xmm1, and multiply this register with the xmm0 register so that each value stored in xmm0 is multiplied with 0.5.
I have absolutely no idea how to store 0.5 in an XMM register. Any suggestions?
Btw: It's Inline Assembler in C++.
void filter(image* src_image, image* dst_image)
{
float* src = src_image->data;
float* dst = dst_image->data;
__asm__ __volatile__ (
"movaps (%%esi), %%xmm0\n"
// Multiply %xmm0 with a float, e.g. 0.5
"movaps %%xmm0, (%%edi)\n"
:
: "S"(src), "D"(dst) :
);
}
This is the quiet simple version of the thing i want to do. I got some image data stored in a float array. The pointer to these arrays are passed to assembly. movaps takes the first 4 float values of the array, stores these 16 bytes in the xmm0 register. After this xmm0 should be multiplied with e.g. 0.5. Than the "new" values shall be stored in the array from edi.