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

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