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

  1.  
  2. ; BYE500 Time insert
  3. ; Author: Joe Wright
  4. ; Date: 28 July 1985
  5. ; Version: 1.0
  6.  
  7. ; This insert will read the time from the CCS 2805 Wallclock
  8. ; and place it at RTCBUF as follows:
  9. ;
  10. ; Real-Time clock buffer - is organized as HH:MM:SS YYYY/MM/DD
  11. ;
  12. ;RTCBUF:
  13. ;    DB    99H,99H,99H    ;HH:MM:SS (BCD 24HR TIME) 00:00:00-23:59:59
  14. ;    DB    19H,84H,01H,31H ;YYYY/MM/DD (BCD ISO DATE)
  15. ;
  16. ; Binary values are also stored for CCHOUR and CCMIN
  17. ;
  18. ; BYE500 saves and restores registers before/after calling TIME.
  19. ;
  20.  
  21. BASE    EQU    38H        ; Base address of CCS 2805 pio
  22.  
  23. ADATA    EQU    BASE+4        ; Port a data
  24. ACMND    EQU    BASE+5        ; Port a command
  25. BDATA    EQU    BASE+6        ; Port b data
  26. BCMND    EQU    BASE+7        ; Port b command
  27.  
  28. HOLD    EQU    64        ; Hold 5832 to set up read/write
  29. WR    EQU    32        ; Read 5832
  30. RD    EQU    16        ; Write 5832
  31.  
  32. BSYA    EQU    128        ; Address delay, 6 us.
  33. BSYH    EQU    64        ; Main clock hold delay, 150 us.
  34.  
  35. MODE0    EQU    0FH        ; Pio channel a output mode
  36. MODE3    EQU    0CFH        ; Pio channel b control mode
  37.  
  38. ;
  39. ; set port a to output mode
  40. ;
  41. TIME:
  42.     MVI    A,MODE0        ; Output mode
  43.     OUT    ACMND        ; Cha command port
  44.     MVI    A,3        ; Disable interrupts
  45.     OUT    ACMND        ; Cha command port
  46. ;
  47. ; set port b to read the clock
  48. ;
  49.     MVI    A,MODE3        ; Control mode
  50.     OUT    BCMND        ; Chb command port
  51.     MVI    A,0CFH        ; To read clock
  52.     OUT    BCMND        ; Chb command port
  53.  
  54.     LXI    H,RTCBUF    ; Point to real time clock buffer in Bye500
  55.  
  56.     MVI    A,5        ; High order hours
  57.     CALL    TENS
  58.     ANI    30H        ; Mask off high bits in high nybble
  59.     MOV    B,A        ; Save it for now
  60.     MVI    A,4        ; Low order hours
  61.     CALL    ONES
  62.     CALL    BCDBIN        ; Convert to binary
  63.     STA    CCHOUR
  64.  
  65.     MVI    A,3        ; High minutes
  66.     CALL    TENS
  67.     MVI    A,2        ; Low minutes
  68.     CALL    ONES
  69.     CALL    BCDBIN
  70.     STA    CCMIN
  71.  
  72.     MVI    A,1        ; High seconds
  73.     CALL    TENS
  74.     XRA    A        ; Low seconds
  75.     CALL    ONES
  76.  
  77.     MVI    M,19H        ; Declare 20th century
  78.     INX    H        ; Point to year
  79.  
  80.     MVI    A,12        ; High year
  81.     CALL    TENS
  82.     MVI    A,11        ; Low year
  83.     CALL    ONES
  84.  
  85.     MVI    A,10        ; High month
  86.     CALL    TENS
  87.     MVI    A,9        ; Low month
  88.     CALL    ONES
  89.  
  90.     MVI    A,8        ; High date
  91.     CALL    TENS
  92.     MVI    A,7        ; Low date
  93.     CALL    ONES
  94. ;
  95.     RET            ; End of TIME, return to caller
  96.  
  97. TENS:    CALL    RDCLK        ; Get it
  98.     CALL    SHL4        ; To high nybble
  99.     MOV    B,A        ; Save it a moment
  100.     RET
  101.  
  102. ONES:    CALL    RDCLK
  103.     ORA    B        ; Or in the high nybble
  104.     MOV    M,A        ; Save it in memory
  105.     INX    H        ; Point to next byte
  106.     RET
  107.  
  108. SHL4:
  109.     RAL
  110.     RAL
  111.     RAL
  112.     RAL            ; Shift low to high nybble
  113.     RET
  114.  
  115. RDCLK:    ORI    HOLD        ; Acc has clock address
  116.     OUT    ADATA
  117. RDC1:    IN    BDATA
  118.     ANI    BSYH
  119.     JNZ    RDC1
  120.     IN    ADATA
  121.     ORI    RD
  122.     OUT    ADATA
  123. RDC2:    IN    BDATA
  124.     ANI    BSYA
  125.     JNZ    RDC2
  126.     IN    BDATA
  127.     ANI    0FH        ; Mask hi order
  128.     PUSH    PSW
  129.     XRA    A
  130.     OUT    ADATA
  131.     POP    PSW
  132.     RET
  133. ;
  134. ; END OF B5-2805.INS
  135. ;
  136.