; TIMERC.ASM ; for PCPICPM ; constant update display the time ; TRUE EQU 0FFH FALSE EQU 0 acr equ 0dh ;A Carrage Return alf equ 0ah ;A Line Feed aesc equ 1bh ;An ESCAPE clrscrn equ 0ch ;Clear screen (Apple //e) ; SLOT equ 2 ;VersaCard Slot # slot1 equ slot*16+80h ctrlp equ 0C002h+slot1 dtap equ 0C003h+slot1 ; CHOUR: EQU 043H ;some BIOS clocks keep time CMIN: EQU 044H ;here anyway. LHOUR: EQU 050H ;set by STARTUP.COM on LMIN: EQU 051H ;system initailzation ; sec01 equ 10h sec10 equ 11h min01 equ 12h min10 equ 13h hrs01 equ 14h hrs10 equ 15h day equ 16h ; 0=Sunday 6=Saturday dat01 equ 17h dat10 equ 18h mon01 equ 19h mon10 equ 1Ah yer01 equ 1Bh yer10 equ 1Ch ; ; BASE - Base Address of user's CP/M system (normally 0 for DR version) BASE EQU 0 ;BASE OF CP/M SYSTEM (SET FOR STANDARD CP/M) BDOS EQU BASE+0005H ;BDOS FUNCTION CALL ENTRY PT keyhit equ 0Bh ;BDOS test console for key ; RDBYTE EQU 0FFE0H ;READ A BYTE FROM APPLE (A = BYTE) WRBYTE EQU 0FFE3H ;WRITE A BYTE TO APPLE (C = BYTE) RDWORD EQU 0FFE6H ;READ 2 BYTES FROM APPLE (DE = BYTES) WRWORD EQU 0FFE9H ;WRITE 2 BYTES TO APPLE (DE = BYTES) RDNBYTS EQU 0FFECH ;READ N BYTES (DE = COUNT, HL = BUFFER) WRNBYTS EQU 0FFEFH ;WRITE N BYTES (DE = COUNT, HL = BUFFER) ; PEEK1BYTE EQU 6 ; COMMAND TO PEEK 1 BYTE IN THE APPLE POKE1BYTE EQU 7 ; COMMAND TO POKE 1 BYTE IN THE APPLE ; ********************************************************************* org 0100h ********************************************************************* jmp start ; date: db 'Date - ' db 0 ; time: db 'Time - ' db 0 ; ; hrs: db 0 min: db 0 ten: db 0Ah ; start: ; mvi a,alf call conout mvi a,alf call conout start1: mvi a,acr call conout ; ; print three spaces ; call p3spaces ; ; print the date ; lxi h,date call PRINT ; ; month tens digit ; mvi a,mon10 call fetch ani 0f1h call storeit ; ; month units digit ; mvi a,mon01 call fetch call storeit ; ; seperator / ; mvi a,'/' call conout ; ; day tens digit ; mvi a,dat10 call fetch ani 0f3h call storeit ; ; day units digit ; mvi a,dat01 call fetch call storeit ; ; seperator / ; mvi a,'/' call conout ; ; year tens digit ; mvi a,yer10 call fetch call storeit ; ; year units digit ; mvi a,yer01 call fetch call storeit ; ; print three spaces ; call p3spaces ; ; print the time ; lxi h,time call PRINT ; ; hour tens digit ; mvi a,hrs10 call fetch ani 0f3h call storeit ; setup timer routine mvi a,hrs10 call fetch ani 003h mov b,a ;move #of tens to reg-B mvi a,0 sta hrs ;zero to start mov a,b jz endit mult0: mvi c,0Ah ;put a ten in C lda hrs ;put current hrs in A add C ;add 10 sta hrs ;save it in hrs: dcr b jnz mult0 endit: ; ; hour units digit ; mvi a,hrs01 call fetch call storeit ; setup timer routine mvi a,hrs01 call fetch ani 07h mov b,a lda hrs mov c,a mov a,b add c sta CHOUR ; sta LHOUR ; ; seperator : ; mvi a,':' call conout ; ; minute tens digit ; mvi a,min10 call fetch ani 0f7h call storeit ; setup timer routine mvi a,min10 call fetch ani 007h mov b,a ;move #of tens to reg-B mvi a,0 sta min ;zero to start mov a,b jz endit1 mvi a,0 mult1: mvi c,0Ah ;put a ten in C lda min ;put current min in A add C ;add 10 sta min ;save it in min: dcr b jnz mult1 endit1: ; ; minute units digit ; mvi a,min01 call fetch call storeit ; setup timer routine mvi a,min01 call fetch ani 0fh mov b,a lda min mov c,a mov a,b add c sta CMIN ; sta LMIN ; ; seperator : ; mvi a,':' call conout ; ; seconds tens digit ; mvi a,sec10 call fetch ani 0f7h call storeit ; ; seconds units digit ; mvi a,sec01 call fetch call storeit ; ; print three spaces ; call p3spaces ; ; ; ;*********************************************************************** ; ; TIME0: CALCULATE USER'S ELAPSED TIME ; ;*********************************************************************** ; ; Calculate time on system and inform user. ; ; TIME0: NOP ;the SYSOP must add the code here neces- NOP ; sary to read his clock and store NOP ; binary values of current hours (0-23) NOP ; in CHOUR and minutes (0-59) in CMIN LXI H,LHOUR ;point to log-on hour LDA CHOUR ;current hour CMP M ;equal? JNZ TIME1 ;no LDA LMIN ;log on minutes MOV D,A LDA CMIN ;current minutes SUB D STA TON ;store total time on JMP TIME2 ; TIME1: LDA LMIN ;log on min MOV D,A MVI A,03CH ;60 min into A SUB D LXI H,CMIN ;point at current min ADD M ;add current minutes STA TON ; TIME2: ; TIME3: LXI H,MSG1+015H ;point at message insert bytes LDA TON ;convert to ASCII MVI B,-1 ; TIME4: INR B SUI 0AH ;subtract 10 JNC TIME4 ;until done ADI 0AH ORI '0' ;make ASCII MOV M,A DCX H MVI A,'0' ADD B MOV M,A LXI H,MSG1 CALL PRINT ; ; mvi c,keyhit call BDOS ;test the console ora a ;was a key hit jz wait ;jump if not ; mvi a,alf call conout mvi a,alf call conout mvi a,acr call conout ; ret ; ; ; MSG1: DB ' ' DB 'Time on system is 00 minutes' DB 0 ; ; TON: DB 0 ; ;----------------------------------------------------------------------- ; ; End of program code ; ;----------------------------------------------------------------------- ; ; ; ; S U B R O U T I N E S: ; ;PEEK AT 1 BYTE IN THE APPLE ;ENTRY: DE = ADDRESS ;EXIT: A = DATA PEEK: PUSH B MVI C,PEEK1BYTE CALL WRBYTE CALL WRWORD CALL RDBYTE POP B RET ;POKE 1 BYTE INTO THE APPLE ;ENTRY: DE = ADDRESS ;EXIT: A = DATA POKE: PUSH B MOV B,A MVI C,POKE1BYTE CALL WRBYTE CALL WRWORD MOV C,B CALL WRBYTE POP B RET ; ; fetch: lxi d,ctrlp call poke lxi d,dtap call peek sui 10h ret ; storeit: call conout ret ; cout: CONOUT: MVI C,2 OUTPUT: MOV E,A CALL BDOS RET ; ; print three spaces ; p3spaces: mvi a,' ' call conout mvi a,' ' call conout mvi a,' ' call conout ret ; PRINT: mov a,m ;get a character of the message inx h ;Bump text pointer ana a ;Test for End jz done ;Exit if done push h ;Save pointer to text mov c,a ;Output char in C call cout ;output the character pop h ;restore the pointer jmp PRINT ;Continue untill null reached ; done: RET ; wait: mvi b,006h wait1: mvi c,0FFh wait2: mvi d,0FFh wait3: dcr d jnz wait3 dcr c jnz wait2 dcr b jnz wait1 jmp start1 ;