I'm stuck on this problem and quite new to assembly, so bear with me.
I'm suppose to make a SIMD version of it. I was trying to program it with MMX set.
a1 and a2 is just an array of 256 random integers. When I run this code, their outputs don't match. The pointers are throwing me off and confusing me. Plus, I'm new to assembly. Any suggestions?
// Regular C++ code
void Add(unsigned char *a1, unsigned char *a2, unsigned short *out){
for (int j = 0; j < 256; j++){
out[j] = a1[j] + a2[j];
}
}
//SIMD version of the above
void AddSIMD(unsigned char *a1, unsigned char *a2, unsigned short *out){
__asm{
mov eax, dword ptr [a1];
mov ecx, dword ptr [a2];
mov edx, dword ptr [aOut];
movdqu xmm0, XMMWORD ptr [eax];
movdqu xmm1, XMMWORD ptr [ecx];
paddd xmm0, xmm1;
movdqu XMMWORD ptr [edx], xmm0;
}
}
I'm suppose to make a SIMD version of it. I was trying to program it with MMX set.
a1 and a2 is just an array of 256 random integers. When I run this code, their outputs don't match. The pointers are throwing me off and confusing me. Plus, I'm new to assembly. Any suggestions?
// Regular C++ code
void Add(unsigned char *a1, unsigned char *a2, unsigned short *out){
for (int j = 0; j < 256; j++){
out[j] = a1[j] + a2[j];
}
}
//SIMD version of the above
void AddSIMD(unsigned char *a1, unsigned char *a2, unsigned short *out){
__asm{
mov eax, dword ptr [a1];
mov ecx, dword ptr [a2];
mov edx, dword ptr [aOut];
movdqu xmm0, XMMWORD ptr [eax];
movdqu xmm1, XMMWORD ptr [ecx];
paddd xmm0, xmm1;
movdqu XMMWORD ptr [edx], xmm0;
}
}
