Date: Mon, 17 Feb 1997 15:35:37 +0200 (IST) From: Eli Zaretskii To: Ian Miller cc: DJGPP workers Subject: Re: Exact timming II In-Reply-To: <330822FF.41C67EA6@dra.hmg.gb> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 17 Feb 1997, Ian Miller wrote: > come up with this evening. (I'm hoping that there is a > get_timer_mode() library function because I probably don't know > enough about programming the hardware otherwise.) No, there's no way to read the timer mode (AFAIK), so you will need to use indirect methods. One way is to write a tight loop that reads the BIOS tick count and the timer counter values, and stores them in an array. Let the program run for a few seconds (more than that will require a huge buffer), then print the values and see whether the timer counter goes through 0 once or twice for a single increment in the BIOS tick count. Call `uclock' only once (to put the timer into mode 2), then use this fragment from its source to read the counters: tics = _farpeekl(_dos_ds, 0x46c); outportb(0x43, 0x00); lsb = inportb(0x40); msb = inportb(0x40); Another possibility is to call the BIOS Event Wait service (Int 15H/AH=83h) to see how much does the timer counter change for a given period of time (timer in mode 3 changes twice as fast as mode 2). The BIOS Event Wait service (described in the Interrupt List) can be set to wait for an integer multiple of 976 microseconds; timer in mode 2 gets decremented by 1 every 838 nanoseconds, while mode 3 decrements it by 2 every 838 nanoseconds. So you should see the timer counter change either by 1165 (mode 2) or by 2329 (mode 3) every 976 microseconds.