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

  1. ;
  2. ;**********************************************************************
  3. ;
  4. ;    Generic OKI Semiconductor MSM5832 Clock Routine for BYE5
  5. ;
  6. ;    The 5832 is wired with a 74LS138, 74LS85 and input tristate gate
  7. ;    based at 0F0h. 0F0h is the seconds 'units' and 0FCh is the year
  8. ;    'tens' place. In all cases, the least significant nibble is used
  9. ;    for the clock data, the most significant nibble is garbage. Yea, I
  10. ;    know it is not the most elegant way to do it, but it is cheap. Of
  11. ;    this there is no doubt. My implementation is on the unused prototype 
  12. ;    area of a Mullen S100 bus extender. 5 chips, one oddball crystal - 
  13. ;    32khz -  and a couple of hearing aid batteries for power down standby 
  14. ;    (my clock has been running for over two years without changing them) 
  15. ;    ... well under 20 bucks and an hour to build. Nothing fancy, but
  16. ;    it does work very well.
  17. ;
  18. ;    Leave me a message in my MINIRBBS and Ill drop ya a drawing of it.
  19. ;
  20. ;                            JP Sojak - sysop
  21. ;                            Smokin Silicon RCPM
  22. ;                            (312) 941-0049 
  23. ;
  24. ; Real-Time clock buffer - is organized as HH:MM:SS YYYY/MM/DD
  25. ;
  26. ;RTCBUF:
  27. ;    DB    99H,99H,99H    ;HH:MM:SS (BCD 24HR TIME) 00:00:00-23:59:59
  28. ;    DB    19H,84H,01H,31H ;YYYY/MM/DD (BCD ISO DATE)
  29. ;
  30. ; BYE5 saves and restores registers before/after calling TIME.
  31. ;
  32. CBASE    EQU    0F0h
  33. ;
  34. TIME:    IN    CBASE+5        ; Hours tens place
  35.     ANI    00000011B
  36.     MOV    B,A
  37.     IN    CBASE+4        ; Hours ones place
  38.     CALL    SHFTIT
  39.     STA    RTCBUF+0
  40. ;
  41.     IN    CBASE+3        ; Now the tens of minutes
  42.     ANI    00000111B
  43.     MOV    B,A        ; save it at <b> 
  44.     IN    CBASE+2    
  45.     CALL    SHFTIT        
  46.     STA    RTCBUF+1
  47. ;
  48.     IN    CBASE+1        ; Now the tens of seconds
  49.     ANI    00000111B
  50.     MOV    B,A
  51.     IN    CBASE+0        ; now the ticks
  52.     CALL    SHFTIT
  53.     STA    RTCBUF+2
  54. ;
  55. ;    DB    19H,84H,01H,31H ;YYYY/MM/DD (BCD ISO DATE)
  56. ;    
  57.     MVI    A,19H
  58.     STA    RTCBUF+3
  59.     MVI    A,84H
  60.     STA    RTCBUF+4
  61. ;
  62.     IN    CBASE+0Ah    ; Now the tens of month3
  63.     ANI    00000001B
  64.     MOV    B,A
  65.     IN    CBASE+9        ; ones of months
  66.     CALL    SHFTIT
  67.     STA    RTCBUF+5
  68. ;
  69.     IN    CBASE+8        ; Now the day
  70.     ANI    00000011B
  71.     MOV    B,A
  72.     IN    CBASE+7
  73.     CALL    SHFTIT
  74.     STA    RTCBUF+6
  75. ;
  76. CLKEXIT:
  77.     LDA    RTCBUF        ; Pick up BCD HH
  78.     CALL    BCDBIN        ; Convert to binary
  79.     STA    CCHOUR        ; For BYE5
  80.     LDA    RTCBUF+1    ; Pick up BCD MM
  81.     CALL    BCDBIN        ; Convert to binary
  82.     STA    CCMIN        ; For BYE
  83.     RET            ; And return (for now..)
  84.  
  85. SHFTIT:    PUSH    PSW        ; Save the units digit
  86.     MOV    A,B        ; Recover the Tens
  87.     RLC
  88.     RLC
  89.     RLC
  90.     RLC            ; made it the MSN
  91.     MOV    B,A        ; save tens here
  92.     POP    PSW        ; get the units again
  93.     ANI    00001111B    ; and mask crap off
  94.     ORA    B        ; OR in the tens place 
  95.     RET            ; and return with it in <a>
  96. ;
  97. ;**********************************************************************
  98. ;
  99. ; This is the end of the TIME insert for BYE500 and up.
  100. ; Replace the existing BYE5 TIME code with this insert.
  101. ; It SHOULD work fine...
  102. ;
  103. ;**********************************************************************
  104. ;
  105.