cpuid64.asm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. %include "defs.asm"
  2. ;************************* cpuid64.asm *********************************
  3. ; Author: Agner Fog
  4. ; Date created: 2008-12-14
  5. ; Last modified: 2011-07-01
  6. ; Source URL: www.agner.org/optimize
  7. ; Project: asmlib.zip
  8. ; Description:
  9. ; This function calls the CPUID instruction.
  10. ;
  11. ; Copyright (c) 2011 GNU General Public License www.gnu.org/licenses
  12. ;******************************************************************************
  13. default rel
  14. global cpuid_ex: function
  15. SECTION .text align=16
  16. ; ********** cpuid_ex function **********
  17. ; C++ prototype:
  18. ; extern "C" void cpuid_ex (int abcd[4], int a, int c);
  19. ; Input: a = eax, c = ecx
  20. ; Output: abcd[0] = eax, abcd[1] = ebx, abcd[2] = ecx, abcd[3] = edx
  21. cpuid_ex:
  22. %IFDEF WINDOWS
  23. ; parameters: rcx = abcd, edx = a, r8d = c
  24. push rbx
  25. xchg rcx, r8
  26. mov eax, edx
  27. cpuid ; input eax, ecx. output eax, ebx, ecx, edx
  28. mov [r8], eax
  29. mov [r8+4], ebx
  30. mov [r8+8], ecx
  31. mov [r8+12], edx
  32. pop rbx
  33. %ENDIF
  34. %IFDEF UNIX
  35. ; parameters: rdi = abcd, esi = a, edx = c
  36. push rbx
  37. mov eax, esi
  38. mov ecx, edx
  39. cpuid ; input eax, ecx. output eax, ebx, ecx, edx
  40. mov [rdi], eax
  41. mov [rdi+4], ebx
  42. mov [rdi+8], ecx
  43. mov [rdi+12], edx
  44. pop rbx
  45. %ENDIF
  46. ret
  47. ;cpuid_ex END