delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2006/01/16/15:30:32

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <dont_have AT bitbucket DOT cmm>
Newsgroups: comp.os.msdos.djgpp
References: <43cbed4a_1 AT x-privat DOT org>
Subject: Re: Reading the TSC
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
X-IWN-Posted-By: [68.60.59.250] Mon Jan 16 13:17:52 2006
Message-ID: <gkbt93-1jp1.ln1@news.infowest.com>
X-Complaints-To: abuse AT eli DOT net
X-Trace: 52616e646f6d4956ab9aae61b20bf993acae1422cde01d166036f04ded8031b4ed2f07b6c7cb32c4f6630704743e93bc74be641946b228b4e19f1c85f7beeca033388c317c153b1f19385589ff425e0547034e567bc67373b93f8c358c3e7c5d0733a44e6a2018cb3c5389260e6188b04ab5bce9f740766ccf2c13607a15afaf12c33cbf216a39eef4063b042bafeca5
X-Abuse-Info: Please be sure to forward ALL headers so that we may process your complaint properly.
NNTP-Posting-Date: Mon, 16 Jan 2006 20:27:37 UTC
Date: Mon, 16 Jan 2006 20:27:37 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Cristiano" <cristiano DOT pi AT NSquipo DOT it> wrote in message
news:43cbed4a_1 AT x-privat DOT org...
> I'm trying to write the Pentium time-stamp counter in a file under MSDOS.
> DJGPP says that there is a parsing error. Please, could somebody help me?
>
<snip>

> Thanks
> Cristiano

I think this is more of what you want:

#include <stdio.h>

#define RDTSC(x) __asm__ __volatile__ ("rdtsc":"=A"(x));

int main(void)
{
  FILE *f = fopen("RDTSC.txt", "wb");
  unsigned long long tsc;

  RDTSC(tsc);
  fprintf(f,"%llu",tsc); fclose(f); return 0;
}


Putting the clobber list in for some reason seems to prevent the variable
from being stored...  You can look at the assembly with,  gcc -S sample.c.
I didn't need to change the DPMI host to CWSDPR0 which means the TSD CR4 bit
is correct RM dos.  If you are under XP, etc., you may need to fixup CR4.
There is a long thread on rdtsc by AL SANTINO 1/7/06 6:31PM in
comp.lang.asm.x86.  It recommends the 'cpuid' instruction be thrown in there
too.


Rod Pemberton


- Raw text -


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