Created
July 20, 2012 21:41
-
-
Save yalla/3153430 to your computer and use it in GitHub Desktop.
Test variations of xgetbv
This file contains 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
#include <stdio.h> | |
static unsigned long long _xgetbv(unsigned int index){ | |
unsigned int eax, edx; | |
/* original code | |
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); | |
*/ | |
/* Nokia code */ | |
__asm__ __volatile__(".byte 0x0f, 0x01, 0xd0" | |
: "=a"(eax), "=d"(edx) : "c"(index)); | |
/* modified code, segfaults | |
__asm__ __volatile__ (".byte 0x0f\n"); | |
__asm__ __volatile__ (".byte 0x01\n"); | |
__asm__ __volatile__ (".byte 0xd0\n" // xgetbv instruction | |
: "=a"(eax), "=d"(edx) : "c"(index)); | |
*/ | |
return ((unsigned long long)edx << 32) | eax; | |
} | |
int main() { | |
printf("666 is %i\n", _xgetbv(666)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment