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

  1.  
  2.     title    'STATTIME as of october 20, 1980'
  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. ;
  26. ;    STATTIME.ASM (revised 10/16/80)
  27. ;
  28. ;    Revised from the May 1980, INTERFACE AGE MAGAZINE
  29. ;
  30. ;    For Compu-Time T-102 TIME/DATE board (With MM 5375 AC)
  31. ;
  32. ;       or,
  33. ;
  34. ;    QT Computer Systems Inc. "Clock/Calendar +" board
  35. ;
  36. ;
  37. bdos    equ    5
  38. pbuf    equ    9
  39.  
  40. stat    equ    433h    ; STAT.COM entry address
  41.  
  42. cr    equ    0dh    ; ASCII carriage return
  43. lf    equ    0ah    ; ASCII line feed
  44.  
  45. true    equ    -1    ; define true
  46. false    equ    not true; define false
  47. qt    equ    true    ; define QT Computer Systems Clock/Calendar + board
  48. ct    equ    false    ; Compu-Time Time/Date board
  49.  
  50.     if qt
  51.  
  52. clock    equ    080h    ; real time clock base port address
  53.  
  54.     endif
  55.  
  56.     if ct
  57.  
  58. clock    equ    024h    ; real time clock base port address
  59.  
  60.     endif
  61.  
  62.  
  63.     org     0100h
  64.  
  65.     jmp    date
  66.  
  67.     org    1501h    ; version 2.2 stat.com entry address
  68.  
  69. date:    push psw ! push b ! push d ! push h
  70.     lxi    h,month    ; point to month
  71.     mvi    d,8    ; select month tens digit
  72.     call    digit    ; read and store high digit
  73.     rlc ! rlc ! rlc ! rlc    ; shift to high order hex digit
  74.     mov    b,a    ; save in b reg.
  75.     call    digit    ; read and store month units digit
  76.     ora    b    ; or-in the units and tens digit
  77.     mov    b,a    ; save the month in b reg.
  78.     call    digit    ; read and store the day tens digit
  79.     rlc ! rlc ! rlc ! rlc    ; shift to high order hex digit
  80.     mov    c,a    ; save in c reg.
  81.     call    digit    ; read and store day units digit
  82.     ora    c    ; or-in the units and tens digit
  83.     mov    c,a    ; save the day in c reg.
  84.  
  85. ;
  86. ; test the date, and convert it to four year calendar format
  87. ;
  88.  
  89.     cpi    031h    ; 31st day?
  90.     mov    a,b    ; get the month, for next test
  91.     jnz    m2    ; if not the 31st, test for february
  92.     cpi    2    ; test for months < 31 days
  93.     jz    fix    ; ...and fix if needed
  94.     cpi    4
  95.     jz    fix
  96.     cpi    6
  97.     jz    fix
  98.     cpi    9
  99.     jz    fix
  100.     cpi    011h
  101.     jz    fix
  102. m2:    cpi    2    ; test for february
  103.     jnz    time    ; if not february, then read time
  104.     mov    a,c    ; get day for test
  105.     cpi    029h    ; is this the 29th day?
  106.  
  107. ;
  108. ; insert two NOP's over previous instruction, if this is a leap year
  109. ;
  110.     jz    fix    ; fix date...
  111.     cpi    030h    ; 30th day?
  112.     jnz    time    ; if not the 29th or 30th, go read time
  113. fix:    mvi    a,41    ; select month units and fast set
  114.     call    rdigit    ; read the month units digit
  115.     mov    b,a    ; save in b reg.
  116. floop:    in    clock    ; read the months unit digit
  117.     cmp    b    ; test for digit changed
  118.     jz    floop    ; wait until month is bumped (stable data)
  119. time:    lxi    h,hour    ; point to hour
  120.     mvi    d,0    ; select hour tens digit
  121.     call    ddigit    ; read hour tens and units
  122.     inx    h    ; step over ":"
  123.     call    ddigit    ; read minutes tens and units
  124.     inx    h    ; step over ":"
  125.     call    ddigit    ; read second tens and units
  126.     lxi    d,pdate    ; point to date and time message
  127.     mvi    c,pbuf    ; print buffer function
  128.     call    bdos    ; let CP/M do the work...
  129.     lda    month    ; get high byte of the month
  130.     cpi    ' '    ; in the range of january to september?
  131.     jz    jansept
  132.     lda    month+1    ; must be october to december...
  133.     cpi    '0'    ; october?
  134.     lxi    d,oct
  135.     jz    pmonth    ; print, if so
  136.     cpi    '1'    ; november?
  137.     lxi    d,nov
  138.     jz    pmonth    ; print, if so
  139.     lxi    d,dec    ; december.
  140.     jmp    pmonth    ; print it...
  141. jansept:lda    month+1    ; it's january to september
  142.     cpi    '1'    ; january?
  143.     lxi    d,jan
  144.     jz    pmonth    ; print, if so
  145.     cpi    '2'    ; february?
  146.     lxi    d,feb
  147.     jz    pmonth    ; print, if so
  148.     cpi    '3'    ; march?
  149.     lxi    d,mar
  150.     jz    pmonth    ; print, if so
  151.     cpi    '4'    ; april?
  152.     lxi    d,apr
  153.     jz    pmonth    ; print, if so
  154.     cpi    '5'    ; may?
  155.     lxi    d,may
  156.     jz    pmonth    ; print, if so
  157.     cpi    '6'    ; june?
  158.     lxi    d,jun
  159.     jz    pmonth    ; print month
  160.     cpi    '7'    ; july?
  161.     lxi    d,jul
  162.     jz    pmonth    ; print, if so
  163.     cpi    '8'    ; august?
  164.     lxi    d,aug
  165.     jz    pmonth    ; print, if so
  166.     lxi    d,sep    ; it's september
  167. pmonth:    mvi    c,pbuf    ; print buffer function
  168.     call    bdos    ; let CP/M do the work...
  169. done:    lxi    d,day    ; get the day
  170.     mvi    c,pbuf    ; print buffer function
  171.     call    bdos    ; let CP/M do the work...
  172.     pop h ! pop d ! pop b ! pop psw
  173.     jmp    stat    ; now jump into STAT...
  174.  
  175. ddigit:    call    digit    ; read and store two digits
  176. digit:    mov    a,d    ; move digit select code to a reg.
  177.     call    rdigit    ; read a clock digit
  178.     cpi    0ffh    ; test for board present
  179.     jz    nobrd    ; go print error message
  180.     ori    030h    ; convert digit to ASCII
  181.     cpi    03fh    ; test for blanked leading zero
  182.     jnz    store    ; go store digit, if not blanked
  183.     mvi    a,020h    ; convert to a blank
  184. store:    mov    m,a    ; store the digit in message buffer
  185.     inx    h    ; bump message pointer buffer location
  186.     inr    d    ; step to next digit
  187.     ani    00fh    ; mask off high ASCII nibble
  188.     ret        ; return with digit in a reg.
  189.  
  190. nobrd:    pop    h    ; adjust the stack
  191.     lxi    d,errmsg; point to the error message
  192.     jmp    done    ; print error message, and exit to CP/M
  193.  
  194. rdigit:    out    clock    ; select digit
  195.     mvi    a,0    ; ...some delay time for settling
  196. dloop:    dcr    a
  197.     jnz    dloop
  198.     in    clock    ; read a digit
  199.     ret        ; return with digit in a reg.
  200.  
  201. ;
  202. ; message buffers
  203. ;
  204.  
  205. pdate:    db    cr,lf,'Date: $'
  206. month:    ds    2    ; the month
  207. day:    db    'xx, '    ; the day...
  208.     db    '1980'    ; the year...
  209.     db    '  Time: '
  210. hour:    db    'xx:'    ; the hour...
  211.     db    'xx:'    ; the minute...
  212.     db    'xx'    ; the second...
  213.     db    cr,lf,'$'    ; string delimeter
  214.  
  215. errmsg:    db    cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$'
  216.  
  217. jan:    db    'January $'
  218. feb:    db    'February $'
  219. mar:    db    'March $'
  220. apr:    db    'April $'
  221. may:    db    'May $'
  222. jun:    db    'June $'
  223. jul:    db    'July $'
  224. Aug:    db    'August $'
  225. sep:    db    'September $'
  226. oct:    db    'October $'
  227. nov:    db    'November $'
  228. dec:    db    'December $'
  229.  
  230.     end
  231.  
  232.