home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / NUBYE / NUC-KP4.INS < prev    next >
Text File  |  2000-06-30  |  2KB  |  80 lines

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