home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / bye3 / b3c-kp4.iqs / B3C-KP4.INS
Text File  |  1985-11-17  |  2KB  |  85 lines

  1. ;
  2. ; B3C-KP4.INS
  3. ;  07/15/85    Clock insert for BYE335 and later
  4. ;        and the KayPro 4-84
  5. ;
  6. ;    Note:    This is an insert, not an overlay.
  7. ;
  8. ;        Use the program TIME2.ASM or later, to initialize your clock
  9. ;        with correct date/time prior to loading BYE.
  10. ;
  11. ;
  12. CENTURY    EQU    019H        ; 19h = 19 bcd, reset this every 100 years
  13. CYEAR    EQU    085H        ; 85h = 85 bcd, reset this every year
  14. RTCA    EQU    20H        ; Clock address select reg
  15. RTCD    EQU    24H        ; Clock data register
  16. RTCS    EQU    22H        ; Clock status register
  17. REGEND    EQU    8        ; Ending register count for time loop
  18. ;
  19. ;
  20.      IF    RTC
  21. TIME:    MVI    A,0CFH        ; Initial status setup byte
  22.     OUT    RTCS        ; Set pio for mode 3 in/output
  23.     MVI    A,0E0H        ; Low 5 bits output, top 3 input
  24.     OUT    RTCS        ; Set pio in/out bits
  25.     MVI    A,03H        ; Disable interrupts
  26.     OUT    RTCS        ; Do it
  27.     MVI    A,14H        ; Status reg addr
  28.     OUT    RTCA        ; Select it
  29.     IN    RTCD        ; Reset status bit
  30. ;
  31. DOREAD:    LXI    H,LOCBUF    ; Point to time save area
  32.     MVI    B,2        ; Start with seconds
  33. ;
  34. BURST:    MOV    A,B        ; A is register we want to read
  35.     CPI    REGEND        ; Gotten all we want?
  36.     JNC    ROLLCK        ; Yes, done getting time
  37.     OUT    RTCA        ; Select that register of clock
  38.     IN    RTCD        ; Read the clock data
  39.     MOV    M,A        ; Save in core
  40.     INX    H        ; Next memory location
  41.     INR    B        ; Next reg addr
  42.     JMP    BURST        ; Go get more data
  43. ;
  44. ; See if the clock rolled over during the reads.
  45. ;
  46. ROLLCK:    MVI    A,14H        ; Status reg addr
  47.     OUT    RTCA        ; Select it
  48.     IN    RTCD        ; Get status
  49.     ORA    A        ; Was clock roll?
  50.     JNZ    DOREAD        ; Yes, go read again
  51. ;
  52. ; Format the date and time for bye's realtime clock buffer
  53. ;
  54.     LDA    LOCBUF        ; BCD seconds
  55.     STA    RTCBUF+2
  56.     LDA    LOCBUF+1    ; BCD minutes
  57.     STA    RTCBUF+1
  58.     CALL    BCDBIN        ; Convert to binary
  59.     STA    CCMIN        ; For bye5
  60.     LDA    LOCBUF+2    ; BCD hours
  61.     STA    RTCBUF
  62.     CALL    BCDBIN        ; Convert to binary
  63.     STA    CCHOUR        ; For bye5
  64.     LDA    LOCBUF+4    ; BCD day of month
  65.     STA    RTCBUF+6
  66.     LDA    LOCBUF+5    ; BCD month
  67.     STA    RTCBUF+5
  68.     MVI    A,CENTURY
  69.     STA    RTCBUF+3
  70.     MVI    A,CYEAR
  71.     STA    RTCBUF+4
  72.     RET            ; All done
  73. ;
  74. ;
  75. LOCBUF:    DB    0        ; Seconds
  76.     DB    0        ; Minutes
  77.     DB    0        ; Hours
  78.     DB    0        ; Day of week (not used by us)
  79.     DB    0        ; Day of month
  80.     DB    0        ; Month of year
  81.      ENDIF    ;RTC
  82. ;
  83. ;    End of B3C-KP4.
  84. ;----------------------------------------------------------------
  85.