	.TITLE LPA.
/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/LPA.
/LPA.=IOPS LINE PRINTER (647) HANDLER.
/647 WITHOUT API
/M. SIFNAS /J.J. MURPHY, JR.
/6-2-69.
/CALLING SEQUENCE:
	/CAL+.DAT SLOT (9-17)
	/FUNCTION
	/N ARGUMENTS, WHERE N IS A FUNCTION OF FUNCTION.
	/NORMAL RETURN
LSDF=706501	/SKIP ON DONE FLAG -CONNECTED TO INTERRUPT
LPCB=706502	/CLEAR DONE FLAG, CLEAR PRINTER BUFFER,
		/SET DONE FLAG
LPL1=706566	/LOAD PRINTER BUFFER 1 CHAR (AC 12-17)
LPL2=706526	/LOAD PRINTER BUFFER 2 CHAR (AC 6-11, 12-17)
LPLD=706546	/LOAD PRINTER BUFFER 3 CHAR (AC 0-5,6-11,12-8)
LSEF=706601	/SKIP ON ERROR FLAG -NOT CONNECTED TO
		/INTERRUPT
LPCF=706602	/CLEAR DONE FLAG
LPPB=706606	/CLEAR DONE FLAG, SELECT PRINTER,
		/PRINT BUFFER, CLEAR BUFFER, SET DONE FLAG
LPLS=706626	/LOAD SPACING BUFFER (AC 15-17), SPACE
		/SET DONE FLAG
.MED=3
	.GLOBL LPA.
LPA.	DAC LPCALP		/SAVE CAL POINTER
	DAC LPARGP		/AND ARGUMENT POINTER.
	ISZ LPARGP		/POINTS TO FUNCTION CODE.
/DISPATCH TO FUNCTION
	LAC* LPARGP
	ISZ LPARGP		/POINTS TO 3RD WORD OF CALLING SEQUENCE.
	TAD (JMP LTABL-1
	DAC .+1
	HLT
LTABL	JMP LPIN		/1  .INIT
	SKP		/2 .IODR---IGNORED.
	JMP LPER06		/3 .SEEK --- ERROR
	ISZ LPARGP		/4.  .ENTER---IGNORED
	JMP LPNOR		/5  .CLEAR---IGNORED
	JMP LPCLOS		/6  .CLOSE
LPILPR	JMP LPNOR		/7  .MTAPE---IGNORED
	JMP LPER06		/10 .READ---ERROR
	JMP LPWRT		/11 .WRITE
	JMP LPWATR		/12 .WAIT OR .WAITR
LPER06	LAW 6		/ILLEGAL FUNCTIONS /13  .TRAN. ---ERROR
	JMP* (.MED+1
LPWATR	LAW 1000
	AND* LPCALP
	SNA
	JMP LPWAIT	/.WAIT
	LAC LPCALP	/.WAITR
	AND (700000	/L,EX,MP
	DAC LPCALP
	LAC* LPARGP
	AND (77777	/BUSY ADDR
	XOR LPCALP
	DAC LPCALP
	ISZ LPARGP	/TO NOT BUSY
/.WAIT LPT ROUTINE.
LPWAIT	JMS LPCKUN
	JMP  LPNOR
/.CLOSE LPT ROUTINE
LPCLOS	JMS LPCKUN		/CHECK IF I/O UNDERWAY
	ISZ LPCLS1		/777777 IN AC.
	JMP LPDZMC			/.CLOSE JUST COMPLETED.
	DAC LPUND			/SET BUSY INDICATOR
	DZM LV2WC		/FORM FEED.
	DZM PGECNT	/INITIALIZE #LINES/PAGE COUNTER
	LPLS		/WAIT ON .CLOSE FOR
LPCALX	DBR
	XCT .+1
	JMP* LPCALP		/COMPLETION OF FORM FEED.
LPCLS1	777777		/777777=.CLOSE NOT DONE.
/INIT LPT ROUTINE.
LPIN	CLA!CMA
	DAC LV2WC
	DAC LPUND
	DAC LPCLS1		/INITIALIZE .CLOSE INDICATOR
	DAC LV2FC		/SET UP FOR FORM FEED ON INTERRUPT FROM LPCB.
	ISZ LPARGP
	LAC (64		/52 (DECIMAL)---RETURN
	DAC* LPARGP		/STANDARD LINE BUFFER SIZE TO USER.
	ISZ LPARGP
LPIN2	CAL	56	/CHANNEL REG. 56 - ONCE ONLY CODE.
LP57T	16		/.SETUP - THESE 6 REGISTERS ARE OVERLAYED.
	LSDF
	LPINT
LPWORD	LAC .+2
LPHRTB	DAC LPIN2
LP3CHR	JMP .+1
	JMS LPNRDY		/CHECK IF DEVICE READY.
	LAW 17775		/INITIALIZE 6-BIT
	DAC LP3CHR	/CHAR. COUNTER
	DZM LPWORD	/AND ACCUMULATOR.
	LPCB		/CLEAR PRINTER BUFFER.
/
/NORMAL EXIT ROUTINE
LPNOR	DBR
	XCT .+1
	JMP* LPARGP	/EXIT
LPNRDY	0
	LSEF
	JMP* LPNRDY		/DEVICE READY.
	LAC (LPNRDY+1	/INDICATE DEVICE NOT READY VIA .MED,
	DAC* (.MED		/RETURN TO LSEF INSTRUCTION ON ^R
	LAC (4		/TO RE-CHECK READY CONDITION.
	JMP* (.MED+1
LPDZMC	DAC LPCLS1		/INITIALIZE .CLOSE INDICATOR
	JMP LPNOR
/WRITE LPT ROUTINE.
LPWRT	JMS LPCKUN		/IS I/O UNDERWAY
	DAC LPUND		/NO
	DAC LP5CH		/INIT BEFORE CALL TO .LPCONV
	LAC LPLPLD		/LPLD
	DAC LV2XIT
	LAW 7000
	AND* LPCALP		/DATA MODE BITS 6-8
	SAD (2000
	JMP .+3		/IOPS ASCII
	LAW 7		/ILLEGAL DATA MODE.
	JMP* (.MED+1
	LAC* LPARGP	/L.B.H. POINTER IN USER'S AREA
	DAC LPLBHP
	ISZ LPARGP
	ISZ LPARGP		/POINTS TO RETURN ADDRESS.
	LAC* LPLBHP	/WPC
	AND (377000
	DAC LPWPC
	ISZ LPLBHP	/MOVE L.B. POINTER (IN USER'S
	ISZ LPLBHP	/AREA) TO 1ST DATA WORD.
	DZM LV2FC	/IOPS ASCII MODE NO FORM CONTROL
	LAW 17770		/INITIALIZE SWITCH AT LPCONV
	DAC LPCONV
	/THIS ROUTINE GETS THE
	/NEXT 7-BIT ASCII CHAR.
	/FROM THE 5/7 LINE BUFFER (USER'S AREA)
	/IT RETURNS WITH IT RIGHT
	/JUSTIFIED IN AN OTHERWISE
	/CLEAR AC.
	/LP5CH MUST BE SET TO
	/777777 BEFORE THE INITIAL
	/CALL TO LPCONV, LPWPC TO WPC INCLUDING HEADER.
	/LPLBHP TO 1ST DATA WORD IN L.B.(USER'S AREA)
LPCONV	LAW 17770		/INITIALIZATION
	DAC LP8CT		/FOR
	LAC (SAD LPCTAB	/CONTROL CHAR.
	DAC LPVTST		/SCANNING.
	ISZ LP5CH		/MODIFIED FOR HOR. TAB.
	JMP LPGET5	/THIS 5/7 PAIR NOT EXHAUSTED.
	LAW 17000
	TAD LPWPC
	DAC LPWPC		/SKIP ON NON 0.
	SNA!SPA
	JMP LPEND	/WORD PAIRS EXHAUSTED
	LAC* LPLBHP	/PICK UP NEXT
	DAC LP57T	/WORD PAIR
	ISZ LPLBHP
	LAC* LPLBHP
	DAC LP57T+1
	ISZ LPLBHP
	LAW 17773	/RESET CHAR. COUNTER
	DAC LP5CH	/FOR THIS WORD PAIR
LPGET5	LAW 17770
	DAC LP57T+2	/GO THROUGH SHIFT LOOP 7 1/2 TIMES.
LPGET6	LAC LP57T+1
	RAL
	ISZ LP57T+2
	JMP .+3
	AND (177	/GOT CHARACTER.
	JMP LPCON1
	DAC LP57T+1
	LAC LP57T
	RAL
	DAC LP57T
	JMP LPGET6
LPCON1	SAD (177
	JMP LPCONV	/DELETE RUBOUTS.
	TAD LPM40		/-40
	SPA
	JMP LPVTST	/CHAR. <40---CONTROL CHAR.
	SAD (135
	JMP LPEMPT	/ALTMODE
	TAD (777700	/-100
	SPA
	TAD (40
	TAD (100	/140-176 MAPPED INTO 100-136
LPCON2	AND (77	/6-BIT TRIMMED.
	XOR LPWORD	/CONSTRUCT 3/6 WORD.
	ISZ LP3CHR	/3 CHARACTER COUNTER.
	JMP LPCON3
	DAC LPWORD
	LAW 17775		/INITIALIZE 6-BIT
	DAC LP3CHR	/CHAR. COUNTER
	LAC LPWORD	/AND ACCUMULATOR
	DZM LPWORD
			/DATA WORD COMPLETE.
	ISZ LV2WC	/INDEX DATA WORD COUNT
LV2XIT	LPLD		/LPLD OR JMP LPFBUF
	DBR
	XCT .+1
	JMP* LPARGP
LPCON3	RTL	/SHIFT CHARS. LEFT
	RTL
	RTL
	AND (777700	/IN CASE LINK WAS ON.
	DAC LPWORD
	JMP LPCONV	/GET NEXT CHAR.
/END OF CHARACTER STRING OR CARR. RETURN (IOPS ASCII)
LPEND	LAC (47
	DAC LV2WC
	JMP LPHT3		/PAD LAST WORD WITH SPACES.
	/CONTROL CHARACTER ROUTINE. - CHAR. IN AC.
LPVTST	XX	/SAD LPCTAB-SAD LPCTAB+7
	JMP LPFORM	/VERTICAL FORM CONTROL CHAR.
	ISZ LPVTST	/SAD LPCTAB+N-SAD LPCTAB+N+1
	ISZ LP8CT
	JMP LPVTST
	SAD LPCTAB+10
	JMP LPEND	/CARRIAGE RETURN.
	SAD LPCTAB+11
	JMP LPHT	/HORIZONTAL TAB.
	JMP LPCONV	/DELETE MEANINGLESS CHAR.
	/COMPUTE FORM CONTROL CODE AND PLACE
	/IN LV2FC
LPFORM	LAC LP8CT
	DAC LV2FC	/L.B.H. IN D.B.
	JMP LPCONV
/CONVERT HOR. TAB TO N SPACES, WHERE N IS THE NUMBER
/NECESSARY TO HAVE THE NEXT CHAR. IN COLUMN 11,21,31,41,51...,111.
LPHT	LAC LV2WC	/DATA WORD COUNT
	CLL!RAL	/X2
	TAD LV2WC	/X3
	TAD (4
	TAD LP3CHR	/CURRENT WORD CHAR. COUNTER.
	TAD (777766	/-10 (DECIMAL)
	SMA!SZA
	JMP .-2
	TAD LPOVRP
LPHT3	DAC LPHRTB
	LAC (JMP LPHT2
	DAC LPCONV
LPHT2	LAW 40
	ISZ LPHRTB
	JMP LPCON2
	LAW 17770
	DAC LPCONV
	JMP LPCONV
	/INTERRUPT HANDLER.
LPEMPT	DZM LPUND		/CLEAR I/O UNDERWAY INDICATOR.
	LAC LV2XIT	/DETERMINE
	SAD LPLPLD	/WAY
	JMP LPNOR		/OUT.
LPDSMS	LAC LPSVAC	/RESTORE AC
LPSWCH	ION		/ION OR IOF.
	DBR
	XCT .+1
	JMP* LPTOUT
LPPIC	DAC LPSVAC		/SAVE AC
	LAC* (0
	DAC LPTOUT		/SAVE PC, L, EM, MP
	LAC LPION
	JMP LPSTON
LPINT	JMP LPPIC		/PIC ENTRY.
	DAC LPSVAC		/API ENTRY, SAVE AC.
	LAC LPINT		/PC, L, EM, MP
	DAC LPTOUT
	IORS		/READ I/O STATUS
	SMA!CLA
LPM40	LAW 17740		/PIC OFF -- BUILD IOF
	TAD LPION		/PIC ON -- ION
LPSTON	DAC LPSWCH
	LPCF		/CLEAR LPT DONE FLAG
LPION	ION		/ENABLE PIC
	LAC LPIDSM
	DAC LV2XIT
	JMS LPNRDY		/CHECK FOR DEVICE NOT READY.
LPTOK	LAC LV2WC
	SNA
	JMP LPEMPT
	SPA
	JMP LPCLSE
	SAD (50		/BUFFER FULL.
	JMP LPSPPR
	JMP LPCONV
LPIDSM	JMP LPFBUF
LPCLSE	DZM LV2WC
LPSPPR	LAW 17706	/IS PAGE FULL?
	TAD PGECNT
	SZA!CMA		/YES - FORM FEED
	LAC LV2FC
	SAD LPOVRP
	JMP LPIOT		/OVERPRINT.
	AND (7
	SAD (7
	DZM PGECNT	/INIT #LINES/PAGE CNT
LPVMOV	IOF
	LPLS		/VERT. SPACING BEFORE PRINTING.
LPOVRP	LAW 17776
	DAC LV2FC
	JMP LPDSMS
	/WORD COUNT EXHAUSTED.
LPIOT	DZM LV2WC
	ISZ PGECNT	/INCREMENT #LINES/PAGE CNT
	IOF
	LPPB	/PRINT BUFFER.
	JMP LPDSMS
LPFBUF	IOF
LPLPLD	LPLD		/PLACE IN LPT BUFFER
	JMP LPDSMS
/SUBROUTINE TO CHECK IF I/O UNDERWAY.
LPCKUN	0
	LAC LPUND
	SMA!CLA!CMA
	JMP* LPCKUN		/I/O NOT UNDERWAY
	JMP LPCALX
LPCALP	0		/CAL POINTER WITH L, EM, MP.
LPARGP	0		/NORMAL RETURN POINTER WITH L, EM, MP.
/REGISTERS USED AT LEVEL 2.
LPLBHP	0	/L.B.H. POINTER (IN USER'S AREA)
LPWPC	0	/W.P.C. ( INCLUDING HEADER)
LP5CH	0	/5/7 COUNTER.
LP8CT	0		/8 VERTICAL FORM CONTROLS.
LV2WC	0	/DATA WORD COUNT.
LPSVAC	0	/SAVED AC ON INTERRUPT
LPTOUT	0	/DISMISS ADDRESS
LV2FC	0	/FORM CONTROL (15-17)
LPUND	0	/I/O UNDERWAY INDICATOR (777777=UNDERWAY)
PGECNT	0	/INITIALIZED TO 0 WHEN AT TOP OF FORM
		/INCREMENTED BY 1 UNTIL 58(10) LINES
		/  HAVE BEEN OUTPUT OR FORM FEED IS ENCOUNTERED
	/TABLE OF ASCII CONTROL CHAR'S SCANNED BY LPT IN IOPS ASCII MODE
LPCTAB	777752	/LF-EVERY LINE 0	---12
	777761	/DC1-EVERY 2ND LINE 1	---21
	777762	/DC2-EVERY 3RD LINE 2 	---22
	777753	/VT-EVERY 6TH LINE 3	---13
	777763	/DC3-EVERY 10TH LINE 4	---23
	777764	/DC4-EVERY 20TH LINE 5	---24
	777760	/DLE-OVER PRINT 6	---20
	777754	/FF-TOP ON NEXT FORM 7	---14
	777755	/CR		---15
	777751	/HT		---11
	.END
