; ; This is an interrupt driven clock routine that ; uses an interrupt to increment the hour, minute and ; seconds registers in a real time clock. ; maclib z80 maclib exec ; ; cr equ 0dh lf equ 0ah esc equ 01bh ; mvi c,inln$chn ; Inline text print rst 1 db cr,lf,'Real time clock. Interrupt Serviced' db cr,lf,' By Richard Holmes 10/01/1988' db cr,lf db 0 ; mvi a,0ffh ; An impossible time to compae to sta old$sec xra a sta bel$flg ; ; ; time: mvi c,wdog rst 1 mvi c,ist$chn rst 1 jz time1 mvi c,inp$chn ; Get the character rst 1 cpi esc jz quit ; Exit if an escape ; mvi c,caps rst 1 ; Capitalize the accumulator cpi 'S' jnz time1 cpi 'B' jmp toggle$Bell ; mvi c,inln$chn rst 1 db cr,lf db cr,lf db 'Enter Hour : ',0 ; mvi c,idhl$chn ; Input decimal HL rst 1 mov a,l sta hrs ; mvi c,inln$chn rst 1 db cr,lf db 'Enter Mins : ',0 ; mvi c,idhl$chn ; Input decimal HL rst 1 mov a,l sta min ; mvi c,inln$chn rst 1 db cr,lf db 'Enter Secs : ',0 ; mvi c,idhl$chn ; Input decimal HL rst 1 mov a,l sta sec ; lxi d,hrs mvi c,put$clk rst 1 ; ; time$1: lxi d,hrs ;-> base of ram to be loaded mvi c,get$clk ; read clock to ram function rst 1 lda old$sec ; Compare to previous second mov e,a lda sec cmp e jz time ; sta old$sec ; ; Print the time now. mvi a,6 ; LCD mvi c,sel$chn rst 1 ; mvi c,xyin$chn ; Print the time message rst 1 db 20,00,'Time : ',0 ; lda hrs mvi c,pdac$chn rst 1 mvi a,':' mvi c,out$chn rst 1 ; lda min mvi c,pdac$chn rst 1 mvi a,':' mvi c,out$chn rst 1 ; lda sec mvi c,pdac$chn rst 1 ; mvi a,1 mvi c,sel$chn rst 1 ; ; Decide if a peep of the bell ; lda bel$flg ora a jz time ; Bel flg = 0 for no beeps ; lda sec cpi 58 jz peep20 cpi 59 jz peep20 cpi 00 ; On zero, a large peep jnz time ; mvi c,set$bel rst 1 ; lxi d,150 mvi c,delay rst 1 mvi c,clr$bel rst 1 jmp time ; peep20: mvi c,set$bel rst 1 lxi d,50 mvi c,delay rst 1 mvi c,clr$bel rst 1 jmp time ; quit: mvi a,1 mvi c,sel$chn rst 1 jmp 3 ; toggle$bell: lda bel$flg xri 1 sta bel$flg jmp time dseg ; bel$flg ds 1 old$sec ds 1 ; hrs ds 1 min ds 1 sec ds 1 ; ; end ; ;