Guest User

Untitled

a guest
Sep 15th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. static unsigned long long _xgetbv(unsigned int index){
  4. unsigned int eax, edx;
  5.  
  6. /* original code
  7. __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
  8. */
  9.  
  10. /* Nokia code */
  11. __asm__ __volatile__(".byte 0x0f, 0x01, 0xd0"
  12. : "=a"(eax), "=d"(edx) : "c"(index));
  13.  
  14. /* modified code, segfaults
  15. __asm__ __volatile__ (".byte 0x0f\n");
  16. __asm__ __volatile__ (".byte 0x01\n");
  17. __asm__ __volatile__ (".byte 0xd0\n" // xgetbv instruction
  18. : "=a"(eax), "=d"(edx) : "c"(index));
  19. */
  20.  
  21. return ((unsigned long long)edx << 32) | eax;
  22. }
  23.  
  24. int main() {
  25. printf("666 is %i\n", _xgetbv(666));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment