; ; PROGRAM: Time generation from the QT board - ; This routine is to be added to any COM program ; to supply time and date information for that program. ; ; PROGRAMMER: G.L. Hewett W6BSK ; REVISION HISTORY: Rev 01 Dated 84/12/07 First version ; true equ -1 ; define true false equ not true; define false qt equ true ; define QT Computer Systems Inc. board ct equ false ; define Compu-Time board fnamå  eqõ  nnnnè »  Puô thå originaì JMÐ valuå  herå  tï  ; return to the original .COM program- ; normally it will be the first three ;bytes of the unmodified .COM file. bdos equ 5 pbuf equ 9 cr equ 0dh ; ASCII carriage return lf equ 0ah ; ASCII line feed overlay equ nnnnh ; overlay area in COM file used with ; this routine. Time and date stored ; here. if qt clock equ 080h ; real time clock base port address endif if ct clock equ 024h ; real time clock base port address endif orç  010°  ;Thå .COÍ prograí musô bå  modifieä  tï  ;allow a JMP in the first three bytes- jmp date ; jump to set date and time org nnnnh ; Change this ORG to put the time program ; at the END of the .COM program. date: lxi h,month ; point to month mvi d,8 ; select month tens digit call digit ; read and store high digit rlc ! rlc ! rlc ! rlc ; shift to high order hex digit mov b,a ; save in b reg. Š call digit ; read and store month units digit ora b ; or-in the units and tens digit mov b,a ; save the month in b reg. call digit ; read and store the day tens digit rlc ! rlc ! rlc ! rlc ; shift to high order hex digit mov c,a ; save in c reg. call digit ; read and store day units digit ora c ; or-in the units and tens digit mov c,a ; save the day in c reg. ; ; test the date, and convert it to four year calendar format ; cpi 031h ; 31st day? mov a,b ; get the month, for next test jnz m2 ; if not the 31st, test for february cpi 2 ; test for months < 31 days jz fix ; ...and fix if needed cpi 4 jz fix cpi 6 jz fix cpi 9 jz fix cpi 011h jz fix m2: cpi 2 ; test for february jnz time ; if not february, then read time mov a,c ; get day for test cpi 029h ; is this the 29th day? ; ; insert two NOP's over previous instruction, if this is a leap year ; jz fix ; fix date... cpi 030h ; 30th day? jnz time ; if not the 29th or 30th, go read time fix: mvi a,41 ; select month units and fast set call rdigit ; read the month units digit mov b,a ; save in b reg. floop: in clock ; read the months unit digit cmp b ; test for digit changed jz floop ; wait until month is bumped (stable data) time: lxi h,hour ; point to hour mvi d,0 ; select hour tens digit call ddigit ; read hour tens and units inx h ; step over ":" call ddigit ; read minutes tens and units inx h ; step over ":" call ddigit ; read second tens and units lda month ; get high byte of the month cpi ' ' ; in the range of january to september? jz jansept lda month+1 ; must be october to december... Š cpi '0' ; october? lxi d,oct jz mmonth ; move, if so cpi '1' ; november? lxi d,nov jz mmonth ; move, if so lxi d,dec ; december! jmp mmonth ; move it... jansept:lda month+1 ; it's january to september cpi '1' ; january? lxi d,jan jz mmonth ; move, if so cpi '2' ; february? lxi d,feb jz mmonth ; move, if so cpi '3' ; march? lxi d,mar jz mmonth ; move, if so cpi '4' ; april? lxi d,apr jz mmonth ; move, if so cpi '5' ; may? lxi d,may jz mmonth ; move, if so cpi '6' ; june? lxi d,jun jz mmonth ; move month cpi '7' ; july? lxi d,jul jz mmonth ; move, if so cpi '8' ; august? lxi d,aug jz mmonth ; move, if so lxi d,sep ; it's september mmonth: mvi b,4 ; four characters to move lxi h,fakem ; place to move real month movem: ldax d ; get the character to move mov m,a ; move it inx h ; bump both pointers inx d dcr b ; de-bump the count left to move.. jnz movem ; loop 'till all characters moved lxi h,overlay ; point to overlay area lxi d,fakem ; point to stuff to be moved mvi b,end$move-start$move ; how much to move... move1: ldax d ; get stuff to move mov m,a ; move it... inx h ; bump both pointers inx d dcr b ; de-bump the move counter jnz move1 ; loop 'till it's all moved done: jmp fname ; Return to original .COM file ddigit: call digit ; read and store two digits digit: mov a,d ; move digit select code to a reg. Š call rdigit ; read a clock digit cpi 0ffh ; test for board present jz nobrd ; go print error message ori 030h ; convert digit to ASCII cpi 03fh ; test for blanked leading zero jnz store ; go store digit, if not blanked mvi a,020h ; convert to a blank store: mov m,a ; store the digit in message buffer inx h ; bump message pointer buffer location inr d ; step to next digit ani 00fh ; mask off high ASCII nibble ret ; return with digit in a reg. nobrd: pop h ; adjust the stack lxi d,errmsg; point to the error message mvi c,pbuf ; print buffer function call bdos ; let CP/M do the work jmp done ; print error message, and exit to CP/M rdigit: out clock ; select digit mvi a,0 ; ...some delay time for settling dloop: dcr a jnz dloop in clock ; read a digit ret ; return with digit in a reg. ; ; message buffers ; start$move equ $ ; start moving from here fakem: ds 2 ; storage for faked-out month, ; which will overlay the next four bytes month: ds 4 ; storage for the real month and date db ',1984 '; the year... hour: db 'xx:' ; the hour... db 'xx:' ; the minute... db 'xx' ; the second... db 0dh ; string delimeter end$move equ $ ; end of move errmsg: db cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$' jan: db 'Jan ' feb: db 'Feb ' mar: db 'Mar ' apr: db 'Apr ' may: db 'May ' jun: db 'Jun ' jul: db 'Jul ' Aug: db 'Aug ' sep: db 'Sep ' oct: db 'Oct ' nov: db 'Nov ' dec: db 'Dec ' Š end