home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bye5 / b5-clock.lbr / B5C-COMP.IQS / B5C-COMP.INS
Encoding:
Text File  |  1986-03-09  |  3.8 KB  |  127 lines

  1. ; B5C-COMP.INS    Wayne Masters, Potpourri, (408) 378-7474
  2. ; 08/08/85
  3. ;
  4. ; Adapted from code supplied by Don E. Appleby,  Bankers & Hackers #2
  5. ;**********************************************************************
  6. ;
  7. ;    Computime S-100 Clock/Calendar board Routine for BYE5
  8. ;
  9. ;    The Computime ComputerWatch uses the MSM5832 chip.
  10. ;
  11. ;    The ComputerWatch is interfaced to the bus by two latching type
  12. ;    output ports and one input tristate gate based at 080h. 081h is
  13. ;    the address port and 082h is the data port. Address is selectable.
  14. ;
  15. ;    Output of 10h to the data port raises the HOLD signal.    Output of
  16. ;    register number (+ offset of 20h) to address port sets the address
  17. ;    of the register (0 to 12) to be read.  Registers are 4 bits each
  18. ;    SS MM HH W DD MM YY where W is day of week.  Bits are 1, 2, 4 & 8.
  19. ;    Registers begin with units, then tens in each pair.  The hours ten
  20. ;    digit includes option bits for 12/24 hour format and for AM/PM.  Bit
  21. ;    4 is for AM/PM and bit 8 is used for 12/24 hour format determination.
  22. ;    Bit 8 on is 24 hour and bit 4 on is PM.  The days ten digit includes
  23. ;    an option bit for leap year determination.  If bit 4=0 there are
  24. ;    28 days in February, else there are 29 days in February.  A 150 micro
  25. ;    second delay is required after HOLD signal is raised.  The HOLD
  26. ;    signal must be lowered after reading to enable registersto continue
  27. ;    counting.  Days of week values are 0-6 where 0=Sunday.    Write data
  28. ;    plus offset of 16 to data port.  Write the address plus 16 to the
  29. ;    address port to raise the write signal.
  30. ;
  31. ;
  32. ;RTCBUF:    Example
  33. ;    DB    99H,99H,99H    ;HH:MM:SS (BCD 24HR TIME) 00:00:00-23:59:59
  34. ;    DB    19H,85H,08H,06H ;YY/YY/MM/DD (BCD U.S. DATE)
  35. ;
  36. ; BYE5 saves and restores registers before/after calling TIME.
  37. ;
  38. CBASE    EQU    128            ; Default i/o address of Computime board
  39. CPORT    EQU    CBASE +    2        ; Data port of clock board
  40. ;
  41. ;
  42. TIME:    MVI    A,5            ; Hours tens place
  43.     CALL    CREAD
  44.     ANI    3            ; Strip 12/24, AM/PM bits
  45.     MOV    B,A
  46.     MVI    A,4            ; Hours units place
  47.     CALL    CREAD
  48.     CALL    SHFTIT
  49.     STA    RTCBUF            ; Store in BYE5's rtcbuf
  50.     CALL    BCDBIN            ; To binary
  51.     STA    CCHOUR            ; For current clock hour
  52. ;
  53.     MVI    A,3            ; Now the tens of minutes
  54.     CALL    CREAD
  55.     MOV    B,A            ; Save it at <b>
  56.     MVI    A,2            ; Minute units
  57.     CALL    CREAD
  58.     CALL    SHFTIT
  59.     STA    RTCBUF+1        ; Minutes to rtcbuf
  60.     CALL    BCDBIN            ; And binary
  61.     STA    CCMIN            ; To current clock minute
  62. ;
  63.     MVI    A,1            ; Now the tens of seconds
  64.     CALL    CREAD
  65.     MOV    B,A
  66.     MVI    A,0            ; Now the ticks
  67.     CALL    SHFTIT
  68.     STA    RTCBUF+2        ; Seconds to rtcbuf
  69. ;
  70. ;    Example: 07H,27H,85H    MM/DD/YY (BCD U.S. DATE)
  71. ;
  72.     MVI    A,19H            ; Century
  73.     STA    RTCBUF+3        ; To rtcbuf
  74.     MVI    A,12            ; Year tens
  75.     CALL    CREAD
  76.     MOV    B,A
  77.     MVI    A,11            ; Year units
  78.     CALL    CREAD
  79.     CALL    SHFTIT
  80.     STA    RTCBUF+4
  81.     MVI    A,10            ; Month tens
  82.     CALL    CREAD
  83.     MOV    B,A
  84.     MVI    A,9            ; Month units
  85.     CALL    CREAD
  86.     CALL    SHFTIT
  87.     STA    RTCBUF+5
  88. ;
  89.     MVI    A,8            ; Now the day tens
  90.     CALL    CREAD
  91.     ANI    3            ; Strip leap year bit
  92.     MOV    B,A
  93.     MVI    A,7            ; Days units
  94.     CALL    CREAD
  95.     CALL    SHFTIT
  96.     STA    RTCBUF+6
  97.     RET                ; And return (for now..)
  98. ;
  99. SHFTIT:    PUSH    PSW            ; Save the units digit
  100.     MOV    A,B            ; Recover the Tens
  101.     RLC
  102.     RLC
  103.     RLC
  104.     RLC                ; Made it the MSN
  105.     MOV    B,A            ; Save tens here
  106.     POP    PSW            ; Get the units again
  107.     ANI    00001111B        ; And mask crap off
  108.     ORA    B            ; OR in the tens place
  109.     RET                ; And return with it in <a>
  110.  
  111. CREAD:    ORI    20H            ; Add in the offset
  112.     OUT    CPORT
  113.     NOP                ; A short delay
  114.     NOP
  115.     IN    CPORT            ; Read the digit
  116.     ORA    A            ; Set the flags
  117.     RET
  118. ;
  119. ;**********************************************************************
  120. ;
  121. ; This is the end of the TIME insert for BYE500 and up.
  122. ; Replace the existing BYE5 TIME code with this insert.
  123. ; It SHOULD work fine...
  124. ;
  125. ;**********************************************************************
  126. ;              END OF B5C-COMP.INS
  127.