Everhart,Glenn From: Chris Van Schoiack [chrisv@microcrafts.com] Sent: Tuesday, March 17, 1998 4:56 PM To: 'LAURENT.L.G.GEOFFROY@TTS.thomson.fr'; ntdev@atria.com Subject: RE: [ntdev] rdtsc routine with arguments passing > __declspec (naked) void _getclockvalue(ULARGE_INTEGER *TimeValue) > { > _asm > { > push eax ; save registers used to store TimeValue parameter > push edx > push edi > mov eax,ss:dword ptr [esp + 16] ; move the pointer to TimeValue into > eax > mov edi,eax ; edi = eax > _emit 0fH ; encode the magic opcodes to > the get the clock count > _emit 31H ;read the Pentium clock hi - > edx, lo - eax > mov ds:dword ptr[edi],edx ; set the high word of TimeValue > mov ds:dword ptr[edi + 4],eax ; set the low word of TimeValue > > pop edi ; restore registers > pop edx > pop eax > ret ; return, needed because of the > __declspec (naked) > } > } > " I'm not sure how necessary the segment overrides are..since I'm pretty sure pointers are valid in every segment--ie. the only difference between the segments are whether the segments are read, write and/or executable. Though, I've never really done any assembly under 95/NT. The big difference between this one, and the other, is this one yields a double dword value. The other, only retrieves the low word. The reason why the other works (with way less code), is because (by convention) return values are stored in the eax. As you can see in the comments above, the get clock count instruction returns the low word in the eax, so no extra work (instructions) are required to return the clock count... Lates, ChrisV > Who would like to comment the latter code sample ? > > TIA > Laurent GEOFFROY > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > [ To unsubscribe, send email to ntdev-request@atria.com with body > UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]