page 64 title 'Simple terminal emulator - TIMER part' maclib term ; -->> File : TIMER.ASM ; ========= ; Copyright (c) Werner Cirsovius ; Hohe Weide 44 ; D-2000 Hamburg 20 ; Federal Republic of Germany ; Tel.: 040/4223247 ; Version 1.0, January 1988 ; ===== Externals ===== ; From LIB BASELIB extrn strbi0 ; From module XMODEM extrn send,receiv ; To TERMINAL public concti,clock,clkon,@cnlen ; ========== THE REAL TIME CLOCK ROUTINES ========== ; (NOTE : These routines are absolutely UNNECESSARY ; .. but good for filling the screen) clock: ; Read time into parameter block ; ENTRY : Reg pair DE points to parameter block ; holding one byte each for hour,min,sec ; EXIT : Parameter block filled ; push d ; Save entry lxi d,tod ; Get system parameter block mvi c,getdat call bdos ; Do it thru BDOS sta tod+4 ; Save seconds pop h ; Get source dcx h ; Fix it lxi d,tod+1 mvi b,3 @clklp: inx d inx h ldax d ; Get BCD call bcd$dec ; Convert to decimal mov m,a ; And store dcr b jnz @clklp ret ; bcd$dec:; Convert BCD to decimal ; ENTRY : Accu holds BCD number ; EXIT : Accu holds decimal number ; push b mov b,a ; Save original value ani 0f0h ; Get high part rrc rrc rrc mov c,a add a ; Now get tens add a add c mov c,a mov a,b ani 00fh ; .. same for lo part add c pop b ret ; dseg tod ds 5 cseg ; time: ; Convert time to string ; ENTRY : Reg pair DE points to parameter block ; Reg pair HL points to ASCII buffer ; which must be at least 9 bytes long ; EXIT : ASCII buffer filled with time value ; mvi b,':' ldax d call @sta1 ; Save hour as ASCII ldax d call @sta ; .. and minutes mvi b,0 ldax d call @sta ; .. and seconds ret @sta: cpi 10 ; Test range jnc @sta1 mvi m,'0' ; Fill with zero of units only inx h @sta1: inx d mvi c,-1 @staco: inr c sui 10 ; Convert jnc @staco push psw mov a,c ora a jz @stapo adi '0' mov m,a ; Save tens inx h @stapo: pop psw adi '0'+10 mov m,a ; .. and units inx h mov m,b ; Save delimiter inx h ret ; calcon: ; Calculate time differences ; ENTRY : Reg pair DE points to parameter block ; EXIT : Parameter block filled with values ; push d lxi d,clkoff call clock ; Get time pop h mvi b,0 ; Clear minutes mvi c,0 ; .. and hours lda clkon+2 mov d,a lda clkoff+2 sub d ; Calculate seconds jp @calcm dcr b ; Set minutes to -1 adi 60 ; Fix seconds @calcm: mov d,a lda clkon+1 mov e,a lda clkoff+1; Calculate minutes add b sub e jp @calch dcr c ; Set hours to -1 adi 60 ; Fix minutes @calch: mov b,a lda clkon mov e,a lda clkoff ; Calculate hours add c sub e jp @calca adi 24 ; Fix hours @calca: mov m,a ; Now set into user area inx h mov m,b inx h mov m,d ret ; concti: ; Tell the connect time ; lxi d,clkmy call calcon ; Get connection time lxi d,clkmy lxi h,@conas call time ; Convert the time lxi h,@conas lxi d,@cncms call strbi0 ; Tell the connection time ret ; dseg clkmy ds 3 clkon ds 3 clkoff ds 3 @cncms if german db 'L{nge der Verbindung: ' else db 'Connection time: ' endif;german @conas ds 9 @cnln equ $-@cncms @cnlen db @cnln ; ========== END OF REAL TIME CLOCK ROUTINES ========== end