; TOS.MAC EMX remote CP/M system time utility ; ; This routine must be linked with the EMXSUBS.REL file ; ; ; v1.22 - 07/30/84 Updated to be in sync with source code release ; version 3.00 of EMX ; - Simon Ewins ; ; v1.00 - 06/10/84 The original, written in Z80 code for assembly ; with M80 and L80, for use with EMSBYE, and the ; EMX message system, developed by Simon Ewins of ; Toronto, Ontario., Canada ; ; Written by: Mark Howard - Sysop ; CNY Technical RCPM ; Syracuse, NY (315) 437-4890 ; .Z80 ASEG ORG 100H ; JP START ; VER:: DB 1 VERR:: DB 22 ; INCLUDE EMXHDR.MAC INCLUDE GETTIM.MAC ; START:: LD SP,STACK ; Use our own stack ; ; Make sure BYE is active ; LD A,(REENTR) ; Get re-entry byte OR A ; 1=signed on CALL Z,LOCAL ; Must be local ; ; Determine the LOGON, LOGOFF and elapsed time ; LD A,(LOCFLG) ; Are we local? OR A JR NZ,LOC1 LD HL,LOGSTR ; Hl -> logon time LD DE,ONTIM ; Point to where to put it LD BC,8 ; No. of bytes LDIR ; Move em ; LOC1:: CALL GETTIM ; Get the current time LD HL,TIME ; Point to the time string LD DE,CURTIM ; Where to put it LD BC,8 LDIR ; Move it LD HL,DATE ; Get the date LD DE,CURDAT LD BC,8 LDIR ; Move it LD A,(LOCFLG) ; Check status OR A CALL Z,CALCTIM ; Calculate the elapsed time ; ; Print the results ; CALL PRINT DB CR,LF,'Today is ......... ' ; CURDAT::DB '00/00/00',0 CALL PRINT DB CR,LF,'Current time ..... ' ; CURTIM::DB '00:00:00',0 LD A,(LOCFLG) ; Check one more time OR A JP NZ,WBOOT ; If local, warm boot ; CALL PRINT DB CR,LF,'Logged on at ..... ' ; ONTIM: DB '00:00:00',0 CALL PRINT DB CR,LF,'Connect time ..... ' ; ELPTIM::DB '00:00:00',0 ; WBOOT:: CALL PRINT DB CR,LF,0 JP 0 ; Warm boot ; ; ---------------- local subroutines ------------------- ; ; Calculate the elapsed time - from TIMEDIF.ASM ; CALCTIM:: LD HL,ONTIM+6 ; Point to start time secs CALL GETBIN ; Get binary LD D,A ; Save it LD HL,CURTIM+6 ; Stop time secs CALL GETBIN LD E,0 ; Reset the borrow flag SUB D ; Subtract JR NC,SKBS ; Skip if no borrow DEC E ; Else make e = ff ADD A,60 ; Make mod 60 ; SKBS:: LD HL,ELPTIM+7 ; Point to elapsed time seconds CALL STORA LD HL,ONTIM+3 CALL GETBIN LD D,A LD HL,CURTIM+3 CALL GETBIN INC E ; If not borrow JR NZ,SKBM1 ; Then skip INC D ; Else add borrowed value ; SKBM1:: LD E,0 SUB D JR NC,SKBM2 ; Skip if no borrow DEC E ADD A,60 ; Make mod 60 ; SKBM2:: LD HL,ELPTIM+4 CALL STORA ; Store it ; LD HL,ONTIM CALL GETBIN LD D,A LD HL,CURTIM CALL GETBIN INC E JR NZ,SKBH1 INC D ; SKBH1:: SUB D JR NC,SKBH2 ADD A,24 ; Add 24 hrs ; SKBH2:: LD HL,ELPTIM+1 JR STORA ; GETBIN::LD A,(HL) ; Get tens AND 0FH LD B,A ; Save XOR A LD C,10 ; Set up multiplier ; MUL:; ADD A,C DEC B JR NZ,MUL LD B,A ; Save tens INC HL ; Point to units LD A,(HL) AND 0FH ADD A,B ; Add tens RET ; Return value in ac ; STORA:; LD B,-1 ; TLP:; INC B SUB 10 JR NC,TLP ADD A,10 OR 30H LD (HL),A DEC HL LD A,30H ADD A,B LD (HL),A RET ; LOCAL:: LD A,0FFH LD (LOCFLG),A ; Indicate that we are local RET ; ; Data ; LOCFLG::DB 0 ; If nz, then was local ; DS 128 ; Stack area ; STACK EQU $ ; END