1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <iostream>
#include <xmmintrin.h>
#include <stdlib.h>
#include <stdio.h>
using std::cout;
int main(int argc, char **argv)
{
short *p __attribute__((aligned(16)));
p = new short[512];
short *p2 __attribute__((aligned(16)));
p2 = new short;
for (int i=0 ; i<512 ; i++)
{
p[i] = i;
}
__m128 *dp = (__m128 *)p;
__m128 *dp2 = (__m128 *)p2;
__asm__ ("movupd %0, %%xmm0"::"m"((__m128 *)dp));
__asm__ ("movupd %%xmm0, %0":"=m"((__m128 *)dp2));
//Theoriquement, les premiers octets de p sont dans p2...
printf("%d %d %d %d %d %d %d %d\n", p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
printf("%d %d %d %d %d %d %d %d\n", p2[0], p2[1], p2[2], p2[3], p2[4], p2[5], p2[6], p2[7]);
delete[] p;
delete[] p2;
return 0;
} |
Partager