	.TITLE FAC57 GENERAL ROUTINE TO GET A CHARACTER
/ 
/ 
/                   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 #1
/	FAC57 IS A SET OF TWO SUBROUTINES TO GET CHARACTERS
/		FROM A LINE BUFFER IN 5/7 FORMAT AND RETURN
/		THEM TO THE CALLER.
/
/	SUBROUTINE SET57
/
/		JMS*	(SET57)
/		+	LINEBUFFERADDRESS
/
/	THIS ROUTINE MUST BE CALLED FIRST TO DEFINE THE
/	LINE BUFFER TO BE PROCESSED
/
/
/	SUBROUTINE FAC57
/
/		JMS*	(FAC57)
/
/
/
/	THIS ROUTINE IS CALLED TO GET ONE CHARACTER
/	IT RETURNS WITH THE CHARACTER IN 7 BIT FORMAT
/	RIGHT JUSTIFIED IN THE AC.
/
/	IF A TERMINATOR IS SENSED ( 015,175) IT
/	WILL BE RETURNED ON EVERY SUBSEQUENT CALL TO FAC57
/
	.EJECT
SET57	0
	LAC*	SET57	/GET LINE BUFFER ADDRESS(HEADER)
	AAC	2
	DAC	FACLBX
	LAC	(FACCB+5)	/STARTS WITH END OF BUFFER
	DAC	FACCBX	/SETUP POINTERS
	ISZ	SET57
	JMP*	SET57
	.EJECT
FAC57	0
/		
/	SUBROUTINE FAC57-- FETCH A CHARACTER FROM THE 5/7 ASCII 
/	LINE BUFFER 'FACLB' DESCRIBED BY THE POINTERS FACLBX
/	AND FACCBX.
/	CHARACTERS ARE NOT FETCHED BEYOND THE TERMINAL CHARACTER.
/
/
	LAC*	FACCBX	/FETCH THE NEXT UNPACKED CHAR
	SMA		/WAS THE CHARBUFFER EMPTY
	JMP	FAC2	/NO-- TEST FOR A TERMINAL CHARACTER
	LAC	(FACCB-1)/YES -- REFILL FACLB FROM THE INPUT LINE
	DAC	FACCBX
	LAC*	FACLBX	/FIRST HALF OF A WORD PAIR
	ISZ	FACLBX
	LMQ
	CLA!CLL
	JMS	FACUPS	/FIRST CHAR
	JMS	FACUPS	/SECOND CHAR
	JMS	FACUPS	/FIRST 4 BITS OF THIRD CHAR
	LAC*	FACLBX	/SECOND HALF OF WORD PAIR
	ISZ	FACLBX
	LRS	17	/LAST 3 BITS OF THIRD CHAR
	XOR*	FACCBX
	DAC*	FACCBX
	CLA
	JMS	FACUPS	/FORTH CHAR
	JMS	FACUPS	/FIFTH CHAR
	LAC	(FACCB)	/RESET THE CHARACTER BUFFER INDEX
	DAC	FACCBX
	LAC*	FACCBX	/FETCH THE FIRST CHAR FROM TH BUFFER
			/OF CHARACTERS JUST FILLED
FAC2	SAD	(015)	/IF IT IS A TERMINAL CHARACTER, CARRIAGE
	JMP*	FAC57	/RETURN OR ALTMODE, RETURN WITH THE  CHAR
	SAD	(175)	/IN THE AC, BUT DO NO ALTER THE CHAR BUF INDEX
	JMP*	FAC57	/THUS REPEATED CALLS WILL GET THE SAME CHAR
	ISZ	FACCBX	/ELSE INCREMENT SAID INDEX
	JMP*	FAC57	/RETURN TO CALLER WITH CHAR IN AC
	.EJECT
/	SUBROUTINE FACUPS -- UNPACKING SUBROUTINE USED BY FAC57
/
/	CALLING SEQUENCE
/
/	AC AN LINK CLEAR
/	NEXT CHAR MUST BE IN
/	THE HIGH ORDER END OF THE MQ
/	FACCBX MUST POINT TO THE WORD PRECEDING
/	THE  ONE IN WHICH THE CHAR IS
/	TO BE STORED
/
/	JMS	FACUPS
/	(UNCONDITIONAL RETURN WITH FACCBX POINTING TO THE STORED
/	CHARACTER AND WITH THE AC AND LINK CLEARED)
/
/
FACUPS	0
	LLS	7	/SHIGT THE CHAR INTO THE AC
	ISZ	FACCBX	/LOW BITS OF THIRD CHAR ARE ZERO
	DAC*	FACCBX	/BECAUSE THE LINK IS ZERO
	CLA
	JMP*	FACUPS	/RETURN TO CALLER
FACLBX	740040		/INITIALIZED TO HALT
FACCBX	740040	/
FACCB	.BLOCK 5
	-1		/MARKS END OF BUFFER
	.GLOBL	FAC57,SET57
	.END
