home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / CLOCK.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.8 KB  |  51 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - clock.cas
  3.  *
  4.  * function(s)
  5.  *        clock     - ANSI standard; returns number of timer ticks
  6.  *                    that have elapsed since this program started.
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #pragma inline
  20. #include <asmrules.h>
  21. #include <time.h>
  22.  
  23. extern unsigned long _StartTime;        /* beginning of program execution  */
  24.                                         /*   initialized in C0.ASM         */
  25.  
  26. static unsigned char DayFlip;           /* keeps track                     */
  27.  
  28. #pragma inline
  29.  
  30. #define I asm
  31.  
  32. clock_t clock(void)
  33. {
  34.    clock_t NowTime;
  35.  
  36. I   xor    ah,ah
  37. I   int    1ah                          /* call BIOS for timer ticks       */
  38.  
  39. I   add    BY0(DayFlip), al             /* record whether day has changed  */
  40.  
  41. I   mov    W0 (NowTime), DX             /* save return values              */
  42. I   mov    W1 (NowTime), CX             /*  which is current time in ticks */
  43.  
  44.  
  45.    if(DayFlip)
  46.       NowTime += 0x1800b0L;             /* number of clock ticks in day    */
  47.  
  48.    return(NowTime - _StartTime);        /* return count of ticks           */
  49. }
  50.  
  51.