home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctech / 1988_02 / eltime.c < prev    next >
Text File  |  1985-08-06  |  858b  |  24 lines

  1. /* eltime.c - use BIOS time-of-day interrupt */
  2. #include "stdio.h"
  3. #include "dos.h"
  4.  
  5. static long stime ;            /* store time-of-day from last call */
  6. #define TOD_INT  0x1A        /* BIOS time-of-day interrupt */
  7.  
  8. int eltime()            /* count ticks since last call */
  9.  {
  10.     struct XREG sreg , dreg ;
  11.     long etime , delta ;
  12.  
  13.     sreg.ax = 0 ;        /* get time count */
  14.     int86(TOD_INT,&sreg,&dreg); /* get current  count */
  15.                 /* assemble 32-bit time-of-day value */
  16.     etime = ( ((long) dreg.cx) << 16 ) + (unsigned) dreg.dx ;
  17.     delta = etime - stime ;
  18.                                             /* check for new day since last call */
  19.     if( ((dreg.ax & 0xff) != 0) || (delta < 0) )   
  20.         delta = delta + 0x01800B0L ; /* new day - add 1 day in ticks */
  21.     stime = etime ;        /* save time-of-day for next call */
  22.     return( (int) delta ) ;        /* return as an integer */
  23.  }
  24.