From: "Billy Chen" Newsgroups: comp.os.msdos.djgpp Subject: Re: Need help for rdtsc inline asm Date: Wed, 19 Jun 2002 16:15:08 -0400 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Complaints-To: newsabuse AT supernews DOT com Lines: 47 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com This one works great, thanks every one Billyc "Andris Pavenis" wrote in message news:Pine DOT A41 DOT 4 DOT 05 DOT 10206191836300 DOT 27608-100000 AT ieva06... > > > 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 > > > >