delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/13/14:32:19

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Fine timing
Date: 13 Oct 2000 10:56:14 -0700
Organization: InterWorld Communications
Lines: 28
Sender: nate AT mercury DOT st DOT hmc DOT edu
Message-ID: <83bswok4ld.fsf@mercury.st.hmc.edu>
References: <8s4ini$g3i$1 AT nnrp1 DOT deja DOT com> <7458-Thu12Oct2000175507+0300-eliz AT is DOT elta DOT co DOT il> <8s6ug4$ebr$1 AT nnrp1 DOT deja DOT com>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 971459775 54773 134.173.57.219 (13 Oct 2000 17:56:15 GMT)
X-Complaints-To: usenet AT news DOT interworld DOT net
NNTP-Posting-Date: Fri, 13 Oct 2000 17:56:15 +0000 (UTC)
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

gdemont AT my-deja DOT com writes:

> > By default, this clock's
> > interrupt is disabled, but you can enable it by writing appropriate
> > values into port 70h.
> 
> Nice! And is it possible to read the 1024ths of second from port 70h
> without using an interrupt ? In that case it would simplify dramatically
> things. For the moment I program the PIT, take Int 8 and repair the BIOS
> time that would go wrong otherwise by reading the values from port 70h!
> I works, but is not so nice and needs not forgetting to reset the
> normal state a the end - especially when an unhandled Ada exception
> has occured.
> Anyway, thank you very much, I'll see on that side!

If you just need a counter, and not a periodic interrupt, you can use
the CPU's timestamp counter, which increments every clock cycle.
Then, if you know the clock frequency, you can get very
high-resolution real timing.  This feature is available on most
Pentium-class and newer CPUs.  You can read it with the the RDTSC
instruction.

I have some sample code for this; email me if you're interested.

-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


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