Is this usable code for testing inline assembly and SSE ?
#include <stdio.h>
#include <stdlib.h>
//#pragma lib "msvcrt.lib"
typedef struct cVector { float x, y, z; } cVector;
int main(void)
{
unsigned char *pTmp = malloc(sizeof(struct cVector) + 16);
struct cVector *vec1;
vec1 = (struct cVector*)pTmp;
printf("pointer: %0Xh\nalign: %0Xh\n", vec1, (unsigned long)vec1 % 0x10);
if ((unsigned long)vec1 % 0x10) {
vec1 = (struct cVector*)(pTmp + (16 - ((unsigned long)vec1 % 0x10)));
printf("pointer: %0Xh\nalign: %0Xh\n", vec1, (unsigned long)vec1 % 0x10);
}
vec1->x = 0.5;
vec1->y = 1.5;
vec1->z = -3.141;
__asm {
mov ecx, vec1
movaps xmm1, [ecx]
mulps xmm1, xmm1
movaps [ecx], xmm1
}
printf( "%f %f %f\n", vec1->x, vec1->y, vec1->z );
free(pTmp);
return 0;
}