Date: Wed, 19 Jun 2002 18:42:39 +0300 (WET) From: Andris Pavenis X-Sender: pavenis AT ieva06 To: billy chen Cc: djgpp AT delorie DOT com Subject: Re: Need help for rdtsc inline asm In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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