Path: utzoo!attcan!ncrcan!becker!censor!comspec!tvcent!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!helios.ee.lbl.gov!hellgate.utah.edu!cc.utah.edu!cc.usu.edu!jrd From: JRD@cc.usu.edu (Joe Doupnik) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: timing a software function via timer chip Message-ID: <23656@cc.usu.edu> Date: 5 May 90 03:12:18 GMT Lines: 16 X-Local-Date: 4 May 90 20:12:18 PDT If one takes a careful look at the IBM PC specs Timer channels 0, 1, and 2 are nearly identical, but channels 0 and 1 are preallocated to memory refresh and time of day. So, channel 2 is the only one free for ordinary programming use. Since they are the same kind, driven from the same clock one needs to simply choose a nice divisor for the chip to count in units of up to 1/18.2 seconds. The chip can be started just before your test function is executed and then then stopped at the end. The differences in counts before and after gives the elapsed time in tics; arithmetic yields the time in seconds. If you would like to see an example of this in action take a look at file MSXIBM.ASM in MS Kermit where I calibrate the duration of a software timing loop to be 1/1000 second by using channel 2 above to measure the real time of the loop. That file is available via anonymous ftp from watsun.cc.columbia.edu in directory kermit/a. Joe D.