	.SYSID <	.TITLE LPU. >,< 124>

/

/COPYRIGHT (C) 1975

/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

/

/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY

/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH

/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS

/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-

/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO

/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE

/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

/

/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE

/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-

/MITMENT BY DIGITAL EQUIPMENT CORPORATION.

/

/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY

/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

	.EJECT

/

/ EDIT LEGENG.

/

/ 120	05-JUN-75 (RCHM)	MAKE XVM CHANGES.

/ 121	05-JUN-75 (RCHM)	TAKE OUT NON-ESSENTIAL CONDITIONALS.

/ 122	22-JUL-75 (RCHM)	TEST STATE OF UC15 ENABLED BIT.
/ 123	29-SEP-75 (SCR)		MODIFY EDIT 122
/ 124	10/3/75 (SCR)		CLOSE IS MINUS HEADER, NOT 6414 DATA
/				MAKE LPU. CONSISTENT WITH LPA.15

/

	.EJECT

/J.M. WOLFBERG	(S. ROOT)

/LPU.--IOPS LINE PRINTER HANDLER FOR LP11 LINE PRINTER

/CALLING SEQUENCE:

/	CAL + .DAT SLOT (9-17)

/	FUNCTION

/	N ARGS, WHERE N IS A FUNCTION OF "FUNCTION"

/	NORMAL RETURN

/BITS 12-13 OF .SCOM+4 INDICATE PRINTER.

/	00= UNDEFINED.

/	01= 80 COLUMNS.

/	10= 120 COLUMNS.

/	11= 132 COLUMNS.

/ASSEMBLY PARAMETERS:
/	NOFF=0	THIS SUPPRESSES AUTOMATIC PAGE FEED ON CLOSE ONLY!!!!
/	FFCNT DEFINES THE NUMBER OF LINES PER PAGE. TO SUPPRESS THE FORM
/		FEED COUNTER, SET FFCNT=0.
/   DEFINE FFCNT IN !!OCTAL!!
/   IF FFCNT AND NOFF BOTH UNDEF., 58 LINES PER PAGE IS DEFAULT.

/

APILVL=2

APISLT=56

/

LSSF=APILVL*20+706101

SIOA=706001			/SKIP ON DATA ACCEPTED BY THE PDP11

LIOR=706006			/CLEAR "DONE" FLAG AND LOAD REG FOR

				/    THE PDP11.

CAPI=APILVL*20+706104		/CLEAR FLAG

/

.SCOM=100

SC.MOD=.SCOM+4			/(RCHM-122) .SCOM MODE REGISTER.

SC.UC15=2			/(RCHM-122) BIT WITHIN SC.MOD TO BE TESTED.

.MED=3

IDX=ISZ

SET=ISZ				/USED TO SET SWITCHES TO NON-ZERO.

EXERRS=.SCOM+37

/

	.IFUND FFCNT

FORMS=72

	.ENDC

	.IFDEF FFCNT

FORMS=FFCNT

	.ENDC

	.IFUND NOSPL

DEVCOD=4		/CODE FOR LP DRIVER IN PIREX

	.ENDC

	.IFDEF NOSPL

DEVCOD=204		/SAME DRIVER, DISABLE SPOOLING!

	.ENDC

	.GLOBL LPA.

	.TITLE CAL ENTRANCE

LPA.	DAC	LPCALP		/SAVE CAL POINTER.

	DAC	LPARGP		/AND ARGUMENT POINTER.

	IDX	LPARGP		/POINTS TO WORD 2 - FUNCTION CODE.

/

/  FIRST TIME THRU GO CAL INIT. CODE IN LBF

/

NEW	JMP	INIT	/FIRST TIME THRU DO SETUP CAL

/			/AND SET-UP TCB AND BUFFER. OVERWRITE

/			/JUMP WITH NO-OP

/

	LAC*	LPARGP

	IDX	LPARGP		/POINTS TO WORD 3 - BUFFER ADDRESS.

	AND	(17777		/STRIP OFF UNIT NUMBER.

	TAD	(JMP LTABL-1	/DISPATCH TO PROCESS FUNCTION.

	DAC	.+1

	XX

LTABL	JMP	LPIN		/1 - .INIT

	SKP			/2 - .FSTAT,.RENAM,.DLETE - IGNORE

	JMP	LPER06		/3 - .SEEK - ERROR

	IDX	LPARGP		/4 - .ENTER - IGNORE

	JMP	LPNEXT		/5 - .CLEAR - IGNORE

	JMP	LPCLOS		/6 - .CLOSE

	JMP	LPNEXT		/7 - .MTAPE - IGNORE

	JMP	LPER06		/10 - .READ - ERROR.

	JMP	LPWRIT		/11 - .WRITE

	JMP	LPWAIT		/12 - .WAIT OR .WAITR

LPER06	LAW	6		/ILLEGAL HANDLER FUNCTION.

	JMP SETERR

IOPS67	LAW 67			/(RCHM-120) FETCH MEMORY BOUNDS ERROR MESSAGE.

	JMP SETERR		/(RCHM-120) GO PRINT ERROR.
IOPS12	LAW 12			/(RCHM-122) FETCH TERMINAL I/O ERROR MESSAGE.
	JMP SETERR		/(RCHM-122) GO PRINT ERROR.
IOPS55	LAW	55	/(SCR-123)NO TCB AREA FOR US
	JMP	SETERR
	.TITLE INTERRUPT SERVICE

/

/LPU. INTERRUPT SERVICE

LPINT	JMP	LPPIC	/PIC ENTRY, JUMP TO CODE

	DAC	LPAC	/SAVE INTERRUPTED AC

	LAC	LPINT	/GET INTERRUPTED PC

	DAC	LPOUT	/SAVE FOR COMMON EXIT

	LAC	(JMP LPPIC /RESTORE PIC ENTRY

	DAC	LPINT

	LAC	(NOP	/WE DON'T NEED ION IN COMMON EXIT

	JMP	LPICM	/JOIN COMMON CODE

/

LPPIC	DAC	LPAC	/PIC CODE, SAV AC

	LAC*	(0	/GET INTERRUPTED PC

	DAC	LPOUT	/SAVE

	LAC	(ION	/NEED INTERRUPT ON INST. IN COMMON CODE

LPICM	DAC	LPISW

	CAPI		/CLEAR FLAG, NOW IN COMMON CODE

	LAC*	LPEV	/EVENT VARIABLE FROM PIREX

	RTL		/PDP-11 (MINUS) BIT TO OUR AC0

	SPA!RTR		/+ IS OK

	JMP	LPIERR	/ERROR, GO LOOK

LPIRT	DZM	LPUND	/CLEAR UNDERWAY FLAG

LPIRT1	LAC	LPAC	/RESTORE AC

LPISW	HLT		/ION OR NOP

	DBR

	JMP*	LPOUT

/

/

LPIERR	AND	(177777	/KEEP REAL 16 BITS FROM PDP-11

	SAD	(177001	/CODE FROM OUT OF NODES IN PIREX

	JMP	RETRY	/JUST TRY AGAIN, LEAVING LPUND SET

	TAD	(600000	/MAKE - NUMBER FOR IOPS

	JMP	SETERR	/TREAT AS REGULAR IOPS ERROR

/			/NOTE THAT THIS SHOULDN'T HAPPER.

/

/

RETRY	LAC	LPTCB	/TCB ADDRESS

	SIOA

	JMP	.-1	/

	LIOR		/THIS MAGIC SHIPS TCB ADDR. TO PDP-11

	JMP	LPIRT1	/EXIT FROM INTERRUPT

/

/

	.TITLE	ERROR ROUTINE

/

SETERR	DAC ERRNUM

ERLOOP	NOP			/'JMP LPTRY' IF IOPS 4 ERROR.

	LAC ERRNUM

EROUT	JMS* (EXERRS

	JMP ERLOOP

	LAW -1

	.SIXBT 'LPU'

ERRNUM	0			/HOLDS ERROR NUMBER FOR REPEAT.

	.TITLE .INIT FUNCTION

/

/.INIT

/

LPIN	IDX LPARGP		/(SCR-123)MOVE TEST TO ONCEONLY CODE

	LAC BUFSIZ		/36(10) FOR 80 COLS; 56(10) FOR 132 COLS.

	DAC* LPARGP		/RETURN TO USER.

	IDX LPARGP		/NOW POINTS TO RETURN.

	LAC	PAGSIZ	/LF COUNTER

	DAC	PAGCNT

	LAC*	LPCALP	/DOES INIT INHIBIT AUTO FORMS FEED
	AND	(4000	/THIS IS INHIBIT BIT
	SZA			/(RCHM-123) INHIBIT OFF?
	LAC (ADD PAGCNT)	/(RCHM-124) PREPARE TO MAKE NOP.
	XOR (ISZ PAGCNT)	/(RCHM-124) OR ISZ PAGCNT IF NOT INHIBIT.

	DAC	FFSW	/THIS SWITCH XCT'ED BY FORMS CONTROL

/			/SECTION IN PUTCH SUBROUTINE

	JMS	RESETL	/RESET TAB AND LINE WIDTH COUNTERS

	JMS	LPIOCK	/CHECK LP BUSY

	DZM	COP	/SAY A FF OCCURRED

	CLA!IAC		/COUNT OF ONE BYTE FOR HEADER

	DAC*	LPBUF	/HEADER

	AAC	13	/FORM FEED

	DAC*	LPBUFD	/FOR BUFFER
	JMS	LPSET	/THIS SENDS REQ. TO PDP-11
/

/NORMAL CAL EXIT

/

LPNEXT	DBR

	JMP*	LPARGP

	.TITLE .WRITE FUNCTION

/

/.WRITE

/

LPWRIT	JMS LPIOCK		/PRINTER BUSY?

	LAC* LPCALP		/GET THE DATA MODE FROM THE USER CAL.

	AND	(1000	/MAKE SKP-NOP IN MIX

	XOR	(SKP

	DAC	MIX

	LAC*	LPARGP		/USER BUFFER ADDRESS.

	IDX LPARGP	/NOW POINTS TO WORD COUNT 

	DAC	TCHAR	/SAVE POINTER TO BUFFER HEADER

	AAC	2	/MAKE X12 POINT TO DATA NOT HEADER

	DAC	X12	/GETTER POINTER

	AND (700000)		/(RCHM-120) EXTRANC EXTEND ADDRESSING BITS FROM BUFFER ADDR3ESS.

	SZA			/(RCHM-120) ARE ANY SET?

	JMP IOPS67		/(RCHM-120) YES, ISSUE IOPS67 ERROR MESSAGE.

/

/  SET UP LIMIT OF INPUT BUFFER SIZE TO PREVENT DATA OVERRUN

/  FOR BOTH IOPS ASCII AND IMAGE ASCII

/

	LAW	17000	/GET PAIR COUNT FROM LEFT HALF

	AND*	TCHAR

	SWHA		/BRING TO RIGHT. PAIR COUNT INCLUDES HEADER

/			/PAIR COUNT. WE ISZ BEFORE LOOP SO THAT'S

/			/OK. IOPS NOW SET XCPT CMA!IAC

	XCT	MIX	/SKIP IF ASCII, NOT IF IMAGE

	SKP!CLA!CMA	/IMAGE -1 IN AC, SKIP. -1 BECAUSE WE ISZ FIRST

	SKP!CMA!IAC	/IOPS COMPLEMENTED TO CORRECT VALUE

	TAD*	LPARGP	/IMAGE ADD IN TOTAL WORD COUNT, INCL

/			/TWO WORDS FOR HEADER. WE ISZ BEFORE LOOP.

	DAC	TEMP1	/INTO CONTROLLER, BOTH MODES

	ISZ	LPARGP	/MOVE ARG POINTER TO EXIT

	LAC	LPBUFD	/POINTER TO DATA PORTION OF BUFFER

	DAC	PUTP	/LOAD TO CHARACTER PUTTER POINTER

	LAC	GETIN	/INIT. CHAR GETTER

	DAC	GETSW

	LAC	PUTIN	/INIT CHAR PUTTER

	DAC	PUTSW

	CLA		/INIT OUTPUT BUFFER HEADER

	XCT	MIX	/TO 0 IF IOPS, 400 FOR IMAGE

	LAC	(400

	DAC*	LPBUF

	CLA!CMA		/COUNT OF 1 BLANK AS DEFUALT

/			/FOR ZERO LENGTH IOPS LINE

	DAC*	LPBUFD	/IN FIRST DATA CHAR

/

/  MAIN LOOP TO TRANSFER CHAR'S TO HANDLER BUFFER

/

MAIN	JMS	GETCH	/CHARACTER GETTER, LEAVES IT IN AC

	SNA		/SKIP UNLESS NULL CHAR

	JMP	MAIN	/NULL, IGNORE

	SAD	(177	/IGNORE RUB-OUT

	JMP	MAIN	/MAIN

	DAC	TCHAR	/SAVE CHAR THROUGH TESTING

	AAC	-40	/SEPARATE 'TEXT' CHAR'S FROM CONTROL CHAR'S

	SNA!SPA		/SKIP ON REGULAR CHARS

	JMP	MSPEC	/GO DO SPECIALS

	SAD	(135	/ALT MODE

	JMP	UCLP03	/END OF LINE ON ALT MODE

/

/  SORRY ABOUT NE XT FIVE LrNES.

/  THE LOGIC AT PUTCH TO DO FORMS CONTROL DOESN'T DO IMPLIED

/  LINE FEEDS, I.E. THOSE LINES HAVING NO LEADING CONTROL CHAR.

/  WE HAVE TO FAKE IT OUT BY  hLACING A LINE FEED ON SUCH LINES!?!

/

	LAC	FIRST	/DO ONLY IF FIRST CHAR OF LINE IS REGULAR

	SMA		/SKIP IF FIRST CHAR

	JMP	.+3	/NOT FIRST CHAR, JUST CONTINUE

	LAC	(12	/HERE IS LINE FEED

	JMS	PUTCH	/AND CALL TO DO FORMS CONTROL

/

	CLA!IAC		/SET FLAG SAYING A REAL CHAR SINCE A FF

	DAC	COP

/

	LAC	BLANKC	/DO WE HAVE PENDING BLANKS/TABS TO SEND

/

/  NOTE BLANKC HAS MINUS COUNT OF CONSECTIVE BLANKS/TABS

/  SINCE PDP-11 CONTROLLER PRINTS ONLY BLANKS

/

	SMA!CLL		/SKIP IF ANY COLLECTED, TO PUT OUT BEFORE

/			/REAL CHAR'S

	JMP	MAINC	/NONE, PENDING, GO PUT OUT THE CHAR

	TAD	(200	/TOUGH, IF MORE THAN 127 COLLECTED, MUST

/			/PUT OUT TWO COUNTS

	SMA!CLA		/SKIP IF NEED TWO COUNTS

	JMP	MAIND	/NO, JUST PUT OUT COLLECTED COUNT

	TAD	(200	/TWO COUNTS, HERE IS FIRST

	JMS	PUTCH

	LAC	(200	/SET UP TO DO SECOND

MAIND	TAD	BLANKC	/COMMON CODE, LAST COUNT FOR EITHER CASE

	JMS	PUTCH

MAINC	DZM	BLANKC	/CLEAR OUT BLANK COUNTER

	LAC	TCHAR	/GET BACK ORIGINAL CHAR

	JMS	PUTCH	/TO OUTPUT BUFFER

MAINK	ISZ	TABC	/INCREMENT TAB COUNTER

	JMP	MAINE	/NOT OVERFLOW, GO CHECK LINE COUNTER

	LAW	-10	/RESET TAB COUNTER

	DAC	TABC

MAINE	ISZ	MAXC	/HAVE WE RUN OUT OF LINE

	JMP	MAIN	/NO

	JMP	UCLP03	/YES, GO FINISH UP, WITH END OF LINE

/

/  SPECIAL CHARACTERS

/

MSPEC	SZA!CLA!CMA	/SKIP IF IT IS A BLANK

	JMP	MSPEC2	/NOPE, CHECK FOR OTHER THINGS

	TAD	BLANKC	/ADD ONE TO BLANK COUNTER (IS MINUS COUNTER)

	DAC	BLANKC

	JMP	MAINK	/JOIN LINE AND TAB CONTROL SECTION

MSPEC2	LAC	TCHAR	/GET BACK ORIGINAL CHAR

	SAD	(11	/IS IT A TAB

	JMP	MTAB	/YUP, GO DO IT

	SAD	(15	/CARRIAGE RETURN

	JMP	UCLP03	/END OF LINE ON CARRIAGE RETURN

	SAD	(20	/FORTRAN OTS OVERPRINT, DO AS CR

	JMP	MCR

	SAD	(14	/FORM FEED

	JMP	MSPEC3	/JUST PUT IT OUT, FOR NOW

	SAD	(21	/FORTRAN DOUBLE SPACE

	JMP	MSPEC4	/DO AS TWO 12'S

MSPEC5	LAC	(12	/DEFAULT ON UNRECOGNIZED CONTROL CHAR. IS LINE FEED

MSPEC3	JMS	PUTCH	/PLACE IN BUFFER

	JMP	MAIN	/GO DO NEXT

MSPEC4	LAC	(12	/FIRST OF TWO 12'S FOR THE 21

	JMS	PUTCH

	JMP	MSPEC5	/GO DO THE SECOND 112

MCR	JMS	RESETL	/NEW LINE, RESET VARIOUS GUYS

	LAC	(15	/CARRIAGE RETURN

	JMP	MSPEC3	/PUT CHAR AND LOOP

MTAB	LAC	TABC	/GET REMAINING COUNT FOR TAB

	TAD	BLANKC	/AND ADD TO CUMULATIVE BLANK COUNT

	DAC	BLANKC

	LAC	TABC	/AND TO LINE CHECKER

	CMA!IAC

	TAD	MAXC

	DAC	MAXC

	SMA		/SKIP IF SOME LINE LEFT

	JMP	UCLP03	/NONE LEFT, FINISH UP LINE

	LAW	-10

	DAC	TABC	/RESET TAB COUNTER

	JMP	MAIN	/NEXT CHAR

/

UCLP03	LAC	(15	/CARRIAGE RETURN

	XCT	MIX	/PLACE IN BUFFER ONLY ON IMAGE!!!

	JMS	PUTCH

	JMS	RESETL

UCLP04	ISZ	COP	/A BLANK LINE IS STILL A REAL CHAR SINCE FF

	LAC*	LPBUF	/ZERO CHAR COUNT??

	AND	(377	/COUNT ONLY IN LOW 8 BITS

	SZA		/SKIP IF ZERO COUNT

	JMP	UCLP05	/NON-ZERO, JUST GO DO REGULAR

	XCT	MIX	/IMAGE OR IOPS

	JMP	LPNEXT	/IMAGE DO NOTHING

	ISZ*	LPBUF	/IOPS MAKE FAKE 1 COUNT

/			/WE ARE DOING A BLANK LINE, AND 0

/			/COUNT MAKES SPOOLER VERY ILL

UCLP05	JMS	LPSET	/SEND BUFFER TO PDP-11

	JMP	LPNEXT	/CAL EXIT

/

/	CHARACTER UNPACKING ROUTINE

/

/

/  THIS ROUTINE 'OWNS' THE MQ

/

/  

/  CHARACTERS ARE OBTAINED FROM X12 POINTER. EACH CHAR

/  IS RETURNED RIGHT JUSTIFIED IN THE AC

/  TEMP1 HAS A MINUS COUNT OF THE WORDS TO BE OBTAINED

/  FROM THE INPUT POINTER X12

/

GETCH	0

	XCT	MIX	/SKIP IF IT IS ASCII

	SKP

	JMP*	GETSW	/GETSW IS POINTER TO CORRECT ACTION ON ONTHE

/			/CORRECT ONE OF THE FIVE POSSIBLE CHAR'S

/

/  NOW DO IMAGE MODE

/

	ISZ	TEMP1

	SKP		/SKP ON NOT THRU YET

	JMP	UCLP04	/DONE

	LAC*	X12

	ISZ	X12

	JMP	GETCM	/FINISH UP IN COMMON

/

GETSW	0		/POINTER TO CORRECT ACTION. INIT'ED FROM GETIN

/			/FILLED BY JMS GETSW AFTER EACH CHAR

GETCM	AND	(177	/COMMON FINISH UP, STRIP XTRA BITS

	JMP*	GETCH	/OUT

/

GETIN	GET1		/INIT GETSW TO POINT TO FIRST CHAR ACTION

/

/  INDIVIDULA CHARACTER ACTION

/

GETQ	JMS	GETSW	/AFTER 5TH CHAR, POINT BACK TO FIRST

/

GET1	ISZ	TEMP1	/OUT OF PAIRS?

	JMP	.+3	/CONTINUE IF OK

	JMS	RESETL	/END OF LINE RESET SONE STUFF

	JMP	UCLP04

	LAC*	X12	/FIRST WORD OF PAIR

	ISZ	X12

	LMQ		/INTO MQ FOR SHIFTING

	LLS	7

	JMS	GETSW	/DONE, LEAVE POINTER FOR SECOND CHAR

GET2	LLS	7	/SECOND CHAR

	JMS	GETSW	/LEAVING POINTER FOR THIRD

GET3	LLS	4	/THE HALF-AND-HALF CHAR

	DAC	GETSW	/VERY TEMPORARY

	LAC*	X12	/CAN'T END IN MIDDLE OF PAIR

	ISZ	X12

	LMQ		/SECOND WORD TO SHIFTER

	LAC	GETSW	/BRING BACK FIRST

	LLS	3	/COMPLETE CHAR

	JMS	GETSW	/LEAVING POINTER TO FOURTH ACTION

GET4	LLS	7

	JMS	GETSW	/LEAVING FOR 5

GET5	LLS	7

	JMP	GETQ	/BACK TO TOP FOR POINTER TO 1

/

/

/

/  CHARACTER PUTTER FOR PDP-11

/

/  TWO CHAR'S PER WORD FORMAT. FIRST CHAR IS RIGHT JUSTIFIED, SECOND

/  IS PLACED IMMEDIATELY ABOVE FIRST, LEAVING TOP TWO BITS OF WORD

/  UNUSED. CHAR IS DELEVERD TO US IN AC. INIT PUTSW BY DAC'ING CONTENTS

/  OF PUTIN INTO IT. ROUTINE COUNTS THE OUTPUT CHARS IN LBF

/

/  THIS ROUTINE ALSO HANDLES FORM FEED PAGE CONTROL

/  THE PDP-11 ASSUMES LINES HAVE A LF IN BEGINNING AND CR AT END

/  SO THIS ROUTINE REMOVES ANY LEADING LF.

/

/

PUTCH	0

	AND	(377	/STRIP TO EIGHT BITS

	SAD	(12	/SPECIAL CASE #1, LINE FEED

	JMP	PUTLF	/GO DO IT

	SAD	(14	/SPECIAL CASE #2, FORM FEED

	JMP	PUTFF	/GO DO IT

PUTY	ISZ	FIRST	/BUMP FIRST TIME THRU SWTICH

	NOP		/IN CASE SKIPS, WE DON'T NEED IT HERE

PUTZ	ISZ*	LPBUF	/COUNT AN OUTPUT CHAR

	JMP*	PUTSW	/DISPATCH TO FIRST OR SECOND CHAR ACTION

/

PUTLF	LAC	COP	/HAS A REAL CHAR OCCURRED SINCE FF?

	SZA		/SKIP IF NO REAL CHAR

	JMP	PUTW	/GO DO REGULAR

	LAC*	LPBUFD	/IF WE ALREADY HAVE A FF

	SAD	(14	/IN BUFFER OUT, DON'T NEED A CR

	JMP*	PUTCH

	LAC	(15	/LEAD WITH CR, SO PDP-11 DOESN'T PUT ON AUTOMATIC LF

	XCT	MIX	/BUT DO NOTHING FOR IMAGE MODE

	JMP*	PUTCH

	JMP	PUTY	/GO REAJOIN

PUTW	LAC	(12	/GET BACK LINE FEED

	XCT	FFSW	/ISZ OR NOP FOR COUNT OF FF PER PAGE

	JMP	PUTLFR	/NO FORM FEED NOW

PUTFF	LAC	PAGSIZ	/FORM FEED, RESET PAGE COUNTER

	DAC	PAGCNT

	DZM	COP	/FLAG SAYING FF OCCURRED.

	LAC	(14	/FORM FEED CODE

	JMP	PUTZ	/GO COUNT CHAR, AND PLACE IT

PUTLFR	XCT	MIX	/SKIP ON IOPS ASCII

	JMP	PUTY	/IMAGE, ACTUALLY PLACE LF

	ISZ	FIRST	/ASCII, IS IT FIRST THRU?

	JMP	PUTZ	/NOT FIRST, DO LF

	JMP*	PUTCH	/FIRST TIME, JUST RETURN

PUTSW	0		/INIT'ED AS PUT1. FILLED LATER BY JMS PUTSW

	JMP*	PUTCH	/DONE, RETURN

/

PUTIN	PUT1		/START AT FIRST CHAR

/

PUTQ	JMS	PUTSW	/LEAVE POINTER FOR FIRST AFTER SECOND

PUT1	DAC*	PUTP	/FIRST CHARACTER ACTION, PLACE RIGHT JUSTIFIED

	JMS	PUTSW	/LEAVING POINTER FOR SECOND

/

PUT2	CLL!SWHA	/PUT CHAR IN RIGHT PLACE

	RAR

	XOR*	PUTP	/PUT HALVES TOGETHER

	DAC*	PUTP	/BOTH IN BUFFER

	ISZ	PUTP	/MOVE POINTER

	JMP	PUTQ	/GO TELL PUTSW  THAT PUT1 IS NEXT

/

/  OUTINE TO RESET LINE AND TAB COUNTRS

/

RESETL	0

	LAW	-1	/SET FIRST CHAR OF LINE REMEMBERER

	DAC	FIRST

	LAW	-10	/SET TAB COUNTR

	DAC	TABC

	LAC	LINLIM	/SET UP MAX PER LINE COUNTER

	DAC	MAXC

	DZM	BLANKC	/RESET SPACE AND TAB COUNTER

	JMP*	RESETL

/

	.TITLE .CLOSE FUNCTION

/

/

/.CLOSE

/
LPCLOS	JMS	LPIOCK		/CHECK I/O UNDERWAY.

	DZM	COP	/SAY A FF OCCURRED

	ISZ	LPCLSW		/777777 IN AC IF HAVEN'T BEEN THRU CLOSE CODE.

	JMP	LPCLDN		/DONE.
	LAC	(104001	/(SCR-124)CLOSE HEADER, IMAGE, 1 BYTE
	DAC*	LPBUF	/JUST GIVE FF TO DRIVER, HOWEVER
	.IFUND	NOFF	/(SCR-124)CLOSE GETS FORM FEED IF NOT NOFF
	LAC	(6414	/THIS IS FF,CR IN PDP-11
	DAC*	LPBUFD	/FIRST DATA WORD POINTER
	.ENDC		/(SCR-124)
	.IFDEF	NOFF	/(SCR-124)
	DZM*	LPBUFD	/(SCR-124) NO FF, JUST SEND A NULL
	.ENDC		/(SCR-124)

/			/THIS MEANS ALWAYS A FF ON CLOSE!!!

	JMS	LPSET	/SEND BUFFER TO PDP-11

	JMS	RESETL	/RESET THE WORLD

LPCALX	DBR

	JMP*	LPCALP		/HANG ON CAL.

LPCLSW	777777			/-1 = .CLOSE NOT DONE.

LPCLDN	LAW -1

	DAC	LPCLSW		/INITIALIZE .CLOSE INDICATOR

	JMP	LPNEXT		/EXIT.

	.TITLE .WAIT FUNCTION

/

/.WAIT OR .WAITR

/

LPWAIT	LAC*	LPCALP

	AND	(1000

	SNA			/BIT 8 = 1 FOR .WAITR

	JMP	LPWAT1		/.WAIT - GO HANG ON CAL.

	LAC	(700000		/LINK, ETC.

	AND	LPCALP

	DAC	LPCALP

	LAC*	LPARGP		/15-BIT BUSY ADDRESS.

	AND	(77777

	XOR	LPCALP

	DAC	LPCALP

	IDX	LPARGP

LPWAT1	JMS	LPIOCK		/CHECK I/O UNDERWAY.

	JMP	LPNEXT		/OK - RETURN.

/

/CHECK FOR I/O UNDERWAY

/

/LPUND 0 WHEN FREE, NON0 WHEN BUSY

/

LPIOCK	0

	LAC	LPUND		/0 = NO ACTIVITY.

	SNA

	JMP*	LPIOCK		/NO I/O UNDERWAY.

	JMP	LPCALX		/HANG ON CAL TIL NOT BUSY.

/

/ SETUP AND OUTPUT TO PRINTER.

/

LPSET	0

	LAC	LPTCB	/SEND TCB POINTER TO PDP-11

	SIOA			/MAKE SURE ITS ABLE TO GET IT

	JMP	.-1		/NOTE THAT THIS IS PROTECTED SINCE

				/    THE LIOR WILL BE ISSUED DIRECTLY

				/    AFTER THE SIOA (FREE INSTRUCTION).

	LIOR

	DAC LPUND		/SET I/O BUSY FLAG.

	JMP* LPSET

	.TITLE INITIALIZATION CODE AND TEMPORARIES

/

LPCALP	0		/POINTER TO CAL ADDR

LPARGP	0		/POINTER ARGUMENTS OF CAL

PAGSIZ	-FORMS		/ASSEMBLED LINES PER PAGE

PAGCNT	-FORMS		/COUNT THE LINES HERE
LPUND	-6		/0=FREE,+=BUSY,-=ERROR
FFSW	ISZ PAGCNT		/(RCHM-124) ACTION CONTROL FOR FORMS CONTROL.
					/(RCHM-124) ISZ PAGCNT => FORMS CONTROL IN DURING PRINTING.
				/(RCHM-124) NOP => NO FORMS CONTROL DURING PRINTING.
INIT	LAC	(NOP	/WRITE OVER JUMP TO HERE

LPTCB	DAC	NEW	/PREVENT RE-ENTRY

LPBUF	LAC*	(.SCOM+4  /GT PRINTER LINE WIDTH

LPBUFD	RTR

LPEV	RAR		/MOVE TO '6' POSITION

TEMP1	AND	(6	/STRIP GARBAGE, LITERAL 6

BUFSIZ	SNA

LINLIM	TAD	(6	/TREAT 0 (UNDEFINED) AS 132 COLUMN!??!

MAXC	TAD	LBFTP	/POINTER TO CONSTANTS

FIRST	DAC	LBFTP

TCHAR	LAC*	LBFTP	/LINE WIDTH

COP	DAC	LINLIM

BLANKC	ISZ	LBFTP

TABC	LAC*	LBFTP	/BUFFER SIZE

MIX	DAC	BUFSIZ

/

/  NOW SET UP POINTERS TO BUFFER AND TCB LOC'S

/

LPAC	LAC*	(.SCOM+100  /POINTER TO TABLE OF POINTERS

LPOUT	SNA!SPA!IAC	/(SCR-123)UC15 GONE IF THIS 0
	JMP	IOPS12	/(SCR-123)FATAL
X12	DAC	TEMP1
PUTP	LAC*	TEMP1	/POINTER TO TCB
	SNA!SPA		/(SCR-123)THIS ALSO, BETTER BE THERE
	JMP	IOPS55	/(SCR-123)NO TCB AREA FOR US
	DAC	LPTCB

	DAC	TEMP1	/POINTER TO FILL LOCATIONS

	AAC	2	/MAKE POINTER TO EVENT VARIABLE

	DAC	LPEV

	AAC	2	/MAKE POINTER TO TCB POINTER

	DAC	TABC	/TO BUFFER ADDR

	AAC	5	/MAKE POINTER TO FIRST DATA WORD

	DAC	LPBUFD

/

/  MAKE TCB

/

	LAC	(APISLT*400+APILVL

	DAC*	TEMP1

	ISZ	TEMP1

	LAC	(DEVCOD	/PIREX CODE FOR LP DRIEVER

	DAC*	TEMP1

	ISZ	TEMP1	/ZERO THRU FIRST BUFFER LOC

	DZM*	TEMP1

	ISZ	LPUND

	JMP	.-3

	LAC	TEMP1	/THIS POINTS TO BUFFER

	DAC*	TABC	/TO LOCATION IN TCB THAT NEEDS

	DAC	LPBUF	/AND A POINTER FOR US

	JMS	RESETL	/RESET LINE AND TAB COUNTRS

	CAL	APISLT	/ISSUE SETUP CAL TO ESTABLISH INTERRUPTS

	16

	LSSF

	LPINT

	JMP	NEW	/WHEW, DONE

/

	.DEC

LBFTP	.-1		/POINTER TO SIZE TABLE

	-80

	36

	-120

	52

	-132

	56

	.END
