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

  1.  
  2.     title    'MACTIME as of April 6, 1982'
  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. ;    06/Apr/82    Revised for Godbout System Support 1 clock
  30. ;            by Bill Bolton, Software Tools, Australia
  31. ;
  32. ;    20/Oct/80    Original version by Kelly Smith
  33. ;
  34. ;
  35. ;
  36. bdos    equ    5
  37. pbuf    equ    9
  38.  
  39. mac    equ    128h    ; MAC.COM entry address
  40. overlay    equ    2cd3H
  41.  
  42. cr    equ    0dh    ; ASCII carriage return
  43. lf    equ    0ah    ; ASCII line feed
  44.  
  45. true    equ    0ffh
  46. false    equ    not true; define false
  47. clkread    equ    10H
  48. timlen    equ    12
  49.  
  50. gbclkc    equ    06Ah    ; real time clock base port address
  51. gbclkd    equ    gbclkc+1
  52.  
  53.  
  54.     org     0100h
  55.  
  56.     jmp    start
  57.  
  58.     org    2f00h    ; version 2.0 mac.com entry address
  59.  
  60. start:
  61.     mvi    a,0+clkread
  62.     out    gbclkc
  63.     in    gbclkd
  64.     cpi    0ffh        ;clock board present?
  65.     jz    done        ;no, just run normally
  66.     call    rtime
  67.     lxi    h,time
  68.     mov    a,m
  69.     cpi    '0'
  70.     jnz    go$on
  71.     mvi    a,' '
  72. go$on:
  73.     sta    day
  74.     inx    h
  75.     mov    a,m
  76.     sta    day+1
  77.     inx    h
  78.     mov    a,m
  79.     sta    month
  80.     inx    h
  81.     mov    a,m
  82.     sta    month+1
  83.     inx    h
  84.     mov    a,m
  85.     sta    year
  86.     inx    h
  87.     mov    a,m
  88.     sta    year+1
  89.     inx    h
  90.     mov    a,m
  91.     sta    hour
  92.     inx    h
  93.     mov    a,m
  94.     sta    hour+1
  95.     inx    h
  96.     mov    a,m
  97.     sta    minutes
  98.     inx    h
  99.     mov    a,m
  100.     sta    minutes+1
  101.     inx    h
  102.     mov    a,m
  103.     sta    seconds
  104.     inx    h
  105.     mov    a,m
  106.     sta    seconds+1
  107. ;
  108. ; test the date, and convert it to four year calendar format
  109. ;
  110.     lda    month    ; get high byte of the month
  111.     cpi    '1'    ; in the range of january to september?
  112.     jnz    jansept ; yes
  113.     lda    month+1
  114.     cpi    '0'
  115.     lxi    d,oct    ; October?
  116.     jz    mmonth    ; print, if so
  117.     cpi    '1'    ; november?
  118.     lxi    d,nov
  119.     jz    mmonth    ; print, if so
  120.     lxi    d,dec    ; december.
  121.     jmp    mmonth    ; print it...
  122. ;
  123. jansept:
  124.     lda    month+1    ; it's january to september
  125.     cpi    '1'    ; january?
  126.     lxi    d,jan
  127.     jz    mmonth    ; print, if so
  128.     cpi    '2'    ; february?
  129.     lxi    d,feb
  130.     jz    mmonth    ; print, if so
  131.     cpi    '3'    ; march?
  132.     lxi    d,mar
  133.     jz    mmonth    ; print, if so
  134.     cpi    '4'    ; april?
  135.     lxi    d,apr
  136.     jz    mmonth    ; print, if so
  137.     cpi    '5'    ; may?
  138.     lxi    d,may
  139.     jz    mmonth    ; print, if so
  140.     cpi    '6'    ; june?
  141.     lxi    d,jun
  142.     jz    mmonth    ; print month
  143.     cpi    '7'    ; july?
  144.     lxi    d,jul
  145.     jz    mmonth    ; print, if so
  146.     cpi    '8'    ; august?
  147.     lxi    d,aug
  148.     jz    mmonth    ; print, if so
  149.     lxi    d,sep    ; it's september
  150. mmonth:    mvi    b,4    ; four characters to move
  151.     lxi    h,fakem    ; place to move real month
  152. movem:    ldax    d    ; get the character to move
  153.     mov    m,a    ; move it
  154.     inx    h    ; bump both pointers
  155.     inx    d
  156.     dcr    b    ; de-bump the count left to move..
  157.     jnz    movem    ; loop 'till all characters moved
  158.     lxi    h,overlay        ; point to overlay area
  159.     lxi    d,fakem        ; point to stuff to be moved
  160.     mvi    b,end$move-start$move    ; how much to move...
  161. move1:    ldax    d    ; get stuff to move
  162.     mov    m,a    ; move it...
  163.     inx    h    ; bump both pointers
  164.     inx    d
  165.     dcr    b    ; de-bump the move counter
  166.     jnz    move1    ; loop 'till it's all moved
  167. done:    jmp    mac    ; now jump into MAC...
  168.  
  169. rtime:
  170.     lxi    h,time        ;Address of time save area
  171.     lxi    d,atable    ;Address of digit table
  172.     mvi    b,timlen/2    ;Number of loops to do
  173. tloop:
  174.     call    rone        ;get digit value
  175.     ani    0fh        ;mask of high nibble
  176.     adi    '0'
  177.     mov    m,a
  178.     inx    h
  179.     call    rone
  180.     ani    0fh
  181.     adi    '0'
  182.     mov    m,a        ;save into table
  183.     inx    h        ;point to next digit
  184.     dcr    b        ;adjust loop count
  185.     jnz    tloop
  186.     ret
  187.  
  188. rone:
  189.     ldax    d        ;Get the digit address
  190.     inx    d        ;Point to next address
  191.     out    gbclkc        ;Output the digit address
  192.     cpi    5+clkread    ;Check for hours 10 digit
  193.     in    gbclkd        ;Get the digit
  194.     rnz            ;If not the hours ten digit
  195.     sui    8        ;Kill the 24 hour bit
  196.     ret
  197. ;
  198. ATABLE:
  199.     DB    8+clkread    ;digit address table
  200.     DB    7+clkread
  201.     DB    10+clkread
  202.     DB    9+clkread
  203.     DB    12+clkread
  204.     DB    11+clkread
  205.     DB    5+clkread
  206.     DB    4+clkread
  207.     DB    3+clkread
  208.     DB    2+clkread
  209.     DB    1+clkread
  210.     DB    0+clkread
  211. ;
  212. ; message buffers
  213. ;
  214.  
  215. time    db    0,0,0,0,0,0,0,0,0,0,0,0
  216.  
  217. start$move    equ    $    ; start moving from here
  218. fakem:    ds    2    ; storage for faked-out month,
  219.             ; which will overlay the next four bytes
  220. month:    ds    2    ; storage for the real month and date
  221. day:    ds    2
  222.     db    ', 19'
  223. year:    db    '82 '    ; the year...
  224. hour:    db    'xx:'    ; the hour...
  225. minutes:db    'xx:'    ; the minute...
  226. seconds:db    'xx'    ; the second...
  227.     db    0dh    ; string delimeter
  228. end$move    equ    $    ; end of move
  229.  
  230. errmsg:    db    cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$'
  231.  
  232. jan:    db    'Jan '
  233. feb:    db    'Feb '
  234. mar:    db    'Mar '
  235. apr:    db    'Apr '
  236. may:    db    'May '
  237. jun:    db    'Jun '
  238. jul:    db    'Jul '
  239. Aug:    db    'Aug '
  240. sep:    db    'Sep '
  241. oct:    db    'Oct '
  242. nov:    db    'Nov '
  243. dec:    db    'Dec '
  244.  
  245.     end
  246.  
  247.