home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / BENCHMAR / STOP200.ZIP / ELTIME.C next >
Encoding:
C/C++ Source or Header  |  1990-06-18  |  879 b   |  31 lines

  1. /* eltime.c - use BIOS time-of-day interrupt */
  2.  
  3. #include <stdio.h>
  4. #include <dos.h>
  5.  
  6. static long     STime;            /* store time-of-day from last call */
  7.  
  8. #define TOD_INT  0x1A            /* BIOS time-of-day interrupt */
  9.  
  10.  long
  11. ElapsedTime (void) {                                /* count ticks since last call */
  12.     union REGS DReg;
  13.  
  14.     long            ElapsedTime, Delta;
  15.  
  16.     DReg.x.ax = 0;                            /* get time count */
  17.     int86(TOD_INT, &DReg, &DReg);            /* get current  count */
  18.  
  19.     /* assemble 32-bit time-of-day value */
  20.  
  21.     ElapsedTime = (((long) DReg.x.cx) << 16) + (unsigned) DReg.x.dx;
  22.     Delta = ElapsedTime - STime;
  23.  
  24.     /* check for new day since last call */
  25.  
  26.     if (((DReg.x.ax & 0xFF) != 0) || (Delta < 0))
  27.         Delta = Delta + 0x01800B0L;            /* new day - add 1 day in ticks */
  28.     STime = ElapsedTime;                     /* save time-of-day for next call */
  29.     return (Delta);                            /* return as an integer */
  30.     }
  31.