home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye5 / b5-clock.lbr / B5C-SS1.IQS / B5C-SS1.INS
Encoding:
Text File  |  1986-03-08  |  2.8 KB  |  126 lines

  1. ; B5C-SS1.INS - Clock routine for the System Support 1
  2. ; 07/15/85  Renamed to B5C-SS1.INS  <wm>
  3. ; 6/28/85 - Added hold support and also pokes RTCBUF with time.
  4. ;                        -- Paul Traina
  5. ;
  6. ;----------------------------------------------------------------
  7. ;
  8. ;    Note- This is an insert--not an overlay
  9. ;
  10.      IF    TIMEON OR RSPEED
  11. SS1BASE    EQU    050H        ; Base port for SS1
  12. CLKCMD    EQU    SS1BASE+10    ; Clock command port
  13. CLKDATA    EQU    SS1BASE+11    ; Clock data port
  14. CLKREAD    EQU    16        ; Read command bit
  15. CLKHOLD    EQU    64        ; Hold command bit
  16. ;
  17. TIME:    LXI    H,RTCBUF    ; Point to RTC buffer
  18.     MVI    C,5        ; Set counter for hour tens
  19.     CALL    RDIGIT        ; Get hour tens
  20.     CALL    SHFT4        ; Save in buffer
  21.     CALL    MULT10        ; Multiply by 10
  22.     MOV    B,A        ; Save in B reg
  23.     CALL    RDIGIT        ; Get hour units in A reg
  24.     CALL    ADDLOW        ; Set BCD digit
  25.     ADD    B        ; Add tens digit from B
  26.     STA    CCHOUR        ; Store for later use
  27. ;
  28. ;    Minutes
  29. ;
  30.     CALL    RDIGIT        ; Get minute tens in A reg
  31.     CALL    SHFT4        ; Save in buffer
  32.     CALL    MULT10        ; Multiply by 10
  33.     MOV    B,A        ; Save in B reg
  34.     CALL    RDIGIT        ; Get minute units in A reg
  35.     CALL    ADDLOW        ; Set BCD digit
  36.     ADD    B        ; Add in minutes tens from B
  37.     STA    CCMIN        ; Store for later use
  38. ;
  39. ;    Seconds
  40. ;
  41.     CALL    RDIGIT        ; Second tens
  42.     CALL    SHFT4
  43.     CALL    RDIGIT        ; Second units
  44.     CALL    ADDLOW
  45. ;
  46. ;    Year
  47. ;
  48.     INX    H        ; Skip over "19"
  49.     MVI    C,12        ; Start with years tens
  50.     CALL    RDIGIT
  51.     CALL    SHFT4
  52.     CALL    RDIGIT        ; Years units
  53.     CALL    ADDLOW
  54. ;
  55.     CALL    RDIGIT        ; Month tens
  56.     CALL    SHFT4
  57.     CALL    RDIGIT        ; Month units
  58.     CALL    ADDLOW
  59. ;
  60.     CALL    RDIGIT        ; Day tens
  61.     CALL    SHFT4
  62.     CALL    RDIGIT        ; Day units
  63.     CALL    ADDLOW
  64. ;
  65.     XRA    A
  66.     OUT    CLKCMD        ; Turn off hold bit
  67.     RET
  68. ;
  69. ;    Read a digit
  70. ;        Command in C
  71. ;        Digit returned in A
  72. ;        C is decremented
  73. ;        Hold bit is set
  74. ;
  75. RDIGIT:    MOV    A,C        ; Get command byte
  76.     DCR    C        ; Bump it for next operation
  77.     ORI    CLKREAD+CLKHOLD    ; Add in read & hold bits
  78.     OUT    CLKCMD        ; Output it
  79.     ANI    15        ; Strip off any commands
  80.     CPI    5        ; Was it hour tens digit?
  81.     IN    CLKDATA        ; Get data
  82.     RNZ            ; No, return
  83.     ANI    3        ; Yes, so kill 24 hour bit
  84.     RET
  85. ;
  86. ;    Multiply register A by 10
  87. ;    Destroys 'D'
  88. ;
  89. MULT10:    ADD    A        ; 2x
  90.     MOV    D,A
  91.     ADD    A        ; 4x
  92.     ADD    A        ; 8x
  93.     ADD    D        ; 10x
  94.     RET
  95. ;
  96. ;    Shift A to high nibble
  97. ;        Stores shifted value in 'M'
  98. ;        Destroys 'E'
  99. ;        A is left unchanged
  100. ;
  101. SHFT4:    MOV    E,A
  102.     ANI    15        ; Only handle lower 4 bits
  103.     RLC            ; Shift A over 4 bits
  104.     RLC
  105.     RLC
  106.     RLC            
  107.     MOV    M,A        ; Save it while we're at it
  108.     MOV    A,E
  109.     RET
  110. ;
  111. ;    Add in low BCD nibble
  112. ;        Gets high nibble from M
  113. ;        Stores new BCD byte in M
  114. ;        Increments HL
  115. ;        Destroyes 'E'
  116. ;
  117. ADDLOW:    MOV    E,A
  118.     ANI    15        ; Deal with low nibble only
  119.     ORA    M        ; Add in high nibble from tens digit
  120.     MOV    M,A        ; Save new BCD byte in buffer
  121.     INX    H        ; Move on to next location
  122.     MOV    A,E
  123.     RET
  124.      ENDIF            ; TIMEON OR RSPEED
  125.