Mach7 icon indicating copy to clipboard operation
Mach7 copied to clipboard

Add Visual C++ equivalent of RDTSC code

Open solodon4 opened this issue 9 years ago • 3 comments

Windows headers are incompatible with /Za flag, which disables language extensions. Windows header right now seems to only be used for timing purposes, so we can include it conditionally when extensions are enabled only. Enabling them though makes us rely on the worst timer available.

Write equivalent of RDTSC access code we now have for GCC in Microsoft assembly.

solodon4 avatar Jun 04 '15 07:06 solodon4

Microsoft provides an intrinsic to access RDTSC, which is nice because they don't support inline assembly in amd64 code. However, it seems like the implementation of get_frequency would still "require" including <windows.h> in order to get Sleep() to pause execution for 1/10th of a second.

Given your statement "Enabling them though makes us rely on the worst timer available." Is the goal to use RDTSC always or to only use RDTSC if Microsoft extensions are disabled?

mwinterb avatar Jun 06 '16 19:06 mwinterb

The main idea was to be able to build with /Za (disable Microsoft extensions), the actual task was what prevented us from doing this.

solodon4 avatar Jun 09 '16 17:06 solodon4

If you still need this, here you go. It is not attached because github says "We don't support that file type" when I drag and drop the file.

`.686P .XMM .model flat

;; ml /c rdtscget.asm ;; produces rdtscget.obj ;; link rdtscget.obj with the rest of your code ;; C function prototype ;; unsigned long long _stdcall rdtsc(void); PUBLIC _rdtsc@0 _TEXT SEGMENT

_rdtsc@0 PROC rdtsc ret _rdtsc@0 ENDP

_TEXT ENDS END `

jrfl avatar Oct 25 '16 23:10 jrfl