X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <3C0B7D51.F096A01A@yahoo.com> From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: RDTSC ? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 29 Date: Mon, 03 Dec 2001 14:32:53 GMT NNTP-Posting-Host: 12.90.174.157 X-Complaints-To: abuse AT worldnet DOT att DOT net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1007389973 12.90.174.157 (Mon, 03 Dec 2001 14:32:53 GMT) NNTP-Posting-Date: Mon, 03 Dec 2001 14:32:53 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Andris Pavenis wrote: > > On Sun, 2 Dec 2001, Damien Knight wrote: > > > As I've been told, RDTSC is a feature of pentium (and up) processers that > > tracks the number of processer cycles completed since the system last > > powered up, making it useful for calculating system uptime - but more > > importantly, it can be used to test code optimization and so on. > > > > My question : How do I get this value and use in in a DJGPP program? If > > anyone has a function already written, that'd be great. > > inline long long rdtsc (void) > { > long long result; > asm volatile ("rdtsc" : "=A"(result)); > return result; > } And if you call this function on a 486 you get a crash. So guard it by checking the actual CPU first. -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) Available for consulting/temporary embedded and systems. (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)