delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/06/19/12:44:20

Date: Wed, 19 Jun 2002 18:42:39 +0300 (WET)
From: Andris Pavenis <pavenis AT lanet DOT lv>
X-Sender: pavenis AT ieva06
To: billy chen <billyc AT intrex DOT net>
Cc: djgpp AT delorie DOT com
Subject: Re: Need help for rdtsc inline asm
In-Reply-To: <ugv5asq8muh79d@corp.supernews.com>
Message-ID: <Pine.A41.4.05.10206191836300.27608-100000@ieva06>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com


On Tue, 18 Jun 2002, billy chen wrote:

> Hi everyone,
> 
> 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. Hoever I could not get to
> working by passing the compiler not allow the compiler (gcc 2.95.2 (djgpp
> 2.03))  to follow the asm code for me, even I am using asm volatile   and
> looks like the gas did not know how to translate the rdtsc code to machine ?
> Could some one help on this ?

Which version of binutils do You have? Any reasonable resent binutils
version understands rdtsc instruction. Anyway You can write something
like:

inline long long rdtsc(void)
{
     union { long L[2]; long long LL; } W;
     asm __volatile__ (".byte 0x0F,0x31" : "=a"(W.L[0]), "=d"(W.L[1]));
     return W.LL;
}

(I have more nicer example somewhere, but I don't want to search now
Also this should work).

But make sure You are running CPU which supports RDTSC, or You'll get 
SIGILL

Andris




- Raw text -


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