	.TITLE	UN.PCK
/
/   4 JUL 78 (002; PDH) ADD ENTRIES 'UNP.SV' & 'UNP.RS'
/  23 JUN 78 - PAUL HENDERSON
/
/  ROUTINE TO UNPACK CHARACTERS, ONE AT A TIME.  NO CHECK IS MADE
/  TO DETERMINE IF A LINE TERMINATOR HAS ALREADY BEEN PROCESSED
/  SINCE THE LAST INITIALIZATION CALL.
/
/  CALLING SEQUENCES:
/
/  1) TO INITIALIZE -
/
/	LAC	(ADDRESS OF CHARACTERS TO BE UNPACKED
/	JMS*	UNP.IN
/	(RETURN)
/
/  2) TO UNPACK A CHARACTER -
/
/	JMS*	UN.PCK		/ RETURNS WITH CHARACTER IN AC
/	(RETURN IF LINE TERMINATOR)
/	(NORMAL RETURN)
/
/  3) TO SAVE CURRENT STATUS -
/
/	JMS*	UNP.SV
/	ADDRESS OF 2-WORD SAVE-RESTORE BUFFER
/	(RETURN)
/
/  4) TO RESTORE A PREVIOUS STATUS -
/
/	JMS*	UNP.RS
/	ADDRESS OF 2-WORD SAVE-RESTORE BUFFER
/	(RETURN)
 
IDX=ISZ			/ INDEX A POINTER (NEVER SKIPS)
 
	.EJECT
	.GLOBL	UNP.IN
 
UNP.IN	XX
	DAC	BUFADR		/ SAVE POINTER TO INPUT BUFFER ADDRESS
	LAC	(FIRSTC
	DAC	SWING		/ SET UP BRANCH ADDRESS
	JMP*	UNP.IN
 
BUFADR
 
	.GLOBL	UNP.SV						/(002)
 
UNP.SV	XX							/(002)
	LAC*	UNP.SV		/ FETCH SAVE AREA ADDRESS	/(002)
	IDX	UNP.SV		/ INDEX TO RETURN ADDRESS	/(002)
	DAC	UNP.IN		/ HANDY LOCATION FOR POINTER	/(002)
	LAC	BUFADR						/(002)
	DAC*	UNP.IN		/ SAVE LINE BUFFER ADDRESS	/(002)
	IDX	UNP.IN						/(002)
	LAC	SWING						/(002)
	DAC*	UNP.IN		/ SAVE 'SWING' ADDRESS		/(002)
	JMP*	UNP.SV						/(002)
 
 
	.GLOBL	UNP.RS						/(002)
 
UNP.RS	XX							/(002)
	LAC*	UNP.RS		/ GET SAVE AREA ADDRESS		/(002)
	IDX	UNP.RS						/(002)
	DAC	UNP.IN		/ HANDY LOCATION FOR POINTER	/(002)
	LAC*	UNP.IN						/(002)
	IDX	UNP.IN						/(002)
	DAC	BUFADR		/ RESTORE LINE BUFFER ADDRESS	/(002)
	LAC*	UNP.IN						/(002)
	DAC	SWING						/(002)
	JMP*	UNP.RS						/(002)
 
	.EJECT
	.GLOBL	UN.PCK
 
UN.PCK	XX
	LAC*	BUFADR		/ GET WORD TO BE PROCESSED
	JMP*	SWING		/ GO PROCESS IT
 
SWING	FIRSTC
	AND	(177		/ CHOP TO 7 BIT CHARACTER
	SAD	(15		/ CHECK FOR CARRIAGE RETURN
	SKP
	SAD	(175		/ AND FOR ALT MODE
	JMP*	UN.PCK		/ LINE TERMINATOR EXIT
	IDX	UN.PCK		/ INDEX TO NORMAL EXIT
	JMP*	UN.PCK
 
FIRSTC	LRS	13
	JMS	SWING
 
..2	LRS	4
	JMS	SWING
 
..3	DAC	SWING		/ HANDY PLACE FOR TEMPORARY STORAGE
	IDX	BUFADR		/ INDEX TO 2ND WORD OF PAIR
	LAC*	BUFADR
	LMQ
	LAC	SWING		/ RETRIEVE FRONT OF SPLIT CHARACTER
	LLS	3		/ UNSPLIT IT
	JMS	SWING
 
..4	LRS	10
	JMS	SWING
 
..5	IDX	BUFADR		/ INDEX TO NEXT WORD PAIR
	RAR
	JMS	SWING
	JMP	FIRSTC
	.END
