	.TITLE *** PP....
/ 
/ 
/                   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
/
/ COPYRIGHT 1971, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS., 01754
/
/ PC15 PAPER TAPE PUNCH I/O DEVICE HANDLER FOR THE
/ PDP-15 RSX-15 MONITOR SYSTEM.
/
/	EDIT	#13		31 DEC 71
/
/				C. PROTEAU
/
/ RECOGNIZED I/O FUNCTIONS:
/
/	17	ABORT
/	24	ATTACH
/	25	DETACH
/	27	OUTPUT(WRITE)
/	34	CLOSE
/	36	HINF
/	777	DISCONNECT & EXIT
/
/ LEGAL DATA MODES:
/
/	0	IOPS BINARY
/	1	IMAGE BINARY
/	2	IOPS ASCII
/	3	IMAGE ASCII
/
/ LABELLING CONVENTION:
/
/	ALL ADDRESS TAGS DEFINED WITHIN THIS TASK
/	BEGIN WITH "PP".
/
/ EVENT VARIABLES RETURNED:
/
/	+100010	VALUE SET BY THE HINF FUNCTION TO
/		INDICATE OUTPUT-ONLY, NON-DIRECTORY-
/		ORIENTED DEVICE WITH DEVICE CODE 10.
/
/	+1	NORMAL VALUE RETURNED FOR COMPLETION
/		OF OPERATION.
/
/	-6	UNIMPLEMENTED OR ILLEGAL CAL FUNCTION.
/
/	-7	ILLEGAL DATA MODE.
/
/	-16	ILLEGAL WORD PAIR COUNT. (THE LINE
/		BUFFER HEADER WORD-PAIR-COUNT IS < 2).
/
/	-24	I/O REQUEST REJECTED BECAUSE THE LUN
/		VIA WHICH THE REQUEST WAS MADE HAS
/		BEEN REASSIGNED AWAY FROM THIS
/		PHYSICAL DEVICE.
/
/	-30	I/O PARAMETER FOR A NORMAL MODE TASK
/		EXCEEDS PARTITION BOUNDS.
/
/	-203	I/O REQUEST (ATTACH OR DETACH) REJECTED
/		BECAUSE IT WAS NOT ISSUED AT TASK LEVEL.
/
/ DEFINITION OF REGISTERS LOCATED WITHIN THE RSX EXECUTIVE.
/
R1=101				/GENERAL REGISTER #1.
R2=102				/GENERAL REGISTER #2.
R3=103				/GENERAL REGISTER #3.
R4=104				/GENERAL REGISTER #4.
NADD=107			/ENTRY POINT TO "ADD
				/NODE TO DEQUE" SUBROUTINE.
SNAM=123			/ENTRY POINT TO "SEARCH FOR 
				/NODE IN DEQUE UNDER THIS
				/NAME" SUBROUTINE.
POOL=240			/HEAD OF THE EMPTY NODES DEQUE.
PDVL=252			/HEAD OF THE PHYSICAL DEVICE LIST DEQUE.
ALAD=325			/ENTRY POINT TO "ATTACH LUN & DEVICE" SUBROUTINE.
DLAD=332			/ENTRY POINT TO "DETACH LUN & DEVICE" SUBROUTINE.
DQRQ=337			/ENTRY POINT TO "DE-QUEUE REQUEST" SUBROUTINE.
VAJX=342			/ENTRY POINT TO "VERIFY AND ADJUST I/O
				/TRANSFER PARAMETERS TO 17 BITS" SUBROUTINE.
IOCD=345			/ENTRY POINT TO "DECREMENT I/O PENDING
				/COUNT" SUBROUTINE.
DMTQ=361			/ENTRY POINT TO "DETACH & EMPTY REQUEST
				/DEQUE" SUBROUTINE.
/
/ IOT & PARAMETER DEFINITIONS.
/
.INH=705522			/INHIBIT INTERRUPTS.
.ENB=705521			/ENABLE INTERRUPTS.
IORS=700314			/READ IORS STATUS WORD INTO THE AC.
				/BIT 9 INDICATES PUNCH-OUT-OF-TAPE.
				/HOWEVER, SINCE THIS DOES NOT CAUSE 
				/A PROGRAM INTERRUPT WHEN A SELECT 
				/IOT IS ISSUED, PUNCH STATUS MUST 
				/ALWAYS BE TESTED BEFORE PUNCHING
				/THE NEXT FRAME.
PCF=700202			/CLEAR THE PUNCH FLAG AND THE PUNCH
				/BUFFER.
PSA=700204			/SELECT ALPHANUMERIC MODE AND PUNCH
				/ONE 8-BIT CHARACTER FROM AC BITS 10
				/THRU 17.  SET THE PUNCH FLAG WHEN DONE.
IDX=ISZ				/IDX IS USED INSTEAD OF ISZ WHEN THE
				/INTENT IS TO ADD 1 TO A REGISTER BUT
				/NOT TO SKIP.
LUN=3				/LUN FOR NOT-READY MESSAGE.
	.TITLE *** INITIALIZATION CODE/VARIABLES
/
/ HANDLER INITIALIZATION CODE -- CONTROL STARTS AT THIS POINT AS A RESULT
/ OF A "REQUEST" BY THE MCR TASK "REASSIGN".
/
/ THIS CODE IS EXECUTED ONLY ONCE; HENCE, THESE REGISTERS ARE REUSED TO
/ STORE DATA VARIABLES.
/
/ **********************************************************************
/
/ ***************************** OVERLAYED ******************************
/
PPINIT	LAC	PPPDVL		/ADDRESS OF THE PHYSICAL
	DAC*	(R1)		/DEVICE LIST QUEUE.
	LAC	PPPNAM		/ADDRESS OF: .SIXBT "PP@@@@".
	DAC*	(R2)	
	JMS*	(SNAM)		/SCAN THE PHYSICAL DEVICE LIST FOR THE
				/PAPER TAPE PUNCH NODE.
				/(R1, R2, R6, X17, XR & AC ARE ALTERED).
				/WAS THE NODE FOUND?
	CAL	(10)		/NO -- EXIT.
	DAC	PPPDNA		/YES -- SAVE THE NODE ADDRESS.
/
/ SAVE THE ADDRESS OF THE REGISTER IN THE PHYSICAL DEVICE LIST NODE 
/ WHICH IS SUPPOSED TO CONTAIN THE ADDRESS OF PP'S TRIGGER EVENT VARIABLE.
/ THEN, STORE THE TRIGGER EVENT VARIABLE ADDRESS IN THE PHYSICAL DEVICE
/ LIST NODE.
/
	AAC	+10
	DAC	PPPDEV
	LAC	PPPTTG		/PICK UP THE ADDRESS OF
	DAC*	PPPDEV		/THE TRIGGER EVENT VARIABLE.
/
/ COMPUTE AND STORE THE INDEX REGISTER ADJUSTMENT FACTOR.  WHEN USING
/ THE CONTENTS OF THE INDEX REGISTER AS A BASE ADDRESS AND THE ADDRESS
/ OPERAND AS A CONSTANT OFFSET, AS IN  LAC 3,X  , ONE MUST ADD AN ADJUSTMENT
/ FACTOR TO THE CONTENTS OF THE XR TO OFFSET THE ADDRESS OPERAND'S 
/ IMPLIED PAGE BITS.
/
	AND	PP70K		/SAVE THE PAGE BITS AS A NEGATIVE 
	TCA			/ADJUSTMENT FACTOR.
	DAC	PPXADJ
/
/ CONNECT THE INTERRUPT LINE (API CHANNEL 42) TO PP'S INTERRUPT SERVICE
/ ROUTINE (PP.INT).  API CHANNEL 42 DOES NOT REALLY EXIST.  IT IS 
/ SIMULATED BY THE RSX EXECUTIVE BECAUSE THE PAPER TAPE PUNCH CAUSES
/ ONLY PROGRAM INTERRUPTS.
/
	CAL	PPCNCT		/"CONNECT".
	IDX	PPCNCT		/CHANGE THE "CONNECT" CPB
	DZM	PPCNCT+1	/TO A "DISCONNECT" CPB.
	LAC	PP.EV		/WAS THE CONNECT
	SPA			/SUCCESSFULLY PERFORMED?
	JMP	PPUNDO		/NO -- EXIT.
	JMP	PP.TW		/YES -- WAIT FOR TRIGGER.
/
/ DATA CONSTANTS USED ONLY DURING THE INITIALIZATION CODE.
/
PPNAME	.SIXBT	"PP@@@@"
PPPDVL	PDVL			/ADDRESS OF THE PHYSICAL DEVICE LIST
				/QUEUE.
PPPNAM	PPNAME
PP70K	070000			/PAGE BIT MASK.
PPPTTG	PPTGEV			/ADDRESS OF THE TRIGGER EVENT VARIABLE.
/
/ ********************* END OF OVERLAYABLE CODE ************************
/
/ **********************************************************************
/
PPIEND=.			/USED FOR .LOC CONDITIONAL BELOW.
/
	.EJECT
/ THE FOLLOWING DATA VARIABLES, WHICH DO NOT NEED TO START OUT WITH A
/ SPECIFIED VALUE, OVERLAY THE ONCE-ONLY INITIALIZATION CODE AT THE
/ BEGINNING OF THIS PROGRAM.
/
PPPDNA=PPINIT+0			/ADDRESS OF THE PHYSICAL DEVICE NODE.
PPXADJ=PPINIT+1			/INDEX REGISTER ADJUSTMENT FACTOR (SEE
				/INITIALIZATION CODE FOR EXPLANATION).
PP.EV=PPINIT+2			/PP'S EVENT VARIABLE.
PPPDEV=PPINIT+3			/ADDRESS OF THE WORD IN THE PHYSICAL
				/DEVICE NODE THAT CONTAINS THE TRIGGER
				/EVENT VARIABLE ADDRESS.
PPRQEV=PPINIT+4			/ADDRESS OF THE REQUESTOR'S EVENT VARIABLE.
PPMODE=PPINIT+5			/THE DATA MODE.
PPHEAD=PPINIT+6			/ADDRESS OF THE REQUESTOR'S LINE BUFFER HEADER.
PPDPTR=PPINIT+7			/POINTER TO A DATA WORD WITHIN THE REQUESTOR'S
				/LINE BUFFER.
PPRQND=PPINIT+10		/ADDRESS OF THE CURRENT I/O REQUEST NODE.
PP.AC=PPINIT+11			/TEMPORARY STORAGE FOR
				/THE AC WHILE IN THE
				/INTERRUPT SERVICE ROUTINE.
PP.CNT=PPINIT+12		/COUNTER.
PPCHAR=PPINIT+13		/7-BIT ASCII CHARACTER OR
				/6-BIT BINARY BYTE.
PP3CNT=PPINIT+14		/COUNTER FOR 3 TAPE FRAMES
				/PER BINARY WORD (IOPS
				/OR IMAGE BINARY).
PP.WC=PPINIT+15			/NEGATIVE WORD COUNTER:
				/INITIALLY SET TO - BUFFER SIZE
				/AS SPECIFIED BY LINE BUFFER HEADER
				/WORD PAIR COUNT.
PPCKSM=PPINIT+16		/CHECKSUM.
PPBCNT=PPINIT+17		/IOPS ASCII BYTE COUNT
				/USED IN DATA UNPACKING:
				/RANGE: -5 TO 0.
PPTBUF=PPINIT+20		/5 WORD TEMPORARY
/	     +21		/BUFFER USED FOR IOPS
/	     +22		/ASCII UNPACKING. ONE
/	     +23		/CHARACTER IS STORED
/	     +24		/PER WORD IN BITS 0 THRU
				/6; THE REMAINDER OF THE
				/WORD IS NOT NECESSARILY 0.
PPBINW=PPINIT+25		/TEMPORARY STORAGE FOR
				/BINARY WORD TO BE
				/PUNCHED OUT IN 3 TAPE FRAMES.
PPCHR1=PPINIT+26		/USED BY IOPS ASCII TO
				/DETECT THE FIRST CHARACTER
				/IN THE REQUESTOR'S
				/BUFFER.  SET NON-0 ONLY
				/WHEN PROCESSING THE
				/FIRST CHARACTER.
PPUNTP=PPINIT+27		/TEMPORARY STORAGE TO BE USED
				/ONLY BY THE PPUNCH SUBROUTINE.
PPABNA=PPINIT+30		/ADDRESS OF THE 'ABORT' I/O REQUEST NODE.
PPABSN=PPINIT+31		/STL NODE ADDRESS OF THE TASK BEING ABORTED.
PPIOSN=PPINIT+32		/STL NODE ADDRESS OF THE TASK FOR WHICH
				/AN I/O REQUEST IS IN PROGRESS.
PPRDEV=PPINIT+33		/EVENT VARIABLE ADDRESS FOR THE I/O
				/RUNDOWN TASK.
/
/ THE .LOC BELOW IS NECESSARY IN CASE THE NUMBER OF VARIABLES EXCEEDS THE
/ SIZE OF THE INIT CODE.
/
PP.LOC=PPINIT+34
/
	.IFNEG	PPIEND-PP.LOC
	.LOC	PP.LOC
	.ENDC
	.TITLE *** I/O REQUEST PROCESSING
/
/ WAIT FOR TASK TO BE TRIGGERED (BY 'I/O CAL' CAL SERVICE
/ ROUTINE OR BY THE I/O RUNDOWN TASK) TO SIGNAL THAT
/ A REQUEST HAS BEEN QUEUED.
/
PP.TW	CAL	PPWFTG		/"WAITFOR" PAPER TAPE PUNCH
				/TRIGGER EVENT VARIABLE TO
				/BE SET.
	DZM	PPTGEV		/CLEAR THE TRIGGER.
/
/ THE TASK HAS BEEN TRIGGERED -- PICK A REQUEST FROM
/ THE QUEUE (IF ANY).
/
PPPICK	LAC	PPPDNA		/PUT THE PHYSICAL DEVICE NODE ADDRESS
	DAC*	(R1)		/INTO R1.
	JMS*	(DQRQ)		/DE-QUEUE AN I/O REQUEST.
				/(R1, R2, R4, R5, R6, XR & AC ARE ALTERED).
				/WAS A REQUEST FOUND?
	JMP	PP.TW		/NO -- WAIT FOR TRIGGER.
	DAC	PPRQND		/YES -- SAVE THE NODE'S ADDRESS.
/
/ AN I/O REQUEST NODE HAS BEEN FOUND. PICK UP THE
/ PARAMETERS FROM THE NODE.
/
	JMS	PPADJX		/SET THE XR TO ACCESS THE REQUEST NODE.
	LAC	2,X		/SAVE THE TASK'S STL NODE ADDRESS.
	DAC	PPIOSN
	LAC	6,X		/SAVE THE ADDRESS (OR 0 IF
	DAC	PPRQEV		/NONE) OF THE REQUESTOR'S
				/EVENT VARIABLE.
	LAC	7,X		/SAVE THE DATA MODE.
	DAC	PPMODE
	LAC	10,X		/SAVE THE ADDRESS OF THE
	DAC	PPHEAD		/LINE BUFFER HEADER.
/
	.EJECT
/ FETCH THE CAL FUNCTION CODE AND DISPATCH TO THE
/ APPROPRIATE ROUTINE.
/
	LAC	5,X		/THE CAL CODE IS IN THE
	AND	(777)		/RIGHT HALF OF THE WORD.
	SAD	(017)
	JMP	PPABOR		/ABORT.
	SAD	(024)		
	JMP	PPATCH		/ATTACH.
	SAD	(025)	
	JMP	PPDTCH		/DETACH.
	SAD	(027)
	JMP	PPWRIT		/OUTPUT (WRITE).
	SAD	(034)
	JMP	PPCLOS		/CLOSE.
	SAD	(036)
	JMP	PPHINF		/HINF.
	SAD	(777)
	JMP	PPEXIT		/DISCONNECT & EXIT.
/
/ UNIMPLEMENTED OR ILLEGAL FUNCTION.
/
PPIFNC	LAW	-6
	JMP	PPSREV		/SET REQUESTOR'S EVENT VARIABLE.
	.TITLE *** ABORT
/
/ ABORT ALL I/O INITIATED BY THIS TASK.
/
/ NOTE THAT ABORT, IN THOSE CASES WHERE I/O IS IN PROGRESS, IS HANDLED
/ BY THE 'PPUNCH' SUBROUTINE. HERE, ABORT WAS DE-QUEUED WHEN NO PUNCH
/ I/O WAS UNDER WAY.
/
PPABOR	XOR	5,X		/ABORT IS AN ILLEGAL FUNCTION FOR ALL
	SZA			/TASKS EXCEPT 'IORD', WHO SETS LUN = 0.
	JMP	PPIFNC
/
	LAC	2,X		/MATCH STL POINTERS TO SEE IF THE TASK
	SAD	PPWSTL		/BEING ABORTED IS THE LAST ONE TO HAVE
				/WRITTEN TO THE PUNCH.
	DZM	PPLEAD		/YES -- INITIALIZE THE "PUNCH 2 FANFOLDS
				/OF LEADER" FLAG.
/
	LAC	PPPDNA		/ADDRESS OF THE PHYSICAL DEVICE NODE.
	DAC*	(R1)
	LAC	PPRQND		/ADDRESS OF THE I/O REQUEST NODE.
	DAC*	(R2)
	JMS*	(DMTQ)		/DETACH LUN & DEVICE, IF NECESSARY, AND
				/THEN EMPTY THE REQUEST QUEUE OF ALL I/O
				/REQUESTS MADE BY THE TASK BEING ABORTED.
				/(R1, R2, R3, R5, R6, X10, X11, X12, XR
				/& AC ARE ALTERED).
	JMP	PPRQOC		/DONE.
	.TITLE *** ATTACH/DETACH
/
/ ATTACH THE PAPER TAPE PUNCH TO A TASK.
/
PPATCH	LAC	PPPDNA		/PUT THE PHYSICAL DEVICE NODE ADDRESS
	DAC*	(R1)		/INTO R1.
	LAC	PPRQND		/PUT THE I/O REQUEST NODE ADDRESS INTO R2.
	DAC*	(R2)
	JMS*	(ALAD)		/ATTACH THE LUN & PHYSICAL DEVICE TO THE TASK.
				/(R3, R4, R5, R6, X10, X11, XR & AC ARE
				/ALTERED).
				/WAS THE ATTACH DONE?
	JMP	PPSREV		/NO -- THE PROPER EVENT VARIABLE SETTING
				/IS IN THE AC.
	JMP	PPRQOC		/YES -- REQUESTED OPERATION COMPLETED.
/
/ DETACH THE PAPER TAPE PUNCH FROM THE TASK.
/
PPDTCH	LAC	PPPDNA		/PUT THE PHYSICAL DEVICE NODE ADDRESS
	DAC*	(R1)		/INTO R1.
	LAC	PPRQND		/PUT THE I/O REQUEST NODE ADDRESS INTO R2.
	DAC*	(R2)
	JMS*	(DLAD)		/DETACH THE LUN & PHYSICAL DEVICE FROM
				/THE TASK.
				/(R3, R4, R5, R6, X10, X11, XR & AC ARE
				/ALTERED).
				/WAS THE DETACH DONE?
	JMP	PPSREV		/NO -- THE PROPER EVENT VARIABLE SETTING
				/IS IN THE AC.
	JMP	PPRQOC		/YES -- REQUESTED OPERATION COMPLETED.
	.TITLE *** EXIT/HINF
/
/ DISCONNECT THE INTERRUPT LINE AND THEN EXIT.  THIS
/ I/O REQUEST IS MADE BY THE "REASSIGN" MCR TASK.
/
/ FIRST, RETURN THE I/O REQUEST NODE TO THE POOL OF EMPTY NODES.
/
PPEXIT	LAC	(POOL)		/ADDRESS OF THE HEAD OF THE
	DAC*	(R1)		/EMPTY POOL.
	LAC	PPRQND		/ADDRESS OF THE NODE TO
	DAC*	(R2)		/BE RETURNED.
	JMS*	(NADD)		/ADD THE NODE TO THE POOL.
				/(R1, R2, R6, XR & AC ARE ALTERED).
/
/ NOTE -- CONTROL COMES HERE FROM THE PPINIT
/ CODE IF THE CONNECT IS NOT SUCCESSFUL.
/
	CAL	PPCNCT		/DISCONNECT THE INTERRUPT LINE.
PPUNDO	.INH			/INHIBIT INTERRUPTS.
	DZM*	PPPDEV		/CLEAR THE TRIGGER EVENT VARIABLE ADDRESS
	IDX	PPPDEV		/AND THE "REQUEST INHIBIT" FLAG IN THE
	DZM*	PPPDEV		/PHYSICAL DEVICE NODE.
	.ENB			/ENABLE INTERRUPTS.
	CAL	(10)		/EXIT.
/
/ HINF (HANDLER INFORMATION) FUNCTION.  SET THE REQUESTOR'S EVENT
/ VARIABLE TO INDICATE DEVICE CODE 10 AND THAT THE HANDLER
/ PERFORMS ONLY NON-DIRECTORY-ORIENTED OUTPUT.
/
PPHINF	LAC	(100010)
	JMP	PPSREV
	.TITLE *** WRITE INITIATION
/
/ WRITE TO THE PUNCH.
/
PPWRIT	LAC	PPMODE		/LEGAL DATA MODES: 0 THRU 3.
	SPA
	JMP	PPIMDE		/ILLEGAL DATA MODE.
	AAC	-4
	SMA
	JMP	PPIMDE		/ILLEGAL DATA MODE.
/
/ FOR A NORMAL MODE TASK, VERIFY THAT THE ADDRESS OF THE LINE BUFFER
/ HEADER IS WITHIN THE TASK'S PARTITION AND ADJUST THE HEADER ADDRESS
/ TO 17 BITS.
/
	LAC	PPRQND		/ADDRESS OF THE I/O REQUEST NODE.
	DAC*	(R2)
	LAC	PPHEAD		/ADDRESS OF THE HEADER.
	DAC*	(R3)
	CLA!IAC			/PRETEND THAT THE BUFFER SIZE IS +1.
	DAC*	(R4)
	JMS*	(VAJX)		/(R3, R5, XR & AC ARE ALTERED).
				/ERROR?
	JMP	PPXPER		/YES -- HEADER IS OUTSIDE OF THE PARTITION.
	LAC*	(R3)		/NO -- SET XR TO ADJUSTED HEADER ADDRESS.
	JMS	PPADJX
/
/ VALIDATE THE WORD-PAIR-COUNT IN THE LINE BUFFER HEADER.
/
	LAC	0,X		/CONVERT WORD-PAIR-COUNT INTO A WORD COUNT.
	LRS	10
	AND	(776)
	DAC*	(R4)		/SAVE FOR CALL TO "VAJX".
	SZA!TCA
	SAD	PPHTAB		/SAD (-2).
	JMP	PPIWPC		/ILLEGAL WORD-PAIR-COUNT.
	AAC	+2		/SET THE WORD COUNT TO BYPASS THE HEADER.
	DAC	PP.WC		/SAVE THE WORD COUNT.
/
/ FOR A NORMAL MODE TASK, VERIFY THAT THE LINE BUFFER LIES WITHIN THE
/ TASK'S PARTITION. THE REQUEST NODE ADDRESS SHOULD STILL BE IN "R2".
/
	LAC	PPHEAD		/UNADJUSTED ADDRESS OF THE HEADER.
	DAC*	(R3)
	JMS*	(VAJX)		/(R3, R5, XR & AC ARE ALTERED).
				/ERROR?
	JMP	PPXPER		/YES -- LINE BUFFER EXCEEDS PARTITION BOUNDS.
	LAC*	(R3)		/NO -- SAVE THE ADJUSTED HEADER ADDRESS.
	DAC	PPHEAD
	AAC	+2
	DAC	PPDPTR		/SET UP THE DATA WORD POINTER.
	LAC	PPMODE		/SAVE THE DATA MODE FOR
	DAC	PPLMOD		/REFERENCE BY THE CLOSE FUNCTION.
	LAC	PPRQND		/SET THE XR WITH THE REQUEST NODE ADDRESS.
	JMS	PPADJX
	LAC	2,X		/SAVE THE STL NODE ADDRESS OF THE LAST
	DAC	PPWSTL		/TASK TO HAVE DONE A WRITE.
/
/ IF THIS IS THE FIRST WRITE REQUEST SINCE THIS HANDLER
/ WAS LOADED OR IF THIS IS THE FIRST WRITE REQUEST FOLLOWING
/ A CLOSE REQUEST, PUNCH 2 FANFOLDS OF BLANK 
/ TAPE TO FORM A LEADER.
/
	LAC	PPLEAD		/0 MEANS: PUNCH LEADER.
	SZA!CLC
	JMP	PPNOLD		/NO LEADER.
	DAC	PPLEAD
/
	.DEC
	LAW	-170		/85 DECIMAL FRAMES PER FANFOLD.
	.OCT
	JMS	PPPNUL		/PUNCH SPECIFIED # OF NULLS.
				/RETURN IF TASK IS NOT ABORTED.
				/(ASSUME ALL ACTIVE REGISTERS ALTERED).
/
/ DISPATCH TO THE APPROPRIATE DATA MODE PROCESSOR.
/
PPNOLD	LAC	PPMODE
	PAX
	JMP	PPDTAB,X
/
/ DISPATCH TABLE.
/
PPDTAB	JMP	PPMDE0		/IOPS BINARY.
	JMP	PPMDE1		/IMAGE BINARY.
	JMP	PPMDE2		/IOPS ASCII.
	JMP	PPMDE3		/IMAGE ASCII.
	.TITLE ***   IOPS BINARY (MODE 0)
/
/ PUNCH AN IOPS BINARY RECORD: HEADER WORD PAIR
/ (INCLUDING HANDLER-COMPUTED CHECKSUM), BLOCK
/ BODY OF DATA WORDS, AND ONE BLANK TAPE
/ FRAME (IGNORED ON INPUT) TO ACT AS A
/ VISUAL RECORD SEPARATOR. ALL IOPS BINARY
/ TAPE FRAMES ARE PUNCHED IN ODD PARITY
/ AND WITH BIT 8=1.
/
PPMDE0	LAC	PPHEAD		/SET XR TO ADDRESS OF HEADER.
	JMS	PPADJX
	777000			/SET THE RIGHT HALF OF
	AND	0,X		/LINE BUFFER HEADER
	DAC	0,X		/WORD 0 TO ZERO TO
				/INSURE THAT THE
				/DATA MODE IS IOPS
				/BINARY AND THAT
				/THE DATA VALIDITY
				/BITS ARE CLEARED.
/
/ COMPUTE THE SUM OF ALL THE DATA WORDS.
/
	LAC	PP.WC		/SAVE THE DATA WORD COUNT IN PP.CNT;
	DAC	PP.CNT		/THEN, ADD 2 TO THE WORD COUNT TO
	AAC	-2		/INCLUDE THE HEADER WORD PAIR.
	DAC	PP.WC
	DZM	PPCKSM		/INITIALIZE THE CHECKSUM.
	LAC	PPDPTR		/POINTER TO 1ST DATA WORD.
	JMS	PPADJX		/ADD ADJUSTMENT FACTOR
				/TO COMPENSATE FOR PAGE BITS.
/
PPCSLP	LAC	0,X		/ADD DATA WORD
	TAD	PPCKSM		/TO THE CHECKSUM.
	DAC	PPCKSM
	AXR	1
	ISZ	PP.CNT
	JMP	PPCSLP
/
/ ADD THE HEADER WORD 0 TO THE CHECKSUM, FORM
/ THE TWOS COMPLEMENT SO THAT THE TOTAL
/ SUM ADDS UP TO ZERO, STORE THE CHECKSUM
/ IN HEADER WORD 1, AND SET THE DATA
/ POINTER TO HEADER WORD 0 TO PREPARE
/ FOR PUNCHING.
/
	LAC	PPHEAD
	DAC	PPDPTR		/POINT TO HEADER WORD 0.
	LAC	PPHEAD		/SET XR TO HEADER ADDRESS.
	JMS	PPADJX
	LAC	0,X
	TAD	PPCKSM
	TCA
	DAC	1,X		/STORE THE CHECKSUM.
/
/ THE FOLLOWING CODE IS COMMON TO BOTH
/ IOPS AND IMAGE BINARY. PUNCH THE
/ BINARY RECORD IN ODD PARITY WITH
/ BIT 8=1 IN EVERY FRAME.
/
PPBLP1	LAW	-3		/COUNTER FOR 3 TAPE
	DAC	PP3CNT		/FRAMES PER BINARY WORD.
	LAC	PPDPTR		/SET XR TO DATA POINTER ADDRESS.
	JMS	PPADJX
	LAC	0,X		/GET DATA WORD.
	DAC	PPBINW		/SAVE TEMPORARILY.
/
PPBLP2	LAC	PPBINW		/ROTATE WORD 6 LEFT
	RTL
	RTL
	RTL
	DAC	PPBINW		/AND SAVE REMAINDER.
	RAL
	AND	(77)		/MASK TO 6 BITS.
	DAC	PPCHAR		/SAVE LINE TEMPORARILY.
	JMS	PP.PAR		/COMPUTE THE CHARACTER
				/PARITY (REMEMBER --
				/NOT INCLUDING THE
				/8TH BIT). LEAVE THE
				/RESULT IN THE LINK.
				/(LINK, AC & PP.CNT ARE ALTERED).
	LAC	PPCHAR
	AAC	+200		/ADD ON BIT 8.
	SZL
	AAC	+100		/ADD ON BIT 7.
/
/ PUNCH THE TAPE FRAME AFTER VERIFYING THAT
/ THE PUNCH IS NOT OUT OF TAPE. RETURN
/ WHEN OPERATION IS COMPLETED, UNLESS THE
/ TASK IS ABORTED.
/
	JMS	PPUNCH		/PUNCH CONTENTS OF THE AC.
				/(ALL ACTIVE REGISTERS ALTERED).
/
/ CHECK IF THE BINARY WORD OUTPUT IS COMPLETE.
/
	ISZ	PP3CNT
	JMP	PPBLP2		/NO.
/
/ CHECK IF THE BUFFER HAS BEEN COMPLETELY PUNCHED.
/
	IDX	PPDPTR		/ADD 1 TO THE DATA POINTER.
	ISZ	PP.WC
	JMP	PPBLP1		/END OF BUFFER NOT REACHED.
/
	.EJECT
/ PUNCH 1 BLANK TAPE FRAME (WHICH WILL
/ BE DISCARDED ON INPUT) TO PROVIDE A
/ VISUAL SEPARATION BETWEEN BINARY
/ RECORDS.
/
	CLA			/NULL CHARACTER.
	JMS	PPUNCH		/PUNCH CONTENTS OF THE AC.
				/RETURN IF TASK IS NOT ABORTED.
				/(ALL ACTIVE REGISTERS ALTERED).
	JMP	PPRQOC		/REQUEST OPERATION COMPLETED.
	.TITLE	***   IMAGE BINARY (MODE 1)
/
/ PUNCH AN IMAGE BINARY RECORD:  NO HEADER
/ WORD PAIR, NO CHECKSUM, BLOCK BODY OF
/ DATA WORDS, AND ONE BLANK TAPE FRAME
/ (IGNORED ON INPUT) TO ACT AS A VISUAL
/ RECORD SEPARATOR. ALL IMAGE BINARY
/ TAPE FRAMES ARE PUNCHED IN ODD PARITY
/ AND WITH BIT 8=1. THE PARITY IS NOT
/ REQUIRED (SINCE IT IS IGNORED WHEN
/ INPUT BY THE PAPER TAPE READER
/ HANDLER IN THIS SAME DATA MODE);
/ IT IS COMPUTED ONLY BECAUSE BOTH
/ BINARY MODES UTILIZE COMMON CODE.
/
PPMDE1=PPBLP1			/GO TO COMMON CODE.
	.TITLE	***   IOPS ASCII (MODE 2)
/
/ PUNCH AN IOPS ASCII RECORD:  NO HEADER WORD
/ PAIR, NO CHECKSUM, BLOCK BODY OF DATA WORDS
/ (8-BIT, EVEN PARITY TAPE FRAMES), NO BLANK
/ TAPE FRAME BETWEEN RECORDS.
/
PPMDE2	LAW	-1		/SET THE "FIRST
	DAC	PPCHR1		/CHARACTER" FLAG NON-0.
/
/ PICK UP THE NEXT DATA WORD PAIR AND UNPACK
/ THE 5 CHARACTERS INTO A TEMPORARY BUFFER.
/
PPALP1	LAC	PPDPTR		/SET THE XR TO THE DATA POINTER ADDRESS.
	JMS	PPADJX
	LAC	0,X		/WORD 1 OF THE PAIR.
	IDX	PPDPTR
	PAL			/TEMPORARY STORAGE.
	LAC	1,X		/WORD 2 OF THE PAIR.
	IDX	PPDPTR
	LMQ			/WORD 2 TO THE MQ.
	LAC	(5)
	PAX
	PLA			/WORD 1 TO THE AC.
	PXL
	CLX
/
/ THE IOPS ASCII WORd PAIR ARE IN THE AC
/ AND MQ. DISSECT THE WORD PAIR AND PLACE 
/ ONE CHARACTER PER WORD INTO A 5-WORD
/ TEMPORARY BUFFER. THE CHARACTER WILL
/ BE POSITIONED IN BITS 0 THRU 6 AND THE
/ REMAINDER OF THE WORD WILL NOT BE ZERO.
/
PPALP2	DAC	PPTBUF,X
	LLS	7
	AXS	1
	JMP	PPALP2
/
	LAW	-5		/SET THE BYTE COUNTER
	DAC	PPBCNT		/FOR 5 CHARACTERS.
/
/ PROCESS EACH CHARACTER FROM THE TEMPORARY BUFFER.
/
PPALP3	LAC	PPBCNT		/PICK A CHARACTER
	PAX			/FROM THE TEMPORARY
	LAC	PPTBUF+5,X	/BUFFER.
	LRS	13
	AND	(177)
	DAC	PPCHAR		/SAVE THE 7-BIT CHARACTER.
/
	.EJECT
/ CHECK IF THIS IS THE FIRST CHARACTER FROM
/ THE REQUESTOR'S BUFFER.  IF IT IS AND IF
/ IT IS NOT A LINE FEED OR OVERPRINT
/ CHARACTER, PUNCH A LINE FEED BEFORE
/ PUNCHING OUT THE REQUESTOR'S BUFFER.
/ THIS IS DONE SO THAT PUNCHED OUTPUT
/ CAN BE LISTED OFF-LINE IF NECESSARY.
/ LINES OUTPUT BY MACRO LANGUAGE PRO-
/ GRAMS NORMALLY TERMINATE WITH JUST A
/ CARRIAGE RETURN, SO IT IS REASONABLE
/ TO INSERT A LINE FEED AT THE BEGINNING
/ OF THE FOLLOWING LINE.
/
/ LINES TERMINATED BY ALTMODE PRESENT A
/ PROBLEM SINCE THE INSERTION OF A LINE
/ FEED AT THE BEGINNING OF THE NEXT LINE
/ IS NOT REALLY MEANINGFUL.  HOWEVER, IT
/ IS NOT WORTH THE EXTRA CODE TO CHECK
/ FOR AND ELIMINATE THIS SITUATION.
/
	LAC	PPCHR1		/SKIP IF WORKING ON
	SNA			/THE FIRST CHARACTER.
	JMP	PPNOT1		/NO.
	DZM	PPCHR1		/YES -- CLEAR THE FLAG.
	LAC	PPCHAR
	SAD	(12)		/LINE FEED?
	SKP
	SAD	(20)		/OVERPRINT?
	JMP	PPNOT1		/YES.
	LAC	(012)		/NO -- PUNCH ONE LINE FEED
	JMS	PPUNCH		/AND RETURN WHEN DONE, UNLESS
				/THE TASK IS ABORTED.
				/(ASSUMES ALL ACTIVE REGISTERS ALTERED).
/
	.EJECT
/ CONVERT THE PRESENT CHARACTER TO 8-BIT EVEN
/ PARITY AND PUNCH IT.
/
PPNOT1	JMS	PP.PAR		/COMPUTE THE CHARACTER
				/PARITY -- LEAVE THE
				/RESULT IN THE LINK.
				/(LINK, AC & PP.CNT ARE ALTERED).
	LAC	PPCHAR		/ADD BIT 8 TO
	SZL			/CHANGE THE PARITY
	AAC	+200		/TO EVEN, IF NECESSARY.
	JMS	PPUNCH		/PUNCH CONTENTS OF THE AC.
				/RETURN IF THE TASK IS NOT ABORTED.
				/(ASSUME ALL ACTIVE REGISTERS ALTERED).
/
/ IN CASE THE TAPE IS TO BE LISTED OFF-LINE,
/ ADD FILLER CHARACTERS TO PROVIDE A
/ NECESSARY TIMING DELAY FOR
/ FORM CONTROL CHARACTERS.
/
	LAC	PPCHAR
	SAD	(11)
	JMP	PPHTAB		/HORIZONTAL TAB.
	SAD	(13)
	JMP	PPVTAB		/VERTICAL TAB.
	SAD	(14)
	JMP	PPFORM		/FORM FEED.
/
/ TEST FOR LINE TERMINATORS: CARRIAGE
/ RETURN AND ALTMODE. IF ONE IS FOUND,
/ THE WRITE OPERATION IS COMPLETED.
/
	SAD	(15)		/CARRIAGE RETURN?
	SKP			/YES.
	SAD	(175)		/ALT MODE?
	JMP	PPRQOC		/YES -- REQUEST
				/OPERATION COMPLETED.
/
/ CHECK IF THE CURRENT WORD PAIR IS EXHAUSTED.
/
PPWPCK	ISZ	PPBCNT
	JMP	PPALP3		/NO -- FETCH NEXT
				/CHARACTER.
/
/ INDEX THE WORD COUNT TO THE NEXT WORD
/ PAIR AND CHECK IF THE END OF THE
/ BUFFER WAS REACHED.
/
	IDX	PP.WC		/END OF BUFFER?
	ISZ	PP.WC
	JMP	PPALP1		/NO -- FETCH NEXT
				/WORD PAIR.
/
	.EJECT
/ THE END OF THE REQUESTOR'S LINE BUFFER
/ WAS REACHED AND NO LINE TERMINATOR 
/ WAS FOUND. PUNCH A CARRIAGE RETURN.
/
	LAC	(215)		/PUNCH A CARRIAGE RETURN
	JMS	PPUNCH		/AND RETURN WHEN DONE, UNLESS
				/THE TASK IS ABORTED.
				/(ASSUME ALL ACTIVE REGISTERS
				/ARE ALTERED).
	JMP	PPRQOC		/REQUEST OPERATION COMPLETED.
/
/ NOTE -- THE FILLER CHARACTERS PUNCHED BELOW PROVIDE AN ADEQUATE
/ DELAY ONLY FOR 110 BAUD TELETYPEWRITERS. HIGHER SPEED LISTING
/ DEVICES WILL REQUIRE MORE FILLERS.
/
/ PUNCH 2 NULLS FOLLOWING A HORIZONTAL TAB.
/ (RUBOUT'S COULD HAVE BEEN USED INSTEAD.
/ THEY ARE QUIETER ON A TELETYPE, BUT
/ NULLS SAVE WEAR AND TEAR ON THE PUNCH).
/
PPHTAB	LAW	-2		/THIS INSTRUCTION IS USED ELSEWHERE
	JMP	PPNULP		/AS A LITERAL.
/
/ PUNCH 2 NULLS FOLLOWING A VERTICAL TAB.
/
PPVTAB=PPHTAB
/
/ PUNCH 10 DECIMAL NULLS FOLLOWING A FORM FEED.
/
	.DEC
PPFORM	LAW	-10
	.OCT
PPNULP	JMS	PPPNUL		/PUNCH SPECIFIED # OF NULLS.
				/RETURN IF TASK IS NOT ABORTED.
				/(ASSUME ALL ACTIVE
				/REGISTERS ARE ALTERED).
	JMP	PPWPCK		/FETCH NEXT CHARACTER.
	.TITLE	***   IMAGE ASCII (MODE 3)
/
/ PUNCH AN IMAGE ASCII RECORD: NO HEADER WORD
/ PAIR, NO CHECKSUM, BLOCK BODY OF DATA WORDS
/ (8-BIT FRAMES AS SPECIFIED BY THE REQUESTOR;
/ NO HANDLER-COMPUTED PARITY), NO BLANK
/ TAPE FRAME BETWEEN RECORDS.
/
PPMDE3	LAC	PPDPTR		/SET THE XR WITH THE DATA POINTER ADDRESS.
	JMS	PPADJX
	LAC	0,X		/GET DATA WORD.
	JMS	PPUNCH		/PUNCH CONTENTS OF THE AC.
				/RETURN IF TASK IS NOT ABORTED.
				/(ALL ACTIVE REGISTERS ALTERED).
	IDX	PPDPTR		/ADD 1 TO DATA POINTER.
	ISZ	PP.WC		/END OF BUFFER?
	JMP	PPMDE3		/NOT YET.
	JMP	PPRQOC		/YES -- REQUEST OPERATION COMPLETED.
	.TITLE	*** CLOSE
/
/ CLOSE THE "FILE".  ALTHOUGH PAPER TAPE IS NOT A DIRECTORY-ORIENTED
/ MEDIUM, THE CLOSE COMMAND IS USED TO WRITE AN END-OF-FILE ON THE TAPE
/ FOR IOPS BINARY OR IOPS ASCII.
/
/ IF THE DATA MODE IS IOPS BINARY, AN END-OF-FILE RECORD CAN BE WRITTEN
/ SINCE IOPS BINARY INCLUDES A HEADER WORD PAIR.
/
/ FOR IOPS ASCII, NO HEADER IS PUNCHED ON THE TAPE. SINCE IT IS NOT
/ DESIRABLE TO EQUATE THE PHYSICAL END OF TAPE WITH THE END-OF-FILE
/ (OR END-OF-TRANSMISSION), A CODE (04) [ASCII "CONTROL D"] IS PUNCHED.
/
PPCLOS	LAC	PPLMOD		/WHAT WAS THE DATA
	SZA			/MODE USED FOR THE
				/LAST WRITE COMMAND?
	JMP	PPCD04		/NOT IOPS BINARY.
/
/ PUNCH AN END-OF-FILE RECORD: 001005 (TO INDICATE 1 WORD PAIR AND END-
/ OF-FILE), 776773 AS THE CHECKSUM WORD.  EACH TAPE FRAME MUST BE PUNCHED
/ IN ODD PARITY WITH BIT 8=1.
/
	AAC	+200		/PUNCH THE CHARACTER IN THE AC
	JMS	PPUNCH		/(ALL ACTIVE REGISTERS ARE ALTERED).
	LAC	(310)		/RETURN IF THE TASK IS NOT ABORTED.
	JMS	PPUNCH
	LAC	(205)
	JMS	PPUNCH
	LAC	(277)
	JMS	PPUNCH
	LAC	(367)
	JMS	PPUNCH
	LAC	(373)
	JMS	PPUNCH
	JMP	PPTRLR		/PUNCH TRAILER.
/
/ IF THE DATA MODE IS IOPS ASCII, PUNCH 8 BLANK FRAMES AND THEN AN EVEN
/ PARITY 04.
/
PPCD04	AAC	-2		/IOPS ASCII?
	SZA
	JMP	PPTRLR		/NO -- PUNCH TRAILER.
	LAW	-10		/YES -- PUNCH 8 NULL TAPE FRAMES.
	JMS	PPPNUL		/(ALL ACTIVE REGISTERS ALTERED).
	LAC	(204)		/RETURN IF THE TASK IS NOT ABORTED.
	JMS	PPUNCH		/(ALL ACTIVE REGISTERS ALTERED).
/
	.EJECT
/ PUNCH 2 FANFOLDS OF BLANK TAPE TO FORM A TRAILER.
/
	.DEC
PPTRLR	LAW	-170		/85 DECIMAL FRAMES PER FANFOLD.
	.OCT
	JMS	PPPNUL		/PUNCH SPECIFIED # OF NULLS. (ASSUME ALL
				/ACTIVE REGISTERS ARE ALTERED).
				/RETURN IF THE TASK IS NOT ABORTED.
	DZM	PPLEAD		/SET FLAG TO 0 TO CAUSE 2 FANFOLDS OF
				/LEADER TAPE TO BE PUNCHED PRIOR TO THE
				/NEXT WRITE.
				/REQUEST OPERATION COMPLETED.
	.TITLE *** REQUEST COMPLETED
/
/ REQUEST OPERATION COMPLETED.
/
PPRQOC	CLA!IAC			/+1 MEANS SUCCESSFUL COMPLETION.
/
/ SET THE REQUESTOR'S EVENT VARIABLE (IF ANY). IF AN ERROR OCCURRED,
/ THE ERROR CODE IS IN THE AC AND ENTRY IS AT THIS LOCATION. THE
/ HINF FUNCTION TRANSFERS HERE WITH THE HINF CODE IN THE AC.
/
PPSREV	PAL			/SAVE VALUE TEMPORARILY.
	LAC	PPRQND		/ADDRESS OF THE I/O REQUEST NODE.
	DAC*	(R2)
	JMS*	(IOCD)		/DECLARE I/O COMPLETED BY DECREMENTING
				/THE COUNT OF PENDING I/O TRANSFERS TO
				/OR FROM THE TASK'S PARTITION (FOR A
				/NORMAL MODE TASK ONLY).
				/(R5, XR & AC ARE ALTERED).
	LAC	PPRQEV		/DID THE REQUESTOR SPECIFY
	SNA			/AN EVENT VARIABLE ADDRESS?
	JMP	PPNOEV		/NO.
	JMS	PPADJX		/YES.
	PLA
	DAC	0,X		/SET THE EVENT VARIABLE.
/
/ DECLARE A SIGNIFICANT EVENT BY POSTING AN API LEVEL 6 INTERRUPT.
/
PPNOEV	LAC	(401000)
	ISA
/
/ RETURN THE I/O REQUEST NODE TO THE POOL OF EMPTY NODES.
/
	LAC	(POOL)		/ADDRESS OF THE HEAD OF THE
	DAC*	(R1)		/EMPTY POOL.
	LAC	PPRQND		/ADDRESS OF THE NODE TO 
	DAC*	(R2)		/BE RETURNED.
	JMS*	(NADD)		/ADD THE NODE TO THE POOL.
				/(R1, R2, R6, XR & AC ARE ALTERED).
	JMP	PPPICK		/PICK ANOTHER I/O REQUEST
				/(IF ANY) FROM THE QUEUE.
/
PPIMDE	LAW	-7		/ILLEGAL DATA MODE.
	JMP	PPSREV
PPIWPC	LAW	-16		/ILLEGAL WORD-PAIR-COUNT IN THE
	JMP	PPSREV		/REQUESTOR'S LINE BUFFER HEADER.
PPXPER	LAW	-30		/I/O PARAMETER EXCEEDS PARTITION BOUNDS.
	JMP	PPSREV
	.TITLE *** INTERRUPT SERVICE
/
/ PAPER TAPE PUNCH INTERRUPT SERVICE ROUTINE.
/
/ THE PUNCH IS ON PROGRAM INTERRUPT ONLY, NOT API.  HOWEVER, THE
/ EXECUTIVE CONVERTS THE PUNCH FLAG INTERRUPT INTO A SIMULATED API 
/ INTERRUPT.  THIS LOCATION IS ENTERED AT API LEVEL 3 BY THE "JMS* (PP.INT)"
/ INSTRUCTION IN PSEUDO-API CHANNEL 42.  THE "CONNECT" WAS PERFORMED IN
/ PP'S INITIALIZATION ROUTINE.
/
PP.INT	0
	DBA			/ENTER PAGE ADDRESSING MODE.
	DAC	PP.AC		/SAVE THE AC.
	PCF			/CLEAR THE PUNCH FLAG AND
				/THE PUNCH BUFFER.
	LAC	(401000)	/SET PP'S EVENT VARIABLE
	DAC	PP.EV		/NON-0 AND DECLARE A
	ISA			/SIGNIFICANT EVENT BY
				/POSTING AN API LEVEL 6
				/INTERRUPT.
	LAC	PP.AC		/RESTORE THE AC.
	DBR			/DEBREAK AND RESTORE.
	JMP*	PP.INT		/RETURN TO INTERRUPTED LOCATION.
	.TITLE *** MISCELLANEOUS
/
/ SUBROUTINE PP.PAR -- A 7-BIT CHARACTER IS IN PPCHAR.  COMPUTE ITS 
/ PARITY AND LEAVE THE RESULT IN THE LINK.
/
/ CALLING SEQUENCE:
/
/	JMS	PP.PAR
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	LINK, AC & PP.CNT
/
PP.PAR	0
	LAW	-7		/COUNTER FOR 7 BITS.
	DAC	PP.CNT
	LAC	PPCHAR
	CLL
	RAR
	SPA
	CML
	ISZ	PP.CNT
	JMP	.-4
	JMP*	PP.PAR
/
/ SUBROUTINE PPPNUL -- PUNCH A NUMBER OF NULL (0) CHARACTERS ON THE TAPE.
/
/ CALLING SEQUENCE:
/
/	-# OF NULLS TO BE
/	PUNCHED IN THE AC
/	JMS	PPPNUL
/	(RETURN, UNLESS THE TASK IS ABORTED)
/
/ ALTERED REGISTERS:
/
/	ASSUME ALL ACTIVE REGISTERS
/	ARE ALTERED DUE TO
/	THE CAL TO THE MONITOR.
/	ALSO, PP.CNT IS ALTERED.
/
PPPNUL	0
	DAC	PP.CNT
PPPNLP	CLA			/PUNCH A NULL TAPE FRAME & RETURN WHEN DONE,
	JMS	PPUNCH		/UNLESS TASK IS ABORTED.
				/(ASSUME ALL ACTIVE REGISTERS ARE ALTERED).
	ISZ	PP.CNT
	JMP	PPPNLP		/MORE TO GO.
	JMP*	PPPNUL
/
	.EJECT
/ SUBROUTINE PPUNCH -- PUNCH THE 8-BIT CHARACTER SPECIFIED IN THE AC.
/ FIRST, HOWEVER, MAKE SURE THAT THERE IS TAPE IN THE PUNCH.
/
/ CALLING SEQUENCE:
/
/	CHARACTER IN AC BITS 10 THRU 17
/	JMS	PPUNCH
/	(RETURN, UNLESS THE TASK IS ABORTED)
/
/ ALTERED REGISTERS:
/
/	ASSUME ALL ACTIVE REGISTERS ARE 
/	ALTERED DUE TO THE CAL TO THE
/	MONITOR.
/
PPUNCH	0
	DAC	PPUNTP		/SAVE TEMPORARILY.
/
/ IS THE PUNCH OUT OF TAPE?
/
PPTPCK	IORS			/BIT 9 OF THE IORS WORD
	SWHA			/WILL BE 1 IF THE
	SMA			/PUNCH IS OUT OF TAPE.
	JMP	PPTPOK		/O.K. -- HAS TAPE.
/
/ THE PUNCH IS OUT OF TAPE.  PRINT A MESSAGE TO THAT EFFECT ON THE
/ MCR TTY (LUN 3).
/
	CAL	PPTYPE		/TYPE MESSAGE AND
	CAL	PPWFEV		/WAIT FOR COMPLETION.
	JMS	PPABRT		/CHECK IF AN 'ABORT' REQUEST HAS BEEN
				/QUEUED. IF SO, PERFORM I/O RUNDOWN.
				/CONTROL WILL NOT RETURN IF THE I/O IN
				/PROGRESS WAS INITIATED BY THE ABORTED TASK.
/
/ SUSPEND TASK EXECUTION.  THE OPERATOR MUST REQUEST TASK RESUMPTION
/ AFTER HE HAS RELOADED THE PUNCH.
/
	CAL	(6)		/"SUSPEND" PP TASK.
				/CONTROL WILL RESUME
				/FOLLOWING THIS CAL.
	JMS	PPABRT		/CHECK IF AN 'ABORT' REQUEST HAS BEEN
				/QUEUED. IF SO, PERFORM I/O RUNDOWN.
				/CONTROL WILL NOT RETURN IF THE I/O IN
				/PROGRESS WAS INITIATED BY THE ABORTED TASK.
/
	JMP	PPTPCK		/RECHECK THE PUNCH STATUS.
/
/ THE PUNCH HAS TAPE.
/
PPTPOK	DZM	PP.EV		/CLEAR THE EVENT VARIABLE.
	LAC	PPUNTP		/GET 8-BIT CHARACTER AND
	PSA			/PUNCH A TAPE FRAME
				/IN ALPHANUMERIC MODE.
	CAL	PPWFEV		/WAIT FOR COMPLETION.
	JMS	PPABRT		/CHECK IF AN 'ABORT' REQUEST HAS BEEN
				/QUEUED. IF SO, PERFORM I/O RUNDOWN.
				/CONTROL WILL NOT RETURN IF THE I/O IN
				/PROGRESS WAS INITIATED BY THE ABORTED TASK.
	JMP*	PPUNCH
/
/ SUBROUTINE PPABRT -- CALLED AFTER TASK HAS 'RESUMED' EXECUTION FOLLOW-
/ ING A 'SUSPEND' OR AFTER COMPLETION OF A PUNCH OPERATION TO CHECK IF AN
/ ABORT NODE HAS BEEN PLACED IN THE I/O REQUEST QUEUE. IF SO, I/O RUNDOWN
/ IS PERFORMED. IF THE TASK BEING ABORTED IS NOT THE ONE FOR WHICH I/O
/ IS UNDER WAY, CONTROL WILL RETURN TO THE CALLER. OTHERWISE, THE I/O
/ UNDER WAY IS ALSO ABORTED AND CONTROL PASSES TO THE 'OPERATION COMPLETED'
/ CODE.
/
/ CALLING SEQUENCE:
/
/	JMS	PPABRT
/	(CONDITIONAL RETURN -- SEE ABOVE)
/
/ ALTERED REGISTERS:
/
/	EFFECTIVELY ALL (FOR SIMPLICITY)
/
PPABRT	0
	LAC	PPTGEV		/EXAMINE BIT 2 IN THE TRIGGER EVENT
	RTL			/VARIABLE TO SEE IF AN ABORT REQUEST
	SMA			/HAS BEEN QUEUED.
	JMP*	PPABRT		/NO -- RETURN.
/
/ DE-QUEUE THE ABORT REQUEST.
/
	DZM	PPTGEV		/CLEAR THE TRIGGER.
	LAC	PPPDNA		/ADDRESS OF THE PDVL NODE.
	DAC*	(R1)
	JMS*	(DQRQ)		/DE-QUEUE I/O REQUEST.
				/(R1, R2, R4, R5, R6, XR & AC ARE ALTERED).
				/WAS A REQUEST FOUND?
	JMP	PP.TW		/NO -- SHOULD NEVER COME HERE.
	DAC	PPABNA		/YES -- SAVE THE ABORT NODE ADDRESS.
	DAC*	(R2)
	LAC	PPPDNA		/PHYSICAL DEVICE NODE ADDRESS.
	DAC*	(R1)
	JMS*	(DMTQ)		/DETACH LUN & DEVICE, IF NECESSARY, AND
				/THEN EMPTY THE REQUEST QUEUE OF ALL I/O
				/REQUESTS MADE BY THE TASK BEING ABORTED.
				/(R1, R2, R3, R5, R6, X10, X11, X12,
				/XR & AC ARE ALTERED).
/
/ SAVE PARAMETERS FROM THE ABORT NODE.
/
	LAC	PPABNA		/SET THE XR WITH THE ABORT NODE ADDRESS.
	JMS	PPADJX
	LAC	6,X		/SAVE THE I/O RUNDOWN TASK'S EVENT
	DAC	PPRDEV		/VARIABLE ADDRESS.
	LAC	2,X		/SAVE THE STL NODE ADDRESS OF THE TASK
	DAC	PPABSN		/BEING ABORTED.
/
/ DECREMENT THE 'TRANSFERS PENDING' COUNT.
/
	LAC	PPABNA		/ADDRESS OF THE ABORT REQUEST NODE.
	DAC*	(R2)
	JMS*	(IOCD)		/(R5, XR & AC ARE ALTERED).
/
/ RETURN THE ABORT NODE TO THE EMPTY POOL. THE ABORT NODE ADDRESS
/ SHOULD STILL BE IN 'R2'.
/
	LAC	(POOL)		/ADDRESS OF THE EMPTY POOL LISTHEAD.
	DAC*	(R1)
	JMS*	(NADD)		/ADD NODE TO DEQUE.
				/(R1, R2, R6, XR & AC ARE ALTERED).
/
/ IS THE TASK BEING ABORTED THE ONE FOR WHICH I/O IS UNDER WAY?
/
	LAC	PPABSN
	SAD	PPIOSN
	JMP	PPSUBS		/YES.
	LAC	PPRDEV		/NO -- SET THE XR WITH THE I/O RUNDOWN
	JMS	PPADJX		/TASK'S EVENT VARIABLE ADDRESS.
	CLA!IAC			/SET THE VARIABLE.
	DAC	0,X
	JMP*	PPABRT		/CONTINUE I/O.
/
/ CLEAN UP BUT DON'T RETURN FROM THIS SUBROUTINE SINCE THE I/O IN PRO-
/ GRESS IS HEREBY CANCELLED.
/
PPSUBS	DZM	PPLEAD		/INITIALIZE THE "PUNCH 2 FANFOLDS OF
				/LEADER" FLAG.
	LAC	PPRDEV		/SUBSTITUTE THE I/O RUNDOWN TASK'S EVENT
	DAC	PPRQEV		/VARIABLE FOR THAT OF THE TASK BEING
	JMP	PPRQOC		/ABORTED, AND THEN EXIT TO THE 'I/O COM-
				/PLETED' CODE.
/
	.EJECT
/ SUBROUTINE PPADJX -- ADD THE INDEX REGISTER ADJUSTMENT FACTOR TO THE
/ AC AND STORE THE RESULT IN THE XR.
/
/ CALLING SEQUENCE:
/
/	VALUE IN THE AC
/	JMS	PPADJX
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	XR & AC
/
PPADJX	0
	TAD	PPXADJ
	PAX
	JMP*	PPADJX
/
/ VARIABLES.
/
PPTGEV	0			/PP'S TRIGGER EVENT VARIABLE.
PPWSTL	0			/STL NODE ADDRESS OF THE LAST TASK TO
				/WRITE TO THE PUNCH.
PPLEAD	0			/0 MEANS:  PUNCH 2 FANFOLDS
				/OF LEADER PRIOR TO THE
				/NEXT WRITE COMMAND.
PPLMOD	0			/THE LAST DATA MODE USED
				/IN A WRITE COMMAND --
				/EXAMINED BY THE CLOSE FUNCTION.
/
/ CAL PARAMETER BLOCKS.
/
PPWFTG	20			/"WAITFOR"
	PPTGEV			/TRIGGER EVENT VARIABLE.
/
PPWFEV	20			/"WAITFOR"
	PP.EV			/EVENT VARIABLE.
/
/ "CONNECT" AND "DISCONNECT" CPB. INITIALLY THIS
/ IS USED FOR "CONNECT". THEN THE 11 IS CHANGED
/ TO A 12 AND THE EVENT VARIABLE ADDRESS IS
/ SET TO ZERO IN PREPARATION FOR A "DISCONNECT".
/
PPCNCT	11			/11=CONNECT; 12=DISCONNECT.
	PP.EV			/EVENT VARIABLE ADDRESS (0 FOR DISCONNECT).
	42			/INTERRUPT LINE #42.
	PP.INT			/ENTRY POINT TO INTERRUPT SERVICE.
/
PPTYPE	2700			/OUTPUT (WRITE) CODE.
	PP.EV			/EVENT VARIABLE ADDRESS.
	LUN
	2			/IOPS ASCII.
	PPMESG			/MESSAGE ADDRESS.
/
PPMESG	12002
	0
	.ASCII	/*** LOAD PAPER PUNCH. THEN, "RESUME PP...."/<15>
/
	.END	PPINIT
