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

  1. ;
  2. ;                       BYE3 CLOCK INSERT
  3. ;                              for
  4. ;                  Zilog Z80A CTC Binary Clock
  5. ;                         by Don Brown
  6. ;
  7. ; This routine is for a clock that is maintained in low memory, CP/M page 0.  
  8. ; Channel 3 of a Zilog Z80A CTC (60 hertz) clock is preprogrammed to interrupt
  9. ; every 1/60th of a second so that the BIOS can maintain the current date &
  10. ; time in locations 40h - 46h, represented in Binary.
  11. ;
  12. ; This is in insert (not an overly) to implement the BYE3 'RTC' and must be
  13. ; inserted into BYE3 at the appropriately marked location in that code.
  14. ;
  15. ;=============================================================================
  16. ;
  17. ; 07/27/85    Initial Release.  Compatible with BYE337    - Don Brown
  18. ;
  19. ;=============================================================================
  20. ;
  21. ; The Real-Time clock buffer 'RTCBUF', is organized: 'HH:MM:SS YYYY/MM/DD'.
  22. ;
  23. ; RTCBUF: DB 99h,99h,99h    ; HH:MM:SS (BCD 24 Hr. Time)
  24. ;         DB 19h,84h,01h,31h    ; YYYY/MM/DD (BCD ISO Date) 1984/01/31
  25. ;
  26. ;      BCD 24 Hr. Time:  HH = 0-23
  27. ;                        MM = 0-59
  28. ;                SS = 0-59
  29. ;
  30. ; The BIOS stores the current Date and time, in Binary, as follows:
  31. ;
  32. ;    40h = Fractions of a Second (1/62nds)
  33. ;    41h = Seconds (0-59)
  34. ;    42h = Minutes (0-59)
  35. ;    43h = Hours   (0-23)
  36. ;    44h = Months  (1-12)
  37. ;    45h = Days    (1-31)
  38. ;    46h = Years   (1-99)
  39. ;
  40. ; This insert requires the 'BINBCD:', (BIN2BCD EQU YES), routine in BYE3 to
  41. ; convert the binary date and time to BCD date and time.
  42. ;
  43. ;=============================================================================
  44. ;
  45. ; CONFIGURATION SECTION
  46. ; ---------------------
  47. ;
  48.      IF    RTC
  49. CLKBASE    EQU    40h        ; Base address of time & date in page 0
  50. CENTURY    EQU    19h        ; Century (BCD) our clock doesn't have it
  51. ;
  52. ;=============================================================================
  53. ;
  54. TIME:    LDA    CLKBASE+3    ; Read the Clock - Binary Hours
  55.     STA    CCHOUR        ; Store Binary Hours
  56.     CALL    BINBCD        ; Convert Hours from Binary to BCD
  57.     STA    RTCBUF+0    ; Store BCD Hours
  58. ;
  59.     LDA    CLKBASE+2    ; Read the Clock - Binary Minutes
  60.     STA    CCMIN        ; Store Binary Minutes
  61.     CALL    BINBCD        ; Convert Minutes from Binary to BCD
  62.     STA    RTCBUF+1    ; Store BCD Minutes
  63. ;
  64.     LDA    CLKBASE+1    ; Read the Clock - Binary Seconds
  65.     CALL    BINBCD        ; Convert Seconds from Binary to BCD
  66.     STA    RTCBUF+2    ; Store BCD Seconds
  67. ;
  68.     LDA    CLKBASE+4    ; Read the Clock - Binary Months
  69.     CALL    BINBCD        ; Convert Months from Binary to BCD
  70.     STA    RTCBUF+5    ; Store BCD Months
  71. ;
  72.     LDA    CLKBASE+5    ; Read the Clock - Binary Days
  73.     CALL    BINBCD        ; Convert Days from Binary to BCD
  74.     STA    RTCBUF+6    ; Store the BCD Days
  75. ;
  76.     LDA    CLKBASE+6    ; Read the Clock - Binary Years
  77.     CALL    BINBCD        ; Convert Years from Binary to BCD
  78.     STA    RTCBUF+4    ; Store the BCD Years
  79. ;
  80.     LDA    CENTURY        ; Get the Century Configured in this insert
  81.     STA    RTCBUF+3    ; Store the BCD Century
  82. ;
  83.     RET            ; Return to Bye
  84.      ENDIF            ; RTC
  85. ;
  86. ;=============================================================================
  87.