pentium.asm 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ; Pentium utilities. Timothy S. Murphy 1/11/97.
  2. ; This is a Borland i586 TASM source file.
  3. ; Works (at least) with Watcom C++ and Visual C++ using "cdecl" linkage.
  4. .586
  5. .MODEL flat, c, os_dos
  6. .CODE
  7. ;------------------------------------------------
  8. PUBLIC c pentiumKiloCycles, pentiumTime
  9. pentiumKiloCycles:
  10. push edx
  11. ; rdtsc ; get 64-bit cycle count in edx:eax
  12. db 0Fh, 31h ; (tasm 4.0 doesn't have rdtsc opcode)
  13. shrd eax, edx, 10 ; divide by 1024
  14. pop edx
  15. ret ; value in eax
  16. pentiumTime:
  17. push ebx
  18. push edx
  19. ; rdtsc ; get 64-bit cycle count in edx:eax
  20. db 0Fh, 31h ; (tasm 4.0 doesn't have rdtsc opcode)
  21. shrd eax, edx, 10 ; divide by 1024
  22. mov ebx, eax
  23. mov eax, 12[esp]
  24. shr eax, 1
  25. lup: shr edx, 16
  26. dec eax
  27. nop
  28. jns lup
  29. ; rdtsc ; get 64-bit cycle count in edx:eax
  30. db 0Fh, 31h ; (tasm 4.0 doesn't have rdtsc opcode)
  31. shrd eax, edx, 10 ; divide by 1024
  32. sub eax, ebx
  33. pop edx
  34. pop ebx
  35. ret ; value in eax
  36. ;------------------------------------------------
  37. ; void Get_scc(&preciseU32,&lessPreciseU32);
  38. x86_Get_sccParams STRUC
  39. dd 3 dup (?) ;3 pushed regs
  40. dd ? ;return address
  41. preciseU32 dd ?
  42. lessPreciseU32 dd ?
  43. x86_Get_sccParams ENDS
  44. PUBLIC c Get_scc
  45. Get_scc:
  46. push edx
  47. push esi
  48. push edi
  49. mov esi,[esp].preciseU32
  50. mov edi,[esp].lessPreciseU32
  51. ; rdtsc ; get 64-bit cycle count in edx:eax
  52. db 0Fh, 31h ; (tasm 4.0 doesn't have rdtsc opcode)
  53. mov [edi],edx
  54. mov [esi],eax
  55. pop edi
  56. pop esi
  57. pop edx
  58. ret ; value in eax
  59. END