delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/19/13:30:18

Message-ID: <3D10BE94.A64FFFAD@cyberoptics.com>
Date: Wed, 19 Jun 2002 12:25:40 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Organization: CyberOptics
X-Mailer: Mozilla 4.72 [en] (Win95; U)
X-Accept-Language: en,pdf
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need help for rdtsc inline asm
References: <ugv5asq8muh79d AT corp DOT supernews DOT com>
Lines: 25
NNTP-Posting-Host: 65.214.97.102
X-Trace: 1024507545 8953 65.214.97.102
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

billy chen wrote:

> I try to write an inline asm code for getting the time stamp counter a 64 bits
> will store at edx:eax when rdtsc is called.

Try this little snippet, which you can customize to your liking:

unsigned long long pentimer(int mode) {
   static unsigned long long tref;
   unsigned long long time;

   asm volatile("rdtsc       # rdtsc"
      : "=A" (time)
         );
   if (mode == 0) {
      tref = time;
      return 0.;
   } else {
      return time - tref;
   }
}

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019