hi, I put together a small app to try using SEE in assembly, but I am getting the wrong output.
these are the .cpp file and the .asm file

#define WIN32_LEAN_AND_MEAN
#include <iostream>
using namespace std;

extern "C" int *myFunc(float *a, float *b, float *result);

int main(int argc, char *argv[])
{
	float inA[] = {1.0f, 2.0f, 3.0f, 4.0f};
	float inB[] = {1.0f, 2.0f, 3.0f, 4.0f};
	float ret[4];

	myFunc(inA, inB, ret);

	cout << ret[0] << endl;
	cout << ret[1] << endl;
	cout << ret[2] << endl;
	cout << ret[3] << endl;

	system("pause");
	
	return 0;
}
.586P
.XMM
.MODEL FLAT, C
.STACK
.DATA
.CODE

myFunc PROC a:DWORD, b:DWORD, result:DWORD

movups xmm0, [a]
movups xmm1, [b]
addps xmm0, xmm1
movups [result], xmm0
ret

myFunc ENDP

END

I was expecting to get the result

2
4
6
8

but instead got

-1.07374e+008
-1.07374e+008
-1.07374e+008
-1.07374e+008

can anyone help me out?

Hi

your indirect address modes are wrong. Unfortunately, you won't get any error message. That's life in assembly programming.

To fast show you the problem in principle I copied your assembly code inline a C program:

void myFunc(float *a, float *b, float *result)   ; *myFunc not necessary but ok
{
__asm {
        mov edi, a;          ; <--- mov via 32bit reg only!
	movups xmm0, [edi]   ; <--- indirect adress mode [a] not allowed!

        mov edi, b;
        movups xmm1, [edi]   ; <--- dito, indirect adress mode [b] not allowed!

        addps xmm0, xmm1

        mov edi, result
        movups [edi], xmm0   ; <--- dito, indirect adress mode [result] not allowed! 
      }
}
int main(int argc, char *argv[])
{
	float inA[] = {1.0f, 2.0f, 3.0f, 4.0f};
	float inB[] = {1.0f, 2.0f, 3.0f, 4.0f};
	float ret[4];

	myFunc(inA, inB, ret);


	cout << ret[0] << endl; // only first element of vector is calculated
        // result is
        // 2

	//cout << ret[1] << endl;  
	//cout << ret[2] << endl;
	//cout << ret[3] << endl;

	system("pause");
	
	return 0;
}

Now it's your turn to program the loop for adding all four elements of the vectors.

-- tesu

Thanks! works now. But why can't I dereference the argument? is there another way to pass the arguments in so that I don't need the extra copy?