home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SYSTEM / MMCLK12.ZIP / BIOS.ASM next >
Encoding:
Assembly Source File  |  1990-04-10  |  3.0 KB  |  134 lines

  1.     include    mmclock.mac
  2.     title    MM58167A BIOS routines -- Copyright 1990 Wales
  3.  
  4. ; ======================================================================
  5. ;
  6. ; BIOS routines for the MM58167A clock/calendar.
  7. ; (C) Copyright 1990 Richard B. Wales.  All Rights Reserved.
  8. ;
  9. ; Global routines:
  10. ;
  11. ;    SetBIOS
  12. ;        Sets the BIOS time-of-day count.
  13.  
  14. ; ======================================================================
  15. ;
  16. ; Global symbols.
  17.     public    SetBIOS
  18.  
  19. ; ======================================================================
  20. ;
  21. ; SetBIOS
  22. ;
  23. ;    Set the BIOS time-of-day count.
  24. ;    This routine is used so that the BIOS time-of-day count will be
  25. ;    in agreement with the system time from the MM58167A (to within
  26. ;    about half a second).
  27. ;
  28. ;    Arguments:
  29. ;
  30. ;        CH    Hours (0-23).
  31. ;        CL    Minutes (0-59).
  32. ;        DH    Seconds (0-59).
  33. ;        DL    Hundredths of a second (0-99).
  34.  
  35. SetBIOS    proc    near
  36.  
  37.  
  38.     ; Validate the input arguments.
  39.     cmp    ch, 23
  40.     ja    short done
  41.     cmp    cl, 59
  42.     ja    short done
  43.     cmp    dh, 59
  44.     ja    short done
  45.     cmp    dl, 99
  46.     ja    short done
  47.  
  48.     ; Use AX as an accumulator for the time-of-day count.
  49.     xor    ax, ax
  50.  
  51.     ; Add hundredths of a second (46/256 tick per 1/100 sec).
  52.         xor    bx, bx
  53.     mov    bl, dl
  54.     shl    bx, 1
  55.     add    ax, bx            ; add DL *  2/256
  56.     shl    bx, 1
  57.     add    ax, bx            ; add DL *  4/256
  58.     shl    bx, 1
  59.     add    ax, bx            ; add DL *  8/256
  60.     shl    bx, 1
  61.     shl    bx, 1
  62.     add    ax, bx            ; add DL * 32/256
  63.     ; (maximum value so far = 17.789)
  64.  
  65.     ; Add seconds (18 + 52/256 ticks per second).
  66.     xor    bx, bx
  67.     mov    bl, dh
  68.     shl    bx, 1
  69.     shl    bx, 1
  70.     add    ax, bx            ; add DH *  4/256
  71.     shl    bx, 1
  72.     shl    bx, 1
  73.     add    ax, bx            ; add DH * 16/256
  74.     shl    bx, 1
  75.     add    ax, bx            ; add DH * 32/256
  76.     mov    al, ah
  77.     xor    ah, ah            ; throw away fraction now
  78.     shr    bx, 1
  79.     add    ax, bx            ; add DH * 16
  80.     shr    bx, 1
  81.     shr    bx, 1
  82.     shr    bx, 1
  83.     add    ax, bx            ; add DH *  2
  84.     ; (maximum value so far = 1091)
  85.  
  86.     ; Add minutes (1092 ticks per minute).
  87.     xor    bx, bx
  88.     mov    bl, cl
  89.         mov    cl, 4
  90.     shl    bx, 1
  91.     shl    bx, 1
  92.     add    ax, bx            ; add CL *    4
  93.     shl    bx, cl
  94.     add    ax, bx            ; add CL *   64
  95.     shl    bx, cl
  96.     add    ax, bx            ; add CL * 1024
  97.     ; (maximum value so far = 65,519)
  98.  
  99.     ; Use BX as an accumulator for the high-order 16 bits.
  100.     ; Initialize BX to the number of hours (65,536 ticks per hour).
  101.     ; This is not quite enough (should be 65,544); the extra will
  102.     ; be taken care of in a moment.
  103.     xor    bx, bx
  104.     mov    bl, ch            ; add CH * 65536
  105.  
  106.     ; Add 8 more ticks per hour.  There might be a carry from AX
  107.     ; into BX after this is done.
  108.     mov    cl, ch
  109.     xor    ch, ch
  110.     xor    dx, dx            ; use DX = 0 when adding carry
  111.     shl    cx, 1
  112.     shl    cx, 1
  113.     shl    cx, 1
  114.     add    ax, cx            ; add CH * 8
  115.     adc    bx, dx            ; handle carry (if any)
  116.     ; (maximum final value = 1,573,031;
  117.     ;  compare with 1,573,040 = one full day)
  118.  
  119.     ; We now have the high-order 16 bits in BX, and the low-order
  120.     ; 16 bits in AX.  Give this value to the BIOS to store as the
  121.     ; time-of-day count.
  122.     mov    cx, bx
  123.     mov    dx, ax
  124.     mov    ah, 1
  125.     int    1Ah
  126.  
  127.     ; That's all.
  128. done:    ret
  129.  
  130. SetBIOS    endp
  131.  
  132. code    ends
  133.  
  134.     end