title 'TIMEPROG as of 21 March 1983' ; ; Modified for CROMASMB.COM ; ; ; This program is a universal patch for any program which runs ; under CP/M Version 2.2 ONLY. It will give a real-time display »  oæ  thå  timå anä datå eacè timå thå patcheä prograí  ió  run® ; Patch it in as follows: ; ; A>DDT fname.COM ; NEXT PC ; nnnn 0100 ; -ITIMEPROG.HEX ; -R ; NEXT PC ; NNNN 0000 ; -^C ; A>SAVE NNH fname.COM ; ; Now you have a new "fname" command file called FNAME.COM, ; and it will display the "real time" on every execution... ; ; Best regards, ; ; Kelly Smith, MP/M-Net (tm) Sysop ; (805) 527-9321 (Modem, 300 Baud) ; ; ; ; TIMEPROG.ASM (revised 12/29/82) by W6BSK ; ; Revised from the May 1980, INTERFACE AGE MAGAZINE ; ; For Compu-Time T-102 TIME/DATE board (With MM 5375 AC) ; ; or, ; ; QT Computer Systems Inc. "Clock/Calendar +" board ; ; bdos equ 5 pbuf equ 9 fname equ 0103h ;This address is the entry point for the ;program fname.COM. It must be adjusted! cr equ 0dh ; ASCII carriage return lf equ 0ah ; ASCII line feed true equ -1 ; define true false equ not true; define false qt equ true ; define QT Computer Systems Clock/Calendar + board ct equ false ; Compu-Time Time/Date board if qt Š clock equ 080h ; real time clock base port address endif if ct clock equ 024h ; real time clock base port address endif org 0100h jmp date orç  3100è  »  nnnnè  ió thå enä oæ  thå  fname.COÍ ;address+1 -ie, TIMEPROG is located imm- ;ediately after the fname.COM program. date: push psw ! push b ! push d ! push h 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 lxi d,pdate ; point to date and time message mvi c,pbuf ; print buffer function call bdos ; let CP/M do the work... 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 pmonth ; print, if so cpi '1' ; november? lxi d,nov jz pmonth ; print, if so lxi d,dec ; december. jmp pmonth ; print it... jansept:lda month+1 ; it's january to september cpi '1' ; january? lxi d,jan jz pmonth ; print, if so cpi '2' ; february? lxi d,feb jz pmonth ; print, if so cpi '3' ; march? lxi d,mar jz pmonth ; print, if so cpi '4' ; april? lxi d,apr jz pmonth ; print, if so cpi '5' ; may? lxi d,may jz pmonth ; print, if so cpi '6' ; june? lxi d,jun Š jz pmonth ; print month cpi '7' ; july? lxi d,jul jz pmonth ; print, if so cpi '8' ; august? lxi d,aug jz pmonth ; print, if so lxi d,sep ; it's september pmonth: mvi c,pbuf ; print buffer function call bdos ; let CP/M do the work... done: lxi d,day ; get the day mvi c,pbuf ; print buffer function call bdos ; let CP/M do the work... pop h ! pop d ! pop b ! pop psw lxi sp,3dcdh ;correct for jump at 100h jmp fname ;now jump into the program which has been ;patched. 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 jmp done ; print error message, and exit to CP/M rdigit: out clock ; select digit mvi a,0 ; ...some delay time for settling dcr a jnz $-1 dcr a jnz $-1 in clock ; read a digit ret ; return with digit in a reg. ; ; message buffers ; pdate: db cr,lf,'Date: $' month: ds 2 ; the month day: db 'xx, ' ; the day... db '1983' ; the year... db ' Time: ' hour: db 'xx:' ; the hour... Š db 'xx:' ; the minute... db 'xx' ; the second... db cr,lf,'$' ; string delimeter errmsg: db cr,lf,'The Clock Board is NOT INSTALLED!',cr,lf,'$' jan: db 'January $' feb: db 'February $' mar: db 'March $' apr: db 'April $' may: db 'May $' jun: db 'June $' jul: db 'July $' Aug: db 'August $' sep: db 'September $' oct: db 'October $' nov: db 'November $' dec: db 'December $' end