Last active
August 29, 2015 14:19
-
-
Save savanovich/e7ca9644554135cdf0e1 to your computer and use it in GitHub Desktop.
Inline asm opcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* http://habrahabr.ru/company/intel/blog/200658/ | |
gcc -O0 -Wall mulsd.c | |
./a.out | |
4.000000 2.000000 | |
*/ | |
#include <stdio.h> | |
int main() { | |
double a[2] = {2, 2}, b[2] = {0, 0}; | |
__asm__ __volatile__ ( | |
// Copy data from a to xmm7 register | |
"movupd %1, %%xmm7\n" | |
// Opcode: "mulsd %%xmm7, %%xmm7\n" | |
".byte 0xf2, 0x66, 0x0f, 0x59, 0xff\n" | |
// Copy data from xmm7 register to b | |
"movupd %%xmm7, %0\n" | |
:"=m"(*b) | |
:"m"(*a) | |
: | |
); | |
printf("%lf %lf\n", b[0], b[1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment