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

  1.  
  2.     title    'MACTIME as of october 20, 1980'
  3.  
  4. ;  Here  is  an  interesting  "patch"  to  Digital  Research's 
  5. ; MAC.COM, that incorporates a "real time clock display.  This 
  6. ; patch   works with MAC.COM version 2.0 ONLY.  Merge it  into 
  7. ; MAC.COM as follows:
  8. ;      A>DDT MAC.COM<cr>
  9. ;      NEXT   PC
  10. ;      2F00  0100
  11. ;      -IMACTIME.HEX<cr>
  12. ;      -R<cr>
  13. ;      NEXT   PC
  14. ;      308E  0000
  15. ;      -^C
  16. ;      A>SAVE 48 MACTIME.COM<cr>
  17. ;  Now  you have a new "MAC" command file called  MACTIME.COM; 
  18. ; now  re-assemble  MACTIME.ASM (assuming your  clock/calendar 
  19. ; board, and the time is properly set) with MACTIME.COM.
  20. ;  Notice,  that  the date and time will be displayed  at  the 
  21. ; start  of execution.  Also because the "title" pseudo-op was 
  22. ; used,  the  time  is  listed  in the  ".PRN"  file  that  is 
  23. ; generated, on each page heading.
  24. ;                         Best regards,
  25. ;           
  26. ;                         Kelly Smith, MP/M-Net (tm) Sysop
  27. ;                         (805) 527-9321 (Modem, 300 Baud)
  28. ;
  29. ;
  30. ;
  31. ; For Compu-Time T-102 TIME/DATE board (With MM 5375 AC)
  32. ;
  33. ; or,
  34. ;
  35. ; QT Computer Systems Inc. "Clock/Calendar +" board
  36. ;
  37. ;
  38. true    equ    -1    ; define true
  39. false    equ    not true; define false
  40. qt    equ    true    ; define QT Computer Systems Inc. board
  41. ct    equ    false    ; define Compu-Time board
  42.  
  43. bdos    equ    5
  44. pbuf    equ    9
  45.  
  46. cr    equ    0dh    ; ASCII carriage return
  47. lf    equ    0ah    ; ASCII line feed
  48.  
  49. mac    equ    128h    ; entry address to MAC.COM
  50.  
  51. overlay    equ    2cd3h    ; overlay area in MAC.COM
  52.  
  53.     if    qt
  54.  
  55. clock    equ    080h    ; real time clock base port address
  56.  
  57.     endif
  58.  
  59.     if    ct
  60.  
  61. clock    equ    024h    ; real time clock base port address
  62.  
  63.     endif
  64.  
  65.     org    100h
  66.  
  67.     jmp    date    ; jump to set date and time
  68.  
  69.     org    2f00h    ; date and time routine
  70.  
  71. date:    lxi    h,month    ; point to month
  72.     mvi    d,8    ; select month tens digit
  73.     call    digit    ; read and store high digit
  74.     rlc ! rlc ! rlc ! rlc    ; shift to high order hex digit
  75.     mov    b,a    ; save in b reg.
  76.     call    digit    ; read and store month units digit
  77.     ora    b    ; or-in the units and tens digit
  78.     mov    b,a    ; save the month in b reg.
  79.     call    digit    ; read and store the day tens digit
  80.     rlc ! rlc ! rlc ! rlc    ; shift to high order hex digit
  81.     mov    c,a    ; save in c reg.
  82.     call    digit    ; read and store day units digit
  83.     ora    c    ; or-in the units and tens digit
  84.     mov    c,a    ; save the day in c reg.
  85.  
  86. ;
  87. ; test the date, and convert it to four year calendar format
  88. ;
  89.  
  90.     cpi    031h    ; 31st day?
  91.     mov    a,b    ; get the month, for next test
  92.     jnz    m2    ; if not the 31st, test for february
  93.     cpi    2    ; test for months < 31 days
  94.     jz    fix    ; ...and fix if needed
  95.     cpi    4
  96.     jz    fix
  97.     cpi    6
  98.     jz    fix
  99.     cpi    9
  100.     jz    fix
  101.     cpi    011h
  102.     jz    fix
  103. m2:    cpi    2    ; test for february
  104.     jnz    time    ; if not february, then read time
  105.     mov    a,c    ; get day for test
  106.     cpi    029h    ; is this the 29th day?
  107.  
  108. ;
  109. ; insert two NOP's over previous instruction, if this is a leap year
  110. ;
  111.     jz    fix    ; fix date...
  112.     cpi    030h    ; 30th day?
  113.     jnz    time    ; if not the 29th or 30th, go read time
  114. fix:    mvi    a,41    ; select month units and fast set
  115.     call    rdigit    ; read the month units digit
  116.     mov    b,a    ; save in b reg.
  117. floop:    in    clock    ; read the months unit digit
  118.     cmp    b    ; test for digit changed
  119.     jz    floop    ; wait until month is bumped (stable data)
  120. time:    lxi    h,hour    ; point to hour
  121.     mvi    d,0    ; select hour tens digit
  122.     call    ddigit    ; read hour tens and units
  123.     inx    h    ; step over ":"
  124.     call    ddigit    ; read minutes tens and units
  125.     inx    h    ; step over ":"
  126.     call    ddigit    ; read second tens and units
  127.     lda    month    ; get high byte of the month
  128.     cpi    ' '    ; in the range of january to september?
  129.     jz    jansept
  130.     lda    month+1    ; must be october to december...
  131.     cpi    '0'    ; october?
  132.     lxi    d,oct
  133.     jz    mmonth    ; move, if so
  134.     cpi    '1'    ; november?
  135.     lxi    d,nov
  136.     jz    mmonth    ; move, if so
  137.     lxi    d,dec    ; december!
  138.     jmp    mmonth    ; move it...
  139. jansept:lda    month+1    ; it's january to september
  140.     cpi    '1'    ; january?
  141.     lxi    d,jan
  142.     jz    mmonth    ; move, if so
  143.     cpi    '2'    ; february?
  144.     lxi    d,feb
  145.     jz    mmonth    ; move, if so
  146.     cpi    '3'    ; march?
  147.     lxi    d,mar
  148.     jz    mmonth    ; move, if so
  149.     cpi    '4'    ; april?
  150.     lxi    d,apr
  151.     jz    mmonth    ; move, if so
  152.     cpi    '5'    ; may?
  153.     lxi    d,may
  154.     jz    mmonth    ; move, if so
  155.     cpi    '6'    ; june?
  156.     lxi    d,jun
  157.     jz    mmonth    ; move month
  158.     cpi    '7'    ; july?
  159.     lxi    d,jul
  160.     jz    mmonth    ; move, if so
  161.     cpi    '8'    ; august?
  162.     lxi    d,aug
  163.     jz    mmonth    ; move, if so
  164.     lxi    d,sep    ; it's september
  165. mmonth:    mvi    b,4    ; four characters to move
  166.     lxi    h,fakem    ; place to move real month
  167. movem:    ldax    d    ; get the character to move
  168.     mov    m,a    ; move it
  169.     inx    h    ; bump both pointers
  170.     inx    d
  171.     dcr    b    ; de-bump the count left to move..
  172.     jnz    movem    ; loop 'till all characters moved
  173.     lxi    h,overlay        ; point to overlay area
  174.     lxi    d,fakem        ; point to stuff to be moved
  175.     mvi    b,end$move-start$move    ; how much to move...
  176. move1:    ldax    d    ; get stuff to move
  177.     mov    m,a    ; move it...
  178.     inx    h    ; bump both pointers
  179.     inx    d
  180.     dcr    b    ; de-bump the move counter
  181.     jnz    move1    ; loop 'till it's all moved
  182. done:    jmp    mac    ; now jump into MAC...
  183.  
  184. ddigit:    call    digit    ; read and store two digits
  185. digit:    mov    a,d    ; move digit select code to a reg.
  186.     call    rdigit    ; read a clock digit
  187.     cpi    0ffh    ; test for board present
  188.     jz    nobrd    ; go print error message
  189.     ori    030h    ; convert digit to ASCII
  190.     cpi    03fh    ; test for blanked leading zero
  191.     jnz    store    ; go store digit, if not blanked
  192.     mvi    a,020h    ; convert to a blank
  193. store:    mov    m,a    ; store the digit in message buffer
  194.     inx    h    ; bump message pointer buffer location
  195.     inr    d    ; step to next digit
  196.     ani    00fh    ; mask off high ASCII nibble
  197.     ret        ; return with digit in a reg.
  198.  
  199. nobrd:    pop    h    ; adjust the stack
  200.     lxi    d,errmsg; point to the error message
  201.     mvi    c,pbuf    ; print buffer function
  202.     call    bdos    ; let CP/M do the work
  203.     jmp    done    ; print error message, and exit to CP/M
  204.  
  205. rdigit:    out    clock    ; select digit
  206.     mvi    a,0    ; ...some delay time for settling
  207. dloop:    dcr    a
  208.     jnz    dloop
  209.     in    clock    ; read a digit
  210.     ret        ; return with digit in a reg.
  211.  
  212. ;
  213. ; message buffers
  214. ;
  215.  
  216. start$move    equ    $    ; start moving from here
  217. fakem:    ds    2    ; storage for faked-out month,
  218.             ; which will overlay the next four bytes
  219. month:    ds    4    ; storage for the real month and date
  220.     db    ',1980 '; the year...
  221. hour:    db    'xx:'    ; the hour...
  222.     db    'xx:'    ; the minute...
  223.     db    'xx'    ; the second...
  224.     db    0dh    ; string delimeter
  225. end$move    equ    $    ; end of move
  226.  
  227. errmsg:    db    cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$'
  228.  
  229. jan:    db    'Jan '
  230. feb:    db    'Feb '
  231. mar:    db    'Mar '
  232. apr:    db    'Apr '
  233. may:    db    'May '
  234. jun:    db    'Jun '
  235. jul:    db    'Jul '
  236. Aug:    db    'Aug '
  237. sep:    db    'Sep '
  238. oct:    db    'Oct '
  239. nov:    db    'Nov '
  240. dec:    db    'Dec '
  241.  
  242.     end
  243.  
  244.