/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT #11
/
/ COPYRIGHT 1970,1971,1972,1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ MCR FUNCTION -- ENTER TIME & DATE     4 APR 73    H. HREJCI
/						M. HEBENSTREIT
/
/ TASK NAME "...ETI" TO ENTER TIME AND DATE.
/
/ THE FIRST LINE OF COMMAND INPUT FOR ANY MCR FUNCTION IS 
/ READ BY THE RESIDENT MCR TASK ("...MCR").  FOR THE "ENTER TIME"
/ FUNCTION, THE SYNTAX OF THE FIRST LINE IS:
/
/	SYNTAX = "ETI"$<CHARACTER><BREAK CHAR><TIME>
/	         (<BREAK CHAR><DATE>/NUL) (<CR>/<AM>)
/	    <CHARACTER> = <LETTER>/<DIGIT>
/	    <BREAK CHAR> = " "/","
/	    <TIME> = <DV>":"<DV>":"<DV>
/	    <DATE> = <DV>"/"<DV>"/"<DV>
/		<DV> = DECIMAL VALUE
/	    <CR> = CAR RTN
/	    <AM> = ALTMODE
/	$ -- "ANY NUMBER OF, INCLUDING ZERO"
/	NUL -- "THE EMPTY SET"
/
/ THE RESIDENT MCR READS A LINE, FETCHES THE FIRST THREE CHARACTERS
/ TO FORM THE MCR FUNCTION TASK NAME ("...ETI"), FLUSHES CHARACTERS
/ THRU THE FIRST BREAK CHARACTER, REQUESTS "...ETI", AND EXITS.
/
/ THE TASK "...ETI" FETCHES CHARACTERS AND FORMS A TIME AND OPTIONALLY
/ A DATE.  IF THE TIME AND DATE ARE VALID, THEY ARE ENTERED INTO THE
/ RSX SYSTEM.
/
/ IF THE INPUT LINE IS TERMINATED BY A CAR RTN, THE FUNCTION 
/ TASK WILL REQUEST THE RESIDENT MCR ("...MCR") AND EXIT.
/
/ IF THE INPUT LINE IS TERMINATED BY AN ALTMODE, THE FUNCTION 
/ TASK ("...ETI") WILL EXIT WITHOUT REQUESTING THE RESIDENT MCR.
/ A ^C TYPEIN IS NECESSARY TO RE-ESTABLISH MCR DIALOGUE.
 .TITLE *** MCR FUNCTION 'ENTER TIME'
/
CLOF=700004
CLON=700044
/
SSM=160	/SECONDS SINCE MIDNITE
DSR=161	/DAYS RUNNING
HH=165	/HOURS
MM=164	/MINUTES
SS=163	/SECONDS
TT=162	/TICKS
MO=166	/MONTH
DA=167	/DAY
YR=170	/YEAR
MCRRI=171
FAC=174
/
	.EJECT
/
ETI	JMS	FNB	/FETCH HOURS & BREAK CHAR
	JMS	CMP	/ERR IF HOURS OUT OF RANGE (0-23)
	00
	27
	JMP	ERR
	DAC	HHB	/SAVE HOURS
	JMS	CLX	/ERR IF NOT COLON BREAK
/
	JMS	FNB	/FETCH MINUTES & BREAK CHAR
	JMS	CMP	/ERR IF MINUTES OUT OF RANGE (0-59)
	00
	73
	JMP	ERR
	DAC	MMB	/SAVE MINUTES
	JMS	CLX	/ERR IF NOT COLON BREAK
/
	JMS	FNB	/FETCH SECONDS & BREAK CHAR
	JMS	CMP	/ERR IF SECONDS OUT OF RANGE (0-59)
	00
	73
	JMP	ERR
	DAC	SSB	/SAVE SECONDS
/
	LAC	BCHAR	/IF BLANK OR COMMA BREAK, ACCEPT
	SAD	(040)	/DATE, OTHERWISE TEST FOR LINE TERMINATION.
	JMP	ADT
	SAD	(054)
	JMP	ADT
	JMS	TCX	/ERR IF NOT CAR RTN OR ALTMODE BREAK
	JMP	STM	/TO SET TIME
/
ADT	JMS	FNB	/FETCH MONTH & BREAK CHAR
	JMS	CMP	/ERR IF MONTH OUT OF RANGE (1-12)
	01
	14
	JMP	ERR
	DAC	MOB	/SAVE MONTH
	JMS	SLX	/ERR IF NOT SLASH BREAK
/
	JMS	FNB	/FETCH DAY & BREAK CHAR
	DAC	DAB	/SAVE DAY (RANGE CHECK AFTER YEAR IS KNOWN)
	JMS	SLX	/ERR IF NOT SLASH BREAK
	JMS	FNB	/FETCH YEAR & BREAK CHAR (SINCE ONLY A
			/ONE OR TWO DIGIT UNSIGNED NUMBER IS ACCEPTED
			/BY 'FNB', THE RANGE (0-99) MUST BE OKAY.
	DAC	YRB	/SAVE YEAR
	JMS	TCX	/ERR IF NOT CAR RTN OR ALTMODE BREAK
/
	LAC	MOB	/DETERMINE LENGTH OF MONTH TO CHECK
	SAD	(02)	/RANGE OF DAY
	JMP	LRX	/FEB -- TEST FOR LEAP YEAR
	XOR	(LRS 0)
	DAC	.+2
	LAC	(012652)/(MAP OF 31 DAY MONTHS)
	XX		/(LRS ONE BIT PER MONTH NUMBER)
	AND	(01)
	AAC	36
	JMP	SML	/AC CONTAINS A 30 OR 31 (PER MONTH)
/
LRX	LAC	YRB	/LEAP YEAR TEST
	AND	(03)
	SNA!CLA
	AAC	+1
	AAC	35	/AC CONTAINS 28 OR 29 (PER YEAR)
/
SML	DAC	DOM	/SET DAYS-OF-MONTH TO 28,29,30,OR 31
	LAC	DAB	/ERR IF DAY OUT OR RANGE
	JMS	CMP
	01
DOM	XX
	JMP	ERR
/
	LAC	DAB	/SET DATE
	DAC*	(DA)
	LAC	MOB
	DAC*	(MO)
	LAC	YRB
	DAC*	(YR)
/
STM     CLOF		/TURN THE CLOCK OFF
        LAC     HHB	/SET TIME PARAMETERS
	DAC*	(HH)
	LAC	MMB
	DAC*	(MM)
	LAC	SSB
	DAC*	(SS)
	DZM*	(TT)
/
	DZM*	(DSR)	/RESET DAYS RUNNING COUNT
/
	LAC	HHB	/SET SECONDS SINCE MIDNITE
	CLL		/  SSM = SS + 60(MM + 60(HH))
	MUL
	74
	LACQ
	TAD	MMB
	CLL
	MUL
	74
	LACQ
	TAD	SSB
	DAC*	(SSM)
/
	LAW	-1	/SET REAL TIME CLOCK TO OVERFLOW
	DAC*	(07)	/IN ONE TICK.
/
	CLON		/TURN CLOCK ON
/
	LAC	BCHAR	/CAR RTN LINE TERMINATOR?
	SAD	(015)
EXIT	CAL	REQMCR	/YES -- REQUEST "...MCR" & EXIT
	SAD	(175)	/IS IT AN ALTMODE?
	DZM*	(MCRRI)	/YES CLEAR MCR REQUEST INHIBIT FLAG
	CAL	(10)	/NO -- EXIT
/
REQMCR	1	/REQUEST "...MCR" CPB
	0
	.SIXBT	"..."
	.SIXBT	"MCR"
	0
/
ERR	CAL	ERRCPB	/AN ERROR HAS BEEN DETECTED, TYPE
			/TYPE MESSAGE AND EXIT.
	CAL	WFEV	/WAIT FOR TTY TO FINISH
	JMP	EXIT
/
ERRCPB	2700		/CPB TO TYPE MESSAGE
	ETEV
	3
	2
	MES1
/
WFEV	20	/WAIT FOR
	ETEV	/EVENT VARIABLE ADDRESS
/
MES1	2; 0; .ASCII	"ETI-SYNTAX ERR"<15>
ETEV	0
/
HHB	0	/HOUR BUF
MMB	0	/MINUTE BUF
SSB	0	/SECOND BUF
MOB	0	/MONTH BUF
DAB	0	/DAY BUF
YRB	0	/YEAR BUF
BCHAR	0	/BREAK CHAR BUF
/
/ FNB -- FETCH-NUMBER-AND-BREAK-CHARACTER SUBROUTINE
/ THE NUMBER MUST BE A ONE OR TWO DIGIT (DECIMAL) CONSTANT
/ AND IS LEFT IN AC.  THE BREAK CHARACTER IS LEFT IN 'BCHAR'.
/ 'JMP ERR' IF NUMBER IS NOT ONE OR TWO DIGITS LONG.
/
FNB	0
	JMS	FDD	/FETCH DIGIT
	JMP	ERR	/NON DECIMAL CHAR--ERROR
	DAC	B1	/SAVE FIRST DIGIT IN B1
	JMS	FDD	/FETCH DIGIT
	JMP	FNBX	/NON DECIMAL CHAR -- CONSIDER BREAK CHAR
	DAC	B2	/SAVE SECOND DIGIT IN B2
	LAC	B1	/MULTIPLY FIRST DIGIT BY TEN, ADD
	RCL		/SECOND DIGIT, AND SAVE RESULT IN B1.
	RTL
	TAD	B1
	TAD	B1
	TAD	B2
	DAC	B1
	JMS	FDD	/FETCH BREAK CHAR
	JMP	FNBX
	JMP	ERR
/
FNBX	DAC	BCHAR	/SAVE BREAK CHAR IN 'BCHAR' AND
	LAC	B1	/EXIT WITH DECIMAL NUMBER IN
	JMP*	FNB	/AC
/
B1	0
B2	0
/
/ FDD -- FETCH DECIMAL DIGIT SUBROUTINE
/
FDD	0
	JMS*	(FAC)	/FETCH CHARACTER
	JMS	CMP	/DECIMAL?
	60
	71
	JMP*	FDD	/NO -- RETURN AT JMS+1 WITH CHARACTER IN AC
	AND	(17)	/YES -- RETURN AT JMS+2 WITH DIGIT IN AC
	ISZ	FDD
	JMP*	FDD
/
/ CMP -- COMPARE-AC-WITH-LIMITS SUBROUTINE
/
/ CALLING SEQUENCE:
/	JMS	CMP
/	LL	/LOWER LIMIT
/	UL	/UPPER LIMIT
/ RETURN AT JMS+3 IF WITHOUT LIMITS
/ RETURN AT JMS+4 IF WITHIN LIMITS (INCLUSIVE)
/ AC IS RESTORED
/
CMP	0
	DAC	CMPBF	/SAVE AC
	LAC*	CMP	/WITHIN LOWER LIMIT?
	ISZ	CMP
	TCA
	TAD	CMPBF
	SPA
	JMP	CMP1	/NO -- RETURN AT JMS+3
	LAC	CMPBF	/YES -- WITHIN UPPER LIMIT?
	TCA
	TAD*	CMP
	SMA		/NO -- RETURN AT JMS+3
	ISZ	CMP	/YES -- RETURN AT JMS+4
CMP1	ISZ	CMP
	LAC	CMPBF	/RESTORE AC
	JMP*	CMP	/RETURN
/
CMPBF	0
/
/ CLX -- COLON TEST.  ERROR IF BREAK CHARACTER IS NOT A COLON.
/
CLX	0
	LAC	BCHAR
	SAD	(072)
	JMP*	CLX
	JMP	ERR
/
/ SLX -- SLASH TEST.  ERR IF BREAK CHARACTER IS NOT A SLASH.
/
SLX	0
	LAC	BCHAR
	SAD	(057)
	JMP*	SLX
	JMP	ERR
/
/ TCX -- TERMINAL CHARACTER TEST.  ERR IF BREAK CHARACTER
/ IS NOT A CAR RTN OR ALTMODE.
/
TCX	0
	LAC	BCHAR
	SAD	(015)
	JMP*	TCX
	SAD	(175)
	JMP*	TCX
	JMP	ERR
/
	.END	ETI
