6 typedef unsigned char UChar
;
7 typedef unsigned int UInt
;
9 static UInt
randomUInt ( void )
12 /* From "Numerical Recipes in C" 2nd Edition */
13 n
= 1664525UL * n
+ 1013904223UL;
17 void maskmovq_mmx ( UChar
* regL
, UChar
* regR
)
20 UChar
* dst
= malloc(8);
22 for (i
= 0; i
< 8; i
++)
26 "movq (%0), %%mm1\n\t"
27 "movq (%1), %%mm2\n\t"
29 "maskmovq %%mm1,%%mm2"
31 : /*in*/ "r"(regL
), "r"(regR
), "r"(&dst
[0])
32 : /*trash*/ "edi", "memory", "cc"
34 for (i
= 0; i
< 8; i
++)
35 printf("%02x", dst
[i
]);
39 void maskmovdqu_sse ( UChar
* regL
, UChar
* regR
)
42 UChar
* dst
= malloc(16);
44 for (i
= 0; i
< 16; i
++)
47 "movups (%0), %%xmm1\n\t"
48 "movups (%1), %%xmm2\n\t"
50 "maskmovdqu %%xmm2,%%xmm1\n\t"
53 : /*in*/ "r"(regL
), "r"(regR
), "r"(dst
)
54 : /*trash*/ "edi", "memory", "cc"
56 for (i
= 0; i
< 16; i
++)
57 printf("%02x", dst
[i
]);
61 int main ( int argc
, char** argv
)
67 UChar
* regL
= malloc(8);
68 UChar
* regR
= malloc(8);
71 for (i
= 0; i
< 10; i
++) {
72 for (j
= 0; j
< 8; j
++) {
73 regL
[j
] = (UChar
)randomUInt();
74 printf("%02x", regL
[j
]);
77 for (j
= 0; j
< 8; j
++) {
78 regR
[j
] = (UChar
)randomUInt();
79 printf("%02x", regR
[j
]);
82 maskmovq_mmx( regR
, regL
);
89 UChar
* regL
= malloc(16);
90 UChar
* regR
= malloc(16);
93 for (i
= 0; i
< 10; i
++) {
94 for (j
= 0; j
< 16; j
++) {
95 regL
[j
] = (UChar
)randomUInt();
96 printf("%02x", regL
[j
]);
99 for (j
= 0; j
< 16; j
++) {
100 regR
[j
] = (UChar
)randomUInt();
101 printf("%02x", regR
[j
]);
104 maskmovdqu_sse( regR
, regL
);