home *** CD-ROM | disk | FTP | other *** search
/ Popular Software (Premium Edition) / mycd.iso / DICT / DFKC / ZWH / CHCS / XTIME.C < prev   
Encoding:
C/C++ Source or Header  |  1998-01-12  |  1.9 KB  |  84 lines

  1. /*
  2.  * xtime.c
  3.  *
  4.  */
  5.  
  6. #pragma    inline
  7. #include   <dos.h>
  8. #include   <stdio.h>
  9.  
  10.    unsigned char   hour, min, sec;
  11.  
  12. void ConvBinary()
  13. {
  14.    asm {
  15.        mov  bl, al
  16.        and  bl, 0fh
  17.        shr  al, 1
  18.        shr  al, 1
  19.        shr  al, 1
  20.        shr  al, 1
  21.        mov  ah, 10
  22.        mul  ah
  23.        add  al, bl
  24.    }
  25. }
  26.  
  27. void GetTime()
  28. {
  29.    asm {
  30.        mov  ah, 2
  31.        int  1ah
  32.        mov  al, ch
  33.        call ConvBinary
  34.        mov  hour, al
  35.        mov  al, cl
  36.        call ConvBinary
  37.        mov  min, al
  38.        mov  al, dh
  39.        call ConvBinary
  40.        mov  sec, al
  41.    }
  42. }
  43. void main(int argc, char *argv[])
  44. {
  45.    unsigned        highBefore, highAfter, lowBefore, lowAfter;
  46.    unsigned long   t1, t2;
  47.    float           i, k, xt1, xt2, xtime;
  48.    int             sp,  tbefore, tafter;
  49.    char            command[200];
  50.  
  51.    if (argc == 1 || strcmp(argv[1], "/?") == 0 ) {
  52.       printf("\tCHCS ╩╡╙├│╠╨≥ XTIME Version 1.00\n"
  53.              "\tCopyright (c) │┬╜¡─■  1993,1994.\n"
  54.              "\n\t╦╡├≈: ▓Γ┴┐│╠╨≥╘╦╨╨╩▒╝Σ"
  55.              "\n\t╙├╖¿: XTIME │╠╨≥├√ [▓╬╩² ...]"
  56.              "\n\t╛┘└²: XTIME DIR\n"
  57.       );
  58.       exit(0);
  59.    }
  60.    strcpy(command, argv[1]);  strcat(command, " ");
  61.    sp = 2;
  62.    while (*argv[sp]) {
  63.       strcat(command, argv[sp]);  strcat(command, " ");
  64.       sp ++;
  65.    }
  66.    _AH = 0;  asm int 0x1a;
  67.    highBefore = _CX;  lowBefore = _DX;
  68.    GetTime();  tbefore = ((hour * 60) + min) * 60 + sec;
  69.  
  70.    system(command);
  71.  
  72.    GetTime();  tafter = ((hour * 60) + min) * 60 + sec;
  73.    _AH = 0;  asm int 0x1a;
  74.    highAfter = _CX;  lowAfter = _DX;
  75.    t1 = ((unsigned long)highBefore << 16) + lowBefore;
  76.    t2 = ((unsigned long)highAfter  << 16) + lowAfter;
  77.    i = t1 / 18.2;  k = t2 / 18.2;
  78.    xt1 = k - i;  xt2 = tafter - tbefore;
  79.    if (xt2 < xt1) xtime = xt1;
  80.    else if ( (xt2 - xt1) < 1.0 ) xtime = xt1;
  81.         else xtime = xt2;
  82.    printf("\n\n│╠╨≥╘╦╨╨╩▒╝Σ: %8.3g ├δ\n", xtime);
  83. }
  84.