home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol075 / stattime.asm < prev    next >
Assembly Source File  |  1984-04-29  |  5KB  |  245 lines

  1.  
  2.     title    'STATTIME as of April 6, 1982'
  3.  
  4. ;  Here  is  an  interesting  "patch"  to  Digital  Research's 
  5. ; STAT.COM, that incorporates a "real time clock display. This 
  6. ; patch  works with STAT.COM for CP/M version 2.2 ONLY.  Merge 
  7. ; it into STAT.COM as follows:
  8. ;      A>DDT STAT.COM<cr>
  9. ;      NEXT   PC
  10. ;      1580  0100
  11. ;      -ISTATTIME.HEX<cr>
  12. ;      -R<cr>
  13. ;      NEXT   PC
  14. ;      16CD  0000
  15. ;      -^C
  16. ;      A>SAVE 22 STATTIME.COM<cr>
  17. ;  Now you have a new "STAT" command file called STATTIME.COM, 
  18. ; and it will display the "real time" on every execution...
  19. ;                         Best regards,
  20. ;           
  21. ;                         Kelly Smith, MP/M-Net (tm) Sysop
  22. ;                         (805) 527-9321 (Modem, 300 Baud)
  23. ;
  24. ;
  25. ;    06/Apr/82    Revised for Godbout System Support 1 clock
  26. ;            by Bill Bolton, Software Tools, Australia
  27. ;
  28. ;    20/Oct/80    Original version by Kelly Smith
  29. ;
  30. ;
  31. ;
  32. bdos    equ    5
  33. pbuf    equ    9
  34.  
  35. stat    equ    433h    ; STAT.COM entry address
  36.  
  37. cr    equ    0dh    ; ASCII carriage return
  38. lf    equ    0ah    ; ASCII line feed
  39.  
  40. true    equ    0ffh
  41. false    equ    not true; define false
  42. clkread    equ    10H
  43. timlen    equ    12
  44.  
  45. gbclkc    equ    08Ah    ; real time clock base port address
  46. gbclkd    equ    gbclkc+1
  47.  
  48.  
  49.     org     0100h
  50.  
  51.     jmp    date
  52.  
  53.     org    1501h    ; version 2.2 stat.com entry address
  54.  
  55. date:    push    psw
  56.     push    b
  57.     push    d
  58.     push    h
  59. start:
  60.     mvi    a,0+clkread
  61.     out    gbclkc
  62.     in    gbclkd
  63.     cpi    0ffh    ; clock board present?
  64.     jz    done1    ; no, just run normally
  65.     call    rtime
  66.     lxi    h,time
  67.     mov    a,m
  68.     cpi    '0'
  69.     jnz    go$on
  70.     mvi    a,' '
  71. go$on:
  72.     sta    day
  73.     inx    h
  74.     mov    a,m
  75.     sta    day+1
  76.     inx    h
  77.     mov    a,m
  78.     sta    month
  79.     inx    h
  80.     mov    a,m
  81.     sta    month+1
  82.     inx    h
  83.     mov    a,m
  84.     sta    year
  85.     inx    h
  86.     mov    a,m
  87.     sta    year+1
  88.     inx    h
  89.     mov    a,m
  90.     sta    hour
  91.     inx    h
  92.     mov    a,m
  93.     sta    hour+1
  94.     inx    h
  95.     mov    a,m
  96.     sta    minutes
  97.     inx    h
  98.     mov    a,m
  99.     sta    minutes+1
  100.     inx    h
  101.     mov    a,m
  102.     sta    seconds
  103.     inx    h
  104.     mov    a,m
  105.     sta    seconds+1
  106. ;
  107. ; test the date, and convert it to four year calendar format
  108. ;
  109.     lxi    d,pdate    ; point to date and time message
  110.     mvi    c,pbuf    ; print buffer function
  111.     call    bdos    ; let CP/M do the work...
  112.     lda    month    ; get high byte of the month
  113.     cpi    '1'    ; in the range of january to september?
  114.     jnz    jansept ; yes
  115.     lda    month+1
  116.     cpi    '0'
  117.     lxi    d,oct    ; October?
  118.     jz    pmonth    ; print, if so
  119.     cpi    '1'    ; november?
  120.     lxi    d,nov
  121.     jz    pmonth    ; print, if so
  122.     lxi    d,dec    ; december.
  123.     jmp    pmonth    ; print it...
  124. ;
  125. jansept:
  126.     lda    month+1    ; it's january to september
  127.     cpi    '1'    ; january?
  128.     lxi    d,jan
  129.     jz    pmonth    ; print, if so
  130.     cpi    '2'    ; february?
  131.     lxi    d,feb
  132.     jz    pmonth    ; print, if so
  133.     cpi    '3'    ; march?
  134.     lxi    d,mar
  135.     jz    pmonth    ; print, if so
  136.     cpi    '4'    ; april?
  137.     lxi    d,apr
  138.     jz    pmonth    ; print, if so
  139.     cpi    '5'    ; may?
  140.     lxi    d,may
  141.     jz    pmonth    ; print, if so
  142.     cpi    '6'    ; june?
  143.     lxi    d,jun
  144.     jz    pmonth    ; print month
  145.     cpi    '7'    ; july?
  146.     lxi    d,jul
  147.     jz    pmonth    ; print, if so
  148.     cpi    '8'    ; august?
  149.     lxi    d,aug
  150.     jz    pmonth    ; print, if so
  151.     lxi    d,sep    ; it's september
  152. pmonth:
  153.     mvi    c,pbuf    ; print buffer function
  154.     call    bdos    ; let CP/M do the work...
  155. done:
  156.     lxi    d,day    ; get the day
  157.     mvi    c,pbuf    ; print buffer function
  158.     call    bdos    ; let CP/M do the work...
  159. done1:
  160.     pop    h
  161.     pop    d
  162.     pop    b
  163.     pop    psw
  164.     jmp    stat    ; now jump into STAT...
  165.  
  166. rtime:
  167.     lxi    h,time        ;Address of time save area
  168.     lxi    d,atable    ;Address of digit table
  169.     mvi    b,timlen/2    ;Number of loops to do
  170. tloop:
  171.     call    rone        ;get digit value
  172.     ani    0fh        ;mask of high nibble
  173.     adi    '0'
  174.     mov    m,a
  175.     inx    h
  176.     call    rone
  177.     ani    0fh
  178.     adi    '0'
  179.     mov    m,a        ;save into table
  180.     inx    h        ;point to next digit
  181.     dcr    b        ;adjust loop count
  182.     jnz    tloop
  183.     ret
  184.  
  185. rone:
  186.     ldax    d        ;Get the digit address
  187.     inx    d        ;Point to next address
  188.     out    gbclkc        ;Output the digit address
  189.     cpi    5+clkread    ;Check for hours 10 digit
  190.     in    gbclkd        ;Get the digit
  191.     rnz            ;If not the hours ten digit
  192.     sui    8        ;Kill the 24 hour bit
  193.     ret
  194. ;
  195. ATABLE:
  196.     DB    8+clkread    ;digit address table
  197.     DB    7+clkread
  198.     DB    10+clkread
  199.     DB    9+clkread
  200.     DB    12+clkread
  201.     DB    11+clkread
  202.     DB    5+clkread
  203.     DB    4+clkread
  204.     DB    3+clkread
  205.     DB    2+clkread
  206.     DB    1+clkread
  207.     DB    0+clkread
  208. ;
  209. ; message buffers
  210. ;
  211.  
  212. time    db    0,0,0,0,0,0,0,0,0,0,0,0
  213. pdate:    db    'Date: $'
  214. month:    ds    2    ; the month
  215. day:    db    'xx, '    ; the day...
  216.     db    '19'
  217. year    db    '80'    ; the year...
  218.     db    '  Time: '
  219. hour:    db    'xx:'    ; the hour...
  220. minutes:db    'xx:'    ; the minute...
  221. seconds:db    'xx'    ; the second...
  222.     db    cr,lf,'$'    ; string delimeter
  223.  
  224. errmsg:    db    cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$'
  225.  
  226. jan:    db    'January $'
  227. feb:    db    'February $'
  228. mar:    db    'March $'
  229. apr:    db    'April $'
  230. may:    db    'May $'
  231. jun:    db    'June $'
  232. jul:    db    'July $'
  233. Aug:    db    'August $'
  234. sep:    db    'September $'
  235. oct:    db    'October $'
  236. nov:    db    'November $'
  237. dec:    db    'December $'
  238.  
  239.     end
  240.