	.TITLE TICTOC
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/%TIC
/INPUT A STRING OF CHARACTERS
/ . CHARACTERS ARE PACKED THREE TO A WORD.
/	/CALLING SEQUENCE:
/
/		LAW	STOP CHARACTER
/		.DSA	BUFFER AREA
/		JMS	%TIC
/
/STOP CHARACTER IS THE 6 OR 8 BIT ASCII CODE OF A TERMINATING
/CHARACTER. WHEN THIS CHARACTER IS TYPED, TIC STORES IT WITH THE
/REST OF THE TEXT AND STOPS LISTENING. THE USER CAN DELIMIT HIS
/TEST BY TYPING THE (IF NECESSARY FILLS OUT THE WORD WITH ZEROS.)
/'AT' SIGN. IF THE USER TYPE A WRONG CHARACTER
/HE CAN GO BACK AND START OVER BY DEPRESSING THE LINE-FEED KEY
/
/
/
%TIC	0
	DAC	%TOC
	AND	(77)	/STRIP HIGH-ORDER BITS
	DAC	%TICST	/STOP CHARACTER
	LAC*	%TIC
	TAD	(-1)	/GET BUFFER ADDRESS
	AND	(17777)
	DAC	%TICAD	/SAVE FOR POINTING
	CLL
%TICWD	JMS	%TCSET
	JMS	%TIC1	/GET A CHARACTER
	AND	(177
	SAD	(11
	JMP	%TICTB	/TAB
	SAD	(15
	JMP	%TICCR	/CARRIAGE RETURN
	SAD	(12
	JMP	%TICLF	/LINE FEED
	AND	(77
	SAD	%TICST	/IS IT A STOP CHARAC@DQ
	JMP	%TICFL	/YES... GO TO FILLER ROUTINE
	SNA!CLL
	JMP	%TICFL
/
/AT THIS POINT THERE IS VALID TEXT IN THE ACCUMULATOR.
	JMS	%TICPT	/PUT IT IN BUFFER.
	JMP	%TICWD	/RESET FOR ANOTHER WORD.
	JMP	%TICWD+1	/CONTINUE WITH PRESENT WORD.
%TICFL	JMS	%TICPT	/STORE STOP CHARACTER
	JMP	%TICEX	/WORD FULL; EXIT
	CLA		/WORD IS NOT FULL, CONTINUE
	JMP	%TICFL	/FILLING WITH ZEROES INSTEAD OF
			/STOP CHARACTER
%TCSET	0
	LAW	-3
	DAC	%TIC2
	ISZ	%TICAD
	DZM*	%TICAD
	JMP*	%TCSET
%TICPT	0
	TAD*	%TICAD
	DAC*	%TICAD
	ISZ	%TIC2
	SKP
	JMP*	%TICPT
	JMS	%TIORL
	DAC*	%TICAD
	ISZ	%TICPT
	JMP*	%TICPT
/EXIT ROUTINE
%TICEX	LAC	%TIC	/GET CALLING ADDRESS AND LINK
	RAL		/RESTORE LINK
	ISZ	%TIC
	LAC	%TOC
	JMP*	%TIC	/EXIT
%TICCR	JMS	%CARR
	JMP	%TICWD+1
%TICLF	JMS	%CARR
	JMP	%TIC+4	/START OVER
%TICTB	LAW	-1
	TAD	%TIOTB
	DAC	%TIOTB
	TAD	%TIOCN
	SMA!CLL
	JMP	.-2
	DAC	%TDIG
	JMS	%TABIT
	LAC	(40
	JMS	%TICPT
	JMS	%TCSET
	ISZ	%TDIG
	JMP	.-4
	JMP	%TICWD+1
/
/TDIG
/TYPE THE DIGIT IN THE RIGHTMOST FOUT BITS OF
/THE AC.  ASCII 260 IS ADDED TO FORM A CHARACTER
/
%TDIG	0
	DAC	%TOC		/SAVE ORGINAL VALUE
	AND	(17		/KEEP ONLY RIGHT MOST 4 BITS
	TAD	(260		/BUILD DECIMAL ASCII CHARACTER
	JMS	%TOC1		/PRINT IT
	LAC	%TOC		/RESTORE AC
	JMP*	%TDIG		/EXIT
/TOC		/TYPE OUT A STRING OF TEXT IN THE FORMAT
/DESCRIBED FOR TIC.
/
/CALLING SEQUENCE:
/		LAW	STOP CHARACTER
/		JMS	%TOC
/		.DSA	BUFFER ADDRESS
/
/STOP CHARACTER IS THE CONCISE 6-BIT CODE OR ASCII CODE.
/THE LOW-ORDER SIX BITS ARE THE ONLY BITS CONSIDERED.
/IF THE LOW-ORDER SIX BITS ARE ZERO, THEY ACT AS THE
/STOP CHARACTER.
/
%TOC	0
	DAC	%TIC	/SAVE ALL 18-BITS
	AND	(77	/KEEP ONLY THE RIGHTMOST
	DAC	%TICST	/SIX BIT OF THE STOP CHARACTER
	LAC*	%TOC	/GET CONTENTS OF THE RETURN ADDRESS
	TAD	(-1	/DECREMENT IT FOR THE LOOP
	AND	(17777	/KEEP ONLY THE ADDRESS
	DAC	%TICAD	/SAVE BUFFER ADDRESS
%TOCB	LAW	-3	/SETUP CHARACTER COUNTER
	DAC	%TIC2
	ISZ	%TICAD	/POINT TO NEXT DONOR WOR@
	LAC*	%TICAD	/GET NEXT WORD TO BE PRINTED
	RCL		/DO THE FIRST SHIFT
%TOCC	JMS	%TIORL	/SHIFT LEFT 6-MORE
	JMS	.+1
	0		/SAVE LINK
	DAC	%TIC3	/SAVE IT TEMPORARILY
	AND	(77	/KEEP ONLY THE RIGHTMOST
	SAD	%TICST	/6-BITS AND TEST FOR THE
	JMP	%TOCEX	/INTERNAL AND
	SNA!CLL		/EXTERNAL STOP CHAR
	JMP	%TOCEX	/EXIT
	DAC	%TIC1
	TAD	(777740
	LAC	(300
	SZL
	LAC	(200
	TAD	%TIC1
	JMS	%TOC1	/O.K. CONTINUE
	ISZ	%TIC2	/IS THIS THE LAST 6-BIT
	SKP		/SET OF THIS WORD?
	JMP	%TOCB	/YES...GET ANOTHER WORD
	LAC	%TOCC+2	/GET THE PRESENT LINK
	RAL
	LAC	%TIC3	/NO...GET THE SAME WORD AGAIN
	JMP	%TOCC	/SHIFT IT.
/
%TOCEX	LAC	%TOC	/GET CALLING ADDRESS AND LINK
	RCL		/RESTORE LINK
	LAC	%TIC	/RESTORE ACCUMULATOR
	ISZ	%TOC	/POINT TO RETURN ADDRESS
	JMP*	%TOC	/EXIT
%TIORL	0
	RTL
	RTL
	RTL
	JMP*	%TIORL
/
%TIC1	0
	KRS
	KSF
	JMP	.-1
	KRB
	JMS	%TOC1
	JMP*	%TIC1
/
%TOC1	0
	TSF
	JMP	.-1
	TLS
	ISZ	%TIOTB
	JMP*	%TOC1
/
/TABIT		/SPACES THE CARRIAGE TO THE NEXT
/TAB STOP. THIS COUNT IS KEPT IN %TIOCN AND IS
/ASSEMBLED AS-12 (OCTAL).
/
%TABIT	0
	DAC	%TOC
	LAC	%TIOTB	/BUILDING TAB COUNT
	TAD	%TIOCN	/SUBTRACT TAB
	SMA		/CONSTANT UNTIL AC IS
	JMP	.-2	/LESS THAN 0.
	DAC	%TIC1	/SAVE IT AS SPACE COUNTER.
	JMS	%SPACE
	ISZ	%TIC1	/FINISHED?
	JMP	.-2	/NO...KEEP SPACING
	LAC	%TABIT	/RESTORE LINK
	RAL
	LAC	%TOC
	DZM	%TIOTB
	JMP*	%TABIT	/EXIT
/TYPE A CARRIAGE RETURN AND LINE FEED;
/SET TAB COUNTER TO 0.
/
%CARR	0
	DAC	%TIORL
	LAW	215	/CARRIAGE RETURN
	JMS	%TOC1	/2 CR TO GUARANTEE
	LAW	215	/THAT THE CARRIAGE RETURNS
	JMS	%TOC1	/BEFORE PRINTING BEGINS
	LAW	212	/LINE FEED
	JMS	%TOC1
	DZM	%TIOTB	/CLEAR BUILDING TAB COUNT
	LAC	%TIORL
	JMP*	%CARR	/EXIT
/
/TYPE A SPACE.
/
%SPACE	0
	DAC	%TIORL
	LAW	240	/SPACE
	JMS	%TOC1
	LAC	%TIORL
	JMP*	%SPACE	/EXIT
KSF=700301
KRS=700332
KRB=700312
TSF=700401
TLS=700406
%TICST	0
%TICAD	0
%TIC2	0
%TIC3	0
%TIOTB	0
%TIOCN	-10
	.EOT

