home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol130 / tmodqt.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  2.8 KB  |  199 lines

  1. title    tmodqt.mac version 2.1
  2.     name    ('tmodqt')
  3. ;    version 2.1    
  4. ;    for CompuPro System Support One
  5. ;    (a good starting point for any 5832 based clock)
  6. ;    by dick lieber
  7. ;    modified for the QT "Computer Watch"
  8. ;    by Glen York 10/05/82 changes marked by @QT
  9.  
  10. base    equ    3Ch        ;this is where glen has his board @QT
  11. clkcmd    equ    base + 01h    ; @QT
  12. clkdata    equ    base + 02h    ; @QT
  13. hold    equ    10h        ; @QT
  14. write    equ    10h        ; @QT
  15. read    equ    20h        ; @QT
  16.  
  17. bdos    equ    5
  18. wrcon    equ    2
  19. wrbuf    equ    9
  20.  
  21. entry    timemd,datemd,daymd
  22.  
  23. timemd:    jmp    gettime
  24. datemd:    jmp    getdate
  25. daymd:    jmp    getdow
  26.  
  27. gettime:
  28.     push    h
  29.     call    getclock
  30.     pop    h
  31.     call    findstring    ;hl points to string
  32.     lxi    d,hours
  33.     call    stashit
  34.     call    stashit
  35.     mvi    m,':'
  36.     inx    h
  37.     call    stashit
  38.     call    stashit
  39.     mvi    m,':'
  40.     inx    h
  41.     call    stashit
  42.     call    stashit
  43.     mvi    m,'$'
  44.     ret
  45.  
  46. getdate:
  47.     push    h
  48.     call    getclock
  49.     pop    h
  50.     call    findstring    ;hl points to string
  51.     lxi    d,months
  52.     call    stashit
  53.     call    stashit
  54.     mvi    m,'/'
  55.     inx    h
  56.     call    stashit
  57.     call    stashit
  58.     mvi    m,'/'
  59.     inx    h
  60.     lxi    d,years
  61.     call    stashit
  62.     call    stashit
  63.     mvi    m,'$'
  64.     ret
  65. ;
  66. ;    get day of week
  67. ;
  68. getdow:
  69.     push    h
  70.     call    getclock
  71.     lda    dow
  72.     ani    7    ;strip ascii bias
  73.     lxi    h,dowtable    ;point to index to day text
  74.     mvi    b,0        ;
  75.     mov    c,a        ; zero bc
  76.     dad    b
  77.     dad    b        ;2 bytes per table entry
  78.     mov    e,m
  79.     inx    h
  80.     mov    d,m        ;de point to text string
  81.     pop    h
  82.     push    d
  83.     call    findstring    ;hl points to output string
  84.     pop    d
  85. dowloop:
  86.     ldax    d
  87.     mov    m,a
  88.     cpi    '$'
  89.     rz
  90.     inx    h
  91.     inx    d
  92.     jmp    dowloop
  93. ;
  94. ;    get time/date/dow into table
  95. ;
  96. getclock:
  97.     call    read5832
  98. ;
  99. ;    clear leap year flag
  100. ;    (leap year flag is in tens of days bit 2)
  101. ;
  102.     lxi    h,days    
  103.     mov    a,m
  104.     sta    leapflag    ;save for later
  105.     mvi    a,0f3h
  106.     ana    m
  107.     mov    m,a    
  108. ;
  109. ;    clear 24 hour flag
  110. ;    (kept in tens of hours bit 3)
  111. ;
  112.     lxi    h,hours
  113.     mvi    a,0f3h
  114.     ana    m
  115.     mov    m,a
  116.     ret
  117. ;
  118. ;    process passed parameter 
  119. ;    makes hl point to passed string
  120. ;
  121. findstring:
  122.     inx    h    ;past length - assumed to be 9
  123.     mov    e,m
  124.     inx    h    ;get address of passed string into de
  125.     mov    d,m
  126.     xchg
  127.     ret
  128. ;
  129. ;    move byte from (de) to (hl)
  130. ;
  131. stashit:
  132.     ldax    d
  133.     mov    m,a
  134.     inx    h
  135.     inx    d
  136.     ret
  137. ;
  138. ;    read all of clock - put into table
  139. ;
  140. read5832:
  141.     mvi    a,hold    ; @QT stop the clock
  142.     out    clkcmd    ; @QT to prevent digit roll-over
  143.     mvi    b,read+13 ; @QT 13 regs, 0-12
  144.      mvi    c,14    ;# of byte to read
  145.     lxi    h,table
  146. readloop:
  147.     dcr    b
  148.     mov    a,b
  149.     out    clkdata    ; @QT 
  150.     PUSH    PSW    ;waste some time @QT
  151.     POP    PSW    ;while clock settles @QT
  152.     in    clkdata    ; @QT
  153.     ori    '0'
  154.     mov    m,a
  155.     inx    h
  156.     mvi    a,0fh
  157.     ana    b
  158.     jnz    readloop
  159.     xra    a
  160.     out    clkcmd
  161.     ret;
  162. ;
  163. ;    ram area
  164. ;
  165. leapflag:
  166.     ds    1
  167. ;
  168. ;    table of data as read from 5832
  169. ;    don't change order
  170. ;
  171. table:     
  172. years:    ds    2
  173. months:    ds    2
  174. days:    ds    2
  175. dow:    ds    1
  176. hours:    ds    2
  177. minutes: ds    2
  178. seconds: ds    2
  179.  
  180. ;
  181. ;    day of week table
  182. ;
  183. dowtable:
  184.     dw    sun    ; @QT
  185.     dw    mon    ; @QT
  186.     dw    tues
  187.     dw    wed
  188.     dw    thurs
  189.     dw    fri
  190.     dw    sat
  191. mon:    db    'Monday$'
  192. tues:    db    'Tuesday$'
  193. wed:    db    'Wedesday$'
  194. thurs:    db    'Thursday$'
  195. fri:    db    'Friday$'
  196. sat:    db    'Saturday$'
  197. sun:    db    'Sunday$'
  198.     end
  199.