home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3c-cw.ins < prev    next >
Text File  |  1994-07-13  |  3KB  |  139 lines

  1. ; B3C-CW.INS - Clock routine for the CompuTime/QT clock card.  07/03/85
  2. ;                        -- by pst
  3. ;
  4. ;  This routine needs:        BCD2BIN = no
  5. ;                BIN2BCD = no
  6. ;
  7. ;----------------------------------------------------------------
  8. ;
  9. ;    Note- This is an insert--not an overlay
  10. ;
  11.      IF    RTC
  12. CWBASE    EQU    241        ; Base port for board
  13. CLKCMD    EQU    CWBASE        ; Clock command port
  14. CLKDATA    EQU    CWBASE+1    ; Clock data port (same as command)
  15. CLKREAD    EQU    32        ; Read command bit
  16. CLKHOLD    EQU    64        ; Hold command bit
  17. ;
  18. TIME:    LXI    H,RTCBUF    ; Point to RTC buffer
  19.     MVI    C,5        ; Set counter for hour tens
  20.     CALL    RDIGIT        ; Get hour tens
  21.     ANI    3
  22.     CALL    SHFT4        ; Save in buffer
  23.     CALL    MULT10        ; Multiply by 10
  24.     MOV    B,A        ; Save in B reg
  25.     CALL    RDIGIT        ; Get hour units in A reg
  26.     CALL    ADDLOW        ; Set BCD digit
  27.     ADD    B        ; Add tens digit from B
  28.     STA    CCHOUR        ; Store for later use
  29. ;
  30. ;    Minutes
  31. ;
  32.     CALL    RDIGIT        ; Get minute tens in A reg
  33.     CALL    SHFT4        ; Save in buffer
  34.     CALL    MULT10        ; Multiply by 10
  35.     MOV    B,A        ; Save in B reg
  36.     CALL    RDIGIT        ; Get minute units in A reg
  37.     CALL    ADDLOW        ; Set BCD digit
  38.     ADD    B        ; Add in minutes tens from B
  39.     STA    CCMIN        ; Store for later use
  40. ;
  41. ;    Seconds
  42. ;
  43.     CALL    RDIGIT        ; Second tens
  44.     CALL    SHFT4
  45.     CALL    RDIGIT        ; Second units
  46.     CALL    ADDLOW
  47. ;
  48. ;    Year
  49. ;
  50.     INX    H        ; Skip over "19"
  51.     MVI    C,12        ; Start with years tens
  52.     CALL    RDIGIT
  53.     CALL    SHFT4
  54.     CALL    RDIGIT        ; Years units
  55.     CALL    ADDLOW
  56. ;
  57.     CALL    RDIGIT        ; Month tens
  58.     CALL    SHFT4
  59.     CALL    RDIGIT        ; Month units
  60.     CALL    ADDLOW
  61. ;
  62.     CALL    RDIGIT        ; Day tens
  63.     CALL    SHFT4
  64.     CALL    RDIGIT        ; Day units
  65.     CALL    ADDLOW
  66. ;
  67.     XRA    A
  68.     OUT    CLKCMD        ; Turn off hold bit
  69.     RET
  70. ;
  71. ;    Read a digit
  72. ;        Command in C
  73. ;        Digit returned in A
  74. ;        C is decremented
  75. ;        Hold bit is set
  76. ;
  77. RDIGIT:    MVI    A,CLKHOLD    ; Set clock hold command
  78.     OUT    CLKCMD
  79.     MVI    A,6
  80. RDLP1:    XTHL
  81.     XTHL
  82.     DCR    A
  83.     JNZ    RDLP1
  84. ;
  85.     MOV    A,C
  86.     DCR    C
  87.     ORI    CLKREAD
  88.     OUT    CLKDATA        ; Select digit
  89.     MVI    A,4
  90. RDLP2:    XTHL
  91.     XTHL
  92.     DCR    A
  93.     JNZ    RDLP2
  94. ;
  95.     IN    CLKDATA        ; read a digit
  96.     ANI    15        ; Strip off any commands
  97.     RET
  98. ;
  99. ;    Multiply register A by 10
  100. ;    Destroys 'D'
  101. ;
  102. MULT10:    ADD    A        ; 2x
  103.     MOV    D,A
  104.     ADD    A        ; 4x
  105.     ADD    A        ; 8x
  106.     ADD    D        ; 10x
  107.     RET
  108. ;
  109. ;    Shift A to high nibble
  110. ;        Stores shifted value in 'M'
  111. ;        Destroys 'E'
  112. ;        A is left unchanged
  113. ;
  114. SHFT4:    MOV    E,A
  115.     ANI    15        ; Only handle lower 4 bits
  116.     RLC            ; Shift A over 4 bits
  117.     RLC
  118.     RLC
  119.     RLC            
  120.     MOV    M,A        ; Save it while we're at it
  121.     MOV    A,E
  122.     RET
  123. ;
  124. ;    Add in low BCD nibble
  125. ;        Gets high nibble from M
  126. ;        Stores new BCD byte in M
  127. ;        Increments HL
  128. ;        Destroyes 'E'
  129. ;
  130. ADDLOW:    MOV    E,A
  131.     ANI    15        ; Deal with low nibble only
  132.     ORA    M        ; Add in high nibble from tens digit
  133.     MOV    M,A        ; Save new BCD byte in buffer
  134.     INX    H        ; Move on to next location
  135.     MOV    A,E
  136.     RET
  137.      ENDIF
  138. ;
  139.