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

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