home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / hd64180a.lbr / CLOCK.AZM / CLOCK.ASM
Encoding:
Assembly Source File  |  1991-08-04  |  2.4 KB  |  184 lines

  1. ;
  2. ; This is an interrupt driven clock routine that
  3. ; uses an interrupt to increment the hour, minute and
  4. ; seconds registers in a real time clock.
  5. ;
  6.     maclib    z80
  7.     maclib    exec
  8. ;
  9. ;
  10. cr    equ    0dh
  11. lf    equ    0ah
  12. esc    equ    01bh
  13. ;
  14.     mvi    c,inln$chn    ; Inline text print
  15.     rst    1
  16.     db    cr,lf,'Real time clock. Interrupt Serviced'
  17.     db    cr,lf,'    By Richard Holmes  10/01/1988'
  18.     db    cr,lf
  19.     db    0
  20. ;
  21.     mvi    a,0ffh        ; An impossible time to compae to
  22.     sta    old$sec
  23.     xra    a
  24.     sta    bel$flg
  25. ;
  26. ;
  27. ;
  28. time:
  29.     mvi    c,wdog
  30.     rst    1
  31.     mvi    c,ist$chn
  32.     rst    1
  33.     jz    time1
  34.     mvi    c,inp$chn    ; Get the character
  35.     rst    1
  36.     cpi    esc
  37.     jz    quit        ; Exit if an escape
  38. ;
  39.     mvi    c,caps
  40.     rst    1        ; Capitalize the accumulator
  41.     cpi    'S'
  42.     jnz    time1
  43.     cpi    'B'
  44.     jmp    toggle$Bell
  45. ;
  46.     mvi    c,inln$chn
  47.     rst    1
  48.     db    cr,lf
  49.     db    cr,lf
  50.     db    'Enter Hour : ',0
  51. ;
  52.     mvi    c,idhl$chn    ; Input decimal HL
  53.     rst    1
  54.     mov    a,l
  55.     sta    hrs
  56. ;
  57.     mvi    c,inln$chn
  58.     rst    1
  59.     db    cr,lf
  60.     db    'Enter Mins : ',0
  61. ;
  62.     mvi    c,idhl$chn    ; Input decimal HL
  63.     rst    1
  64.     mov    a,l
  65.     sta    min
  66. ;
  67.     mvi    c,inln$chn
  68.     rst    1
  69.     db    cr,lf
  70.     db    'Enter Secs : ',0
  71. ;
  72.     mvi    c,idhl$chn    ; Input decimal HL
  73.     rst    1
  74.     mov    a,l
  75.     sta    sec
  76. ;
  77.     lxi    d,hrs
  78.     mvi    c,put$clk
  79.     rst    1
  80. ;
  81. ;
  82. time$1:
  83.     lxi    d,hrs        ;-> base of ram to be loaded
  84.     mvi    c,get$clk    ;   read clock to ram function
  85.     rst    1
  86.     lda    old$sec        ; Compare to previous second
  87.     mov    e,a
  88.     lda    sec
  89.     cmp    e
  90.     jz    time
  91. ;
  92.     sta    old$sec
  93. ;
  94. ; Print the time now.
  95.     mvi    a,6        ; LCD
  96.     mvi    c,sel$chn
  97.     rst    1
  98. ;
  99.     mvi    c,xyin$chn    ; Print the time message
  100.     rst    1
  101.     db    20,00,'Time : ',0
  102. ;
  103.     lda    hrs
  104.     mvi    c,pdac$chn
  105.     rst    1
  106.     mvi    a,':'
  107.     mvi    c,out$chn
  108.     rst    1
  109. ;
  110.     lda    min
  111.     mvi    c,pdac$chn
  112.     rst    1
  113.     mvi    a,':'
  114.     mvi    c,out$chn
  115.     rst    1
  116. ;
  117.     lda    sec
  118.     mvi    c,pdac$chn
  119.     rst    1
  120. ;
  121.     mvi    a,1
  122.     mvi    c,sel$chn
  123.     rst    1
  124. ;
  125. ; Decide if a peep of the bell
  126. ;
  127.     lda    bel$flg
  128.     ora    a
  129.     jz    time            ; Bel flg = 0 for no beeps
  130. ;
  131.     lda    sec
  132.     cpi    58
  133.     jz    peep20
  134.     cpi    59
  135.     jz    peep20
  136.     cpi    00        ; On zero, a large peep
  137.     jnz    time
  138. ;
  139.     mvi    c,set$bel
  140.     rst    1
  141. ;
  142.     lxi    d,150
  143.     mvi    c,delay
  144.     rst    1
  145.     mvi    c,clr$bel
  146.     rst    1
  147.     jmp    time
  148. ;
  149. peep20:
  150.     mvi    c,set$bel
  151.     rst    1
  152.     lxi    d,50
  153.     mvi    c,delay
  154.     rst    1
  155.     mvi    c,clr$bel
  156.     rst    1
  157.     jmp    time
  158. ;
  159. quit:
  160.     mvi    a,1
  161.     mvi    c,sel$chn
  162.     rst    1
  163.     jmp    3
  164. ;
  165. toggle$bell:
  166.     lda    bel$flg
  167.     xri    1
  168.     sta    bel$flg
  169.     jmp    time
  170.  
  171.     dseg
  172. ;
  173. bel$flg    ds    1
  174. old$sec    ds    1
  175. ;
  176. hrs    ds    1
  177. min    ds    1
  178. sec    ds    1
  179. ;
  180. ;
  181.     end
  182. ;
  183. ;
  184.