home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pgmutl / val_link.arc / TIMER.C < prev    next >
Text File  |  1989-02-18  |  2KB  |  62 lines

  1. /*                                 TIMER.C                                 */
  2.  
  3.  
  4. /*+-------------------------------------------------------------------------+
  5.   |                                                                         |
  6.   |                            get_time                                     |
  7.   |                                                                         |
  8.   |                          O/S dependent                                  |
  9.   |                                                                         |
  10.   +-------------------------------------------------------------------------+*/
  11. bit_32 get_time(void)
  12. BeginDeclarations
  13. bit_32                                 hhmmsscc;
  14. EndDeclarations
  15. BeginCode
  16.  inregs.h.ah = 0x2C;                   /* Get time function */
  17.  intdosx(Addr(inregs), Addr(outregs), Addr(segregs));
  18. /* DOS_int21("Failed to get the system time.\n");*/
  19.  hhmmsscc = Bit_32(outregs.h.dl)            +
  20.             Bit_32(outregs.h.dh)  *    100L +
  21.             Bit_32(outregs.h.cl)  *   6000L +
  22.             Bit_32(outregs.h.ch)  * 360000L;
  23.  return(hhmmsscc);
  24. EndCode
  25.  
  26.  
  27. /*+-------------------------------------------------------------------------+
  28.   |                                                                         |
  29.   |                         elapsed_time                                    |
  30.   |                                                                         |
  31.   +-------------------------------------------------------------------------+*/
  32. char_ptr elapsed_time(bit_32 start_time, bit_32 stop_time)
  33. BeginDeclarations
  34.  bit_16                                hh;
  35.  bit_16                                mm;
  36.  bit_16                                ss;
  37.  bit_16                                cc;
  38.  bit_32                                t;
  39. EndDeclarations
  40. BeginCode
  41.  If start_time Exceeds stop_time
  42.   Then /* We passed midnight and must add 24 hours to stop time */
  43.    stop_time += 8640000L;
  44.   EndIf;
  45.  t   = stop_time - start_time;
  46.  cc  = Bit_16(t Mod 100L);                     t /= 100L;
  47.  ss  = Bit_16(t Mod 60L);                      t /= 60L;
  48.  mm  = Bit_16(t Mod 60L);                      t /= 60L;
  49.  hh  = Bit_16(t);
  50.  If hh IsNotZero
  51.   Then
  52.    sprintf(time_array,"%u:%02u:%02u.%02u",hh,mm,ss,cc);
  53.   ElseIf mm IsNotZero
  54.    Then
  55.     sprintf(time_array,"%u:%02u.%02u",mm,ss,cc);
  56.    Else
  57.     sprintf(time_array,"%u.%02u",ss,cc);
  58.  EndIf;
  59.  return(time_array);
  60. EndCode
  61.  
  62.