ATS
   4
ASKIT@008
ATS15@028
ATS@@@JOB
GTFREE001
[\].
ASKIT@008
	.TITLE ASKIT
/
/  20 APR 78 (008; PDH) CHANGE TTY I/O TO LUN'S 12 & 13
/  31 AUG 77 (007; PDH) BEGIN CONVERSION TO RSX
/
	.GLOBL BUFFER,IMAGE,CHANGE,DOWE,ASK,FINI
	.GLOBL A16,A17,PUTIT
	.GLOBL OUTIMG,PCK,ADDR2,UNPCK
/
/  1 MAY 73 - MOD FOR HANDLING SOURCE FILES WITH NUMBERED LINES
/  2 MAY 73 - DEBUG
/  17 JULY 74 - MAJOR REVISION OF MESSAGES
/  5 FEB 75 - ADD NEW MESSAGES
/  29 MAY 75 - ADD MESSAGE NUMBER 21
/  6 MAY 75 - CONTINUE TO DEBUG
/
	.DEC
TTI=12								/(008)
TTO=13								/(008)
	.OCT
/
WHICH;TEMP2;OBJECT;TEMP;FRONT;PNTR;PNTR1;CNT
/
DOWE	0
CHANGE	1
CHAR	40
/
AUTO1=10
AUTO2=11
AUTO3=12
AUTO4=13
/
/
/SUBROUTINE FOR USER INTERATION WITH HIS PROGRAMS
/
COUT	SPA
	JMP	COUTS
	LAC	(TELL10
	JMS	TELL
	LAC	BUFFER		/ TELL USER WE ARE GOING TO
	JMS	TELL		/ DISPLAY THE LINE IN QUESTION
	JMP*	FINI	/THEN GET OUT
COUTS	DZM	DOWE
	LAW	-1
	DAC	CHANGE	/ALWAYS SET FOR QUICK EXIT
	JMP*	ASK		/-1=QUICK EXIT, 0=READ SOMETHING, 1=TERMINAL
/
ASK	XX
	DAC	WHICH
	JMS	SETUP
	LAC	WHICH
	TAD	(MESGS	/GET SET TO ASK APPROPRIATE QUESTION
	DAC	TEMP2
	LAC*	TEMP2
	JMS	TELL
	LAC	CHANGE	/DO WE WANT A QUICK EXIT
	SZA
	JMP	COUT	/YES GET OUT
RAGN	CAL	READ		/ READ A LINE FROM TTY
	CAL	WAITFR
	JMS*	UNPCK
	LAC	DOWE	/A YES OR NO ANSWER?
	SZA
	JMP	COUTS	/NO - GET OUT
	JMS	YORN
	SMA
	JMP	COUTS
	LAC	(WHT
	JMS	TELL		/ 'WHAT?'
	JMP	RAGN
/
YORN	XX
	LAC*	IMAGE
	SAD	(131
	JMP*	YORN	/ANSWER IS YES
	SAD	(116	/N
	JMP	.+3
	CLC
	JMP*	YORN	/UNRECOGNIZABLE REPLY
	CLA
	JMP*	YORN	/ANSWER IS NO
/
TELL	XX
	DAC	WRITE+4		/ PUT LINE BUFFER ADDRESS IN CPB
	CAL	WRITE
	CAL	WAITFR		/ NO CHECKING OF EVENT VARIABLE
	JMP*	TELL
/
SETUP	XX
	LAC	BUFFER
	DAC	MESGS+1		/ FETCH ACTUAL ADDRESS OF
	DAC	READ+4		/ EXTERNAL (GLOBAL) LINE BUFFER
	LAC	.+2
	DAC	SETUP+1
	JMP*	SETUP
/
/  CAL PARAMETER BLOCKS
/
READ	2600;	EV;	TTI; 2; BUFFER; 42
WRITE	2700;	EV;	TTO; 2; BUFFER
WAITFR	20;	EV;EV
/
MESGS	ASK1	/0 - SUPPLY FILE NAME
	BUFFER	/1 - DISPLAY LINE IN QUESTION
	ERR1	/2 - FILE NOT FOUND
	TELL1	/3 - SAME WARNING
	TELL2	/4 - TITLE COMMAND FOUND MORE THAN ONCE OR OUT OF SEQUENCE
	ASK16	/5 - TELL USER HE REQUIRES SO MUCH SPACE
	ASK17	/6 - TELL USER HOW MANY SPACES ARE AVAILABLE
	ASK18	/7 - ASK USER TO CHOOSE AN OPTION
	TELL3	/10 - INDEX TABLE OVERFLOW
	TELL5	/11 - MORE THAN 10 LINES FOR INDEX ENTRY
	ASK21	/12 - SPACE REQUEST TOO LARGE
	TELL6	/13 - NO PREVIOUS $II COMMAND ENCOUNTERED BEFORE THIS $I COMMAND
	TELL7	/14 - MULTIPLE $IE COMMANDS ENCOUNTERED - IGNORE
	TELL8	/15 - NO TEXT ALLOWED AFTER $IE - ONLY COMMANDS
	TELL9	/16 - END OF GROUP ENCOUNTERED WHILE IN PARAGRAPH MODE
	TELL10	/17 - LINE IN QUESTION IS
	TELL11	/20 - TOO MANY LINES FOR CENTERED PAGE
	TELL12	/21 - $IE IGNORED BECAUSE IT WAS 1ST INDEX COMMMAND ENCOUNTERED
	NTHR	/22
	NTHR	/23
	NTHR	/24
	NTHR	/25
	NTHR	/26
	NTHR	/27
	TELL18	/30 - NUMBER OUTSIDE OPTION RANGE
	TELL19	/31 - REQUEST MUST BE ALTERED - ENTER NEW NO OF SPACES
	NTHR	/32
	NTHR	/33
	TELL22	/34 - COMMAND NOT IMPLEMENTED YET - IGNORE TILL NEXT COMMAND
	INE	/35 - END OF FILE REACHED WHILE GETTING INDEX LINE
	TELL23	/36 - OPTION NOT IMPLEMENTED - CHOOSE ANOTHER
	NTHR	/37
	TELL24	/40 - EOF REACHED WHILE GETTING TITLE LINES
	TELL25	/41 - CANNOT HAVE ALTMODE TERMINATOR IN TITLE LINE
	TELL26	/42 - TITLE BUFFER OVERFLOW
	TELL27	/43 - CANNOT HAVE ALTMODE TERMINATOR IN CENTERED LINE
	NTHR	/44
	NTHR	/45
	TELL30	/46 - IN JMP TABLE FOR COMMANDS - GOT A WRONG NUMBER
	NTHR	/47
	TELL32	/50 - PROGRAM SHOULD NOT BE AT THIS POINT
	NTHR	/51
	NTHR	/52
	TELL35	/53 - TERMINAL ERROR
	TELL36	/54 - INDENTATION TOO LARGE
	TELL37	/55 - SHOULD HAVE FOUND A PAGE NUMBER - DIDN'T
	NTHR	/56
	TELL39	/57 - IMPROPER NO OF NOS FOR FUNCTION
	TELL40	/60 - WARNING - THIS LINE HAS NO SPACES
	TELL41	/61 - BLANK LINE ENCOUNTERED
/
INE	I-.*400+2; 0
	.ASCII 'REACHED END OF FILE WHILE GETTING AN INDEX LINE'<15> ;I=.
ERR1	ER1-.*400+2; 0
	.ASCII 'FILE NOT FOUND - TRY AGAIN'<15> ;ER1=.
WHT	W-.*400+2; 0
	.ASCII 'WHAT?'<15> ;W=.
ASK1	AS1-.*400+2; 0
	.ASCII 'ENTER FILE NAME>'<175> ;AS1=.
ASK16	AS16-.*400+2; 0
	.ASCII 'YOU REQUIRE '
A16	.ASCII '20   '
	.ASCII ' SPACES'<15> ;AS16=.
ASK17	AS17-.*400+2; 0
	.ASCII 'ONLY '
A17	.ASCII '12   '
	.ASCII ' SPACES ARE AVAILABLE'<15> ;AS17=.
ASK18	AS18-.*400+2; 0
	.ASCII 'CHOOSE OPTIONS 0,1,2,3 OR 4 >'<175> ;AS18=.
ASK21	AS21-.*400+2; 0
	.ASCII 'TOO MUCH SPACE REQUESTED'<15> ;AS21=.
TELL1	TE1-.*400+2; 0
	.ASCII 'SAME WARNING!!'<15> ;TE1=.
TELL2	TE2-.*400+2; 0
	.ASCII 'TITLE OUT OF SEQUENCE OR MUTLPLE TITLES - IGNORED'<15> ;TE2=.
TELL3	TE3-.*400+2; 0
	.ASCII 'INDEX TABLE OVERLOW - TOO MANY ENTRIES'<15> ;TE3=.
TELL5	TE5-.*400+2; 0
	.ASCII 'MORE THAN 10 ENTRIES FOR THIS INDEX ENTRY'<15> ;TE5=.
TELL6	TE6-.*400+2; 0
	.ASCII '$II COMMAND MUST PRECEED USED OF $I COMMAND'<15> ;TE6=.
TELL7	TE7-.*400+2; 0
	.ASCII 'MULTPLE $IE COMMANDS - IGNORED'<15> ;TE7=.
TELL8	TE8-.*400+2; 0
	.ASCII 'NO TEXT ALLOWED AFTER $IE - ONLY COMMANDS'<15> ;TE8=.
TELL9	TE9-.*400+2; 0
	.ASCII 'END OF GROUP ENCOUNTERED WHILE IN PARAGRAPH MODE'<15> ;TE9=.
TELL10	TE10-.*400+2; 0
	.ASCII 'LINE IN QUESTION IS:'<15> ;TE10=.
TELL11	TE11-.*400+2; 0
	.ASCII 'TOO MANY LINES FOR CENTERED PAGE'<15> ;TE11=.
TELL12	TE12-.*400+2; 0
	.ASCII 'WARNING - $IE IGNORED BECAUSE IT IS 1ST INDEX COMMAND'<15>
TE12=.
/
TELL18	TE18-.*400+2; 0
	.ASCII 'NUMBER MUST BE 0,1,2,3 OR 4'<15> ;TE18=.
TELL19	TE19-.*400+2; 0
	.ASCII 'REQUEST MUST/CAN BE ALTERED '
	.ASCII '- ENTER NEW NUMBER OF SPACES'<15> ;TE19=.
TELL22	TE22-.*400+2; 0
	.ASCII 'COMMAND NOT IMPLEMENTED - IGNORE INPUT UNTIL NEXT'
	.ASCII ' COMMAND'<15> ;TE22=.
TELL23	TE23-.*400+2; 0
	.ASCII 'OPTION NOT IMPLEMENTED - PICK ANOTHER'<15> ;TE23=.
TELL24	TE24-.*400+2; 0
	.ASCII 'EOF REACHED WHILE GETTING TITLE LINES'<15> ;TE24=.
TELL25	TE25-.*400+2; 0
	.ASCII 'CANNOT HAVE ALTMODE TERMINATOR IN TITLE LINE'<15> ;TE25=.
TELL26	TE26-.*400+2; 0
	.ASCII 'TITLE TABLE OVERFLOW'<15> ;TE26=.
TELL27	TE27-.*400+2; 0
	.ASCII 'CANNOT HAVE ALTMODE TERMINATOR IN CENTERED LINE'<15> ;TE27=.
TELL30	TE30-.*400+2; 0
	.ASCII 'GOT A WRONG NUMBER TO JMP TABLE FOR COMMANDS'<15> ;TE30=.
TELL32	TE32-.*400+2; 0
	.ASCII 'PROGRAM SHOULD NOT BE AT THIS POINT '
PUTIT	.ASCII 'PLACE'
	.ASCII <15> ;TE32=.
NTHR	NT-.*400+2; 0
	.ASCII 'MESG NOT WRITTEN YET'<15> ;NT=.
TELL35	TE35-.*400+2; 0
	.ASCII 'TERMINAL ERROR'<15> ;TE35=.
TELL36	TE36-.*400+2; 0
	.ASCII 'INDENTATION REQUEST TOO LARGE'<15> ;TE36=.
TELL37	TE37-.*400+2; 0
	.ASCII 'SHOULD HAVE FOUND A PAGE NUMBER IN HEAD - DIDNT'<15> ;TE37=.
TELL39	TE39-.*400+2; 0
	.ASCII 'IMPROPER NUMBER OF NUMBERS FOR FUNCTION'<15> ;TE39=.
TELL40	TE40-.*400+2; 0
	.ASCII 'THIS LINE HAS NO SPACES'<15> ;TE40=.
TELL41	TE41-.*400+2; 0
	.ASCII 'BLANK LINE ENCOUNTERED'<15> ;TE41=.
	.END
[\].
ATS15@028
	.TITLE	ATS15
/
	.GLOBL FILENM,ASK,CHANGE,DOWE,OCTDEC,FINI
	.GLOBL .DIGCT,A16,A17,BUFFER,IMAGE
	.GLOBL OUTIMG,PCK,ADDR2,UNPCK,PUTIT
	.GLOBL	GTFREE,FREE.L,FREE.H,.IOERR
/
/
/
/  29 AUG 72
/   8 JAN 73 - MOD FOR TOTAL PACKAGE (ELIMINATING THE USE OF PAGER)
/  26 JAN 73 - REFINEMENTS AND USER DEBUG
/  13 FEB 73 - ADD IN DEBUG AND INSTITUE $Z AND $Y COMMANDS
/  16 FEB 73 - DEBUG ABOVE
/  26 FEB 72 - SPLIT ROUTINE INTO TWO PARTS (ATS9 & USER INTERATION)
/  28 FEB 73 - REMOVE EXISTING CODE FOR INDEX COMMANDS AND FIX SPACES
/   7 MAR 73 - DEBUG OPTIONS FOR SPACES
/  17 APR 73 - MAINTENANCE
/   1 MAY 73 - ADD IN FEATURE TO HANDLER NUMBERED SOURCE FILES
/   2 MAY 73 - DEBUG
/  11 MAY 73 - REVISE OUTPUT FOR LINE NUMBERS
/  17 MAY 73 - REMOVE SOME EXTRANEOUS CODE
/  28 MAY 73 - DEBUG FOR BATCH MODE
/   1 AUG 74 - REVISE WIDE MARGIN TECHNIQUE
/   7 JAN 75 - MAJOR REBUILDING IMPLEMENTED (START DATE: SEPT 74)
/  24 JAN 75 - FIRST ON LINE TEST OF REVISED PROGRAM
/  20 FEB 74 - ADD IN $R AND $NR OPTIONS
/  10 MAR 75 - FIX LINE COUNTING OPTION
/  14 APR 75 - FIX LOOSE ENDS IN FORMATTING MODE
/  14 APR 75 - START ADDING CODE FOR HANDLING TABS (INPUT & OUTPUT)
/     	     - ALSO CODE FOR INDEXING
/  29 APR 75 - CONTINUE TO DEBUG
/   6 MAY 75 -       - DITTO -
/   9 MAY 75 - CHANGE CENTERED PAGE PHILOSOPHY
/  14 MAY 75 - DEBUG CONTINUED
/  29 MAY 75 - ADD MORE PROCESSING CODE FOR INDEXING & FIXES FOR BUGS
/   8 MAR 77 (027; MKH,PDH) MAKE IT WORK WITH XVM/DOS
/  31 AUG 77 (028; PDH) RENAME 'ATS15' AND BEGIN CONVERSION TO RSX
/
	.EJECT
/	ATS9 COMMANDS:
/            (IN THE ORDER THAT THEY APPEAR IN THE SEARCH TABLE)
/
/	*	$U  - UNFORMATTED MODE - DEFAULT - TERMINAL
/	*	$F  - PARAGRAPH FORMATTED MODE - TERMINAL
/	*	$C  - CENTERED LINE MODE - TERMINAL
/		$N  - WANT NUMBERED LINES - WILL TAKE DEFAULT SPACING AT END OF LINE
/		$M  - WANT WIDE LEFT MARGIN
/		$O  - OMIT MODE - WILL IGNORE COMMANDS UNTIL NEXT $O FOUND
/		$S  - WANT SINGLE SPACING - DEFAULT MODE
/		$D  - WANT DOUBLE SPACING
/		$Y  - WANT SPACES LEFT BETWEEN PARAGRAPHS AND/OR GROUPS
/		$Z  - DON'T WANT SPACES LEFT BETWEEN PARAGRAPHS AND/OR GROUPS - DEFAULT
/		$I  - INDEX ENTRY - NOT FUNCTIONAL
/		$J  - WANT A RIGHT JUSTIFIED RIGHT MARGIN
/		$E  - WILL ALLOW TEXT TO EXCEED RIGHT MARGIN
/			(ONLY OPERATIVE IF TEXT NOT RIGHT JUSTIFIED)
/		$T  - OUTPUT ON TELETYPE
/		$R  - ALLOW RESTRICTED SPACES AT BEGINNING OF LINE
/		      FOLLOWING ')', '.' OR '/' FOR CONTROLLED FORMATTING
/********	0   - MARKS END OF FIRST GROUP
/		$NT - OUTPUT NOT ON TELETYPE - DEFAULT OPTION
/	*	$NP - NEW PAGE COMMAND - TERMINAL
/		$NM - NO WIDE LEFT MARGIN - DEFAULT CONDITION
/		$II - INTERMEDITATE INDEX TITLE - NOT YET OPERATIVE
/		$IE - END OF INDEX ENTRY - NEED FOR PROPER PAGING (INOPERATIVE)
/		$NJ - DON'T WANT RIGHT JUSTIFIED MARGIN - DEFAULT CONDITION
/		$IT - INDEX TITLE - NOT YET FUNCTIONAL
/		$NE - TEXT NOT ALLOWED TO EXCEED RIGHT MARGIN - DEFAULT CONDITON
/	*	$CP - CENTERED PAGE MODE - TERMINAL
/		$NN - NO LINE NUMBERS - DEFAULT CONDITION
/		$NO - INHIBIT OUTPUT
/		$ON - ALLOW OUTPUT  - DEFAULT
/		$NR - DISALLOW RESTRICTED SPACES
/********	0   - MARKS END OF SECOND GROUP
/		$NPN - DON'T WANT PAGE NUMBERS - DEFAULT CONDITION
/		$YPN - WANT PAGE NUMBERS
/********	0    - MARKS END ON THIRD GROUP
/	*	$FUXX;XX;XX;...ETC - DOCUMENT FORMAT MODE - TERMINAL
/		$WXX - LINE WIDTH
/		$NXX - NUMBER OF SPACES AFTER END OF LINE WHERE LINE NUMBERS
/		       ARE TO BE INSERTED
/		$HXX - NUMBER OF SPACES ALLOWED FOR HEADER SPACE ON HEACH PAGE
/		$LXX - NUMBER OF LINES PER PAGE (EXCLUDING HEADER SPACE)
/		$SXX - NUMBER OF START PAGE
/	*	$XX - LEAVE XX BLANK LINES REQUEST - QUASI-TERMINAL
/
	.EJECT
	.DEC
INDK=15
OUTDK=17
/***TEMPDK=2
/***TEMDK5=1		/ VARIABLES LEFT FROM PDP-9 INDEXING
	.OCT
/
SRC	.SIXBT	'SRC'
/
IFLAG	0	/DEFAULT  - NO TITLE AND HENCE INDEX FILE PRESENT
		/+1= TITLE RECIEVED AND INDEX FILE PRESENT
		/-1=NO TITLE RECIEVED BUT INDEX FILE PRESENT
REMBS	0	/POINTS TO 2ND ENTRY IN PGTABL FOR $II ENTRY
		/0 INDICATES NO $II AS YET OR $IE PROCESSED PREVIOUSLY
FIRST	-1	/0= $II WAS LAST INDEX COMMAND PROCESSED
		/+1= $I WAS LAST INDEX COMMAND
		/-1= $IE WAS LAST INDEX COMMAND PROCESSED
PARA	10	/DEFAULT INDENTATION FOR NEW PARAGRAPHS
NEW	0	/FLAG FOR NEW PAGE ISSUED PREVIOUSLY - CLEARED WHEN WRITE
		/ SUBROUTINE ENTERED AND SET AFTER NEW PAGE ISSUED
		/CHECKED WHEN BLANK LINE SUBROUTINE ENTERED AND SET
		/SET IF BLANK LINE SUBROUTINE ISSUES A NEW PAGE
		/CHECKED WHEN NEW PAGE SUBROUTINE ENTERED - EFFECT - NO NEW
		/PAGE ISSUED AND FLAG CLEARED
MODE	0	/FLAG FOR CURRENT MODE:  0=UNFORMATTED (DEFAULT)
		/    		         1=FORMATTED MODE (DOCUMENT OR PARA)
		/			-1=CENTERED  MODE (LINE OR PAGE)
MAX	-204	/MAX LINE WIDTH IS 132
DOUBLE	0	/FLAG FOR DOUBLE SPACING (0=NO, 1=YES)
WHATIF	0	/FLAG FOR SPACE REQUEST HELD OVER (0=NO, 1=YES)
NOSP	0	/FLAG FOR SPACES BETWEEN GROUPS OR PARAGRAPHS IN FORMATTED
		/MODE (0=NO, 1=YES)
JUST	0	/FLAG FOR RIGHT JUSTIFYING TEXT IN FORMATTED MODE (0=NO, 1=YES)
INFRST	0	/FLAG FOR 1ST INDEXING COMMAND (0=NO, 1=YES)
CENTPG	0	/CENTERED PAGE FLAG (0=NO, 1=YES)
OMTFLG	0	/FLAG FOR IGNORE COMMANDS (0=NO, 1=YES)
LINEN	0	/LINE COUNTER FROM THE BEGINNING OF SOURCE TEST
TTOUT	0	/SECOND FLAG FOR OUTPUT ON TELETYPE - SET WHEN $T ENCOUNTERED
		/RESET WHEN $NT ENCOUNTERED - CHECK WHEN $NJ ENCOUNTERED
		/BECAUSE WHEN JUST IS RESET WE DONT WANT TO RESET TT
		/IN CASE OUTPUT LINE IS RESTRICTED TO SHORT LINES
	.EJECT
NUMBER	-74	/DEFAULT LINE WIDTH OF 60
HEADSP	-2	/DEFAULT HEAD SPACE OF 2 (REALLY 3 WITH ONE LINE FOR PAGE NO.)
LENGTH	-71	/DEFAULT PAGE LENGTH OF 57
LINENM	-71	/USED TO REGULATE PAGE LENGTH - MUST BE INITIALIZED
		/ALSO USED IN A POSITIVE SENSE TO COUNT LINES
		/WHEN CENTERED PAGES ARE PROCESSED
SPDEF	-12	/DEFAULT OF 10 SPACES FOR LINE NUMBERS AT END OF EACH LINE
STRPG	1	/DEFAULT STARTING PAGE OF 1
NOTOUT	0	/FLAG FOR INHIBITING OUTPUT (0=DONT INHIBIT, 1=INHIBIT)
YES	0	/FLAG FOR WIDE LEFT MARGIN (0=NO, 1=YES)
WIDES	BUFFER	/BUFFER ADDRESS WHEN WIDE LEFT MARGIN NOT DESIRED (ADDRESS IS
		/BUFFER-4 WHEN WIDE LEFT MARGIN IN EFFECT
ADDR1	BUFFER+2	/INPUT PACKED ASCII ADDRESS
ADDR2	OUTIMG-1	/OUTPUT IMAGE BUFFER ADDRES
TT	0	/FLAG FOR INDICATING WHETHER TEXT CAN EXCEED RIGHT HAND MARGIN
		/(0=YES 1=NO)
FU	0	/FLAG FOR FORMATTING MODE (0=PARAGRAPH, 1=DOCUMENT)
NOPGNM	0	/FLAG FOR OUTPUTTING PAGE NUMBERS (0=YES, 1=NO)
DIDWE	0	/FLAG FOR WHETHER LAST LINE ISSUED WAS A BLANK LINE(0=NO,1=YES)
NONE	1	/FLAG FOR EMPTY OUTIMG BUFFER (0=NO, 1=YES)
		/(0=NO,1=YES)
PAGENM	0	/USED TO AVOID PAGE NUMBERING CONFILTS WITH CENTERED PAGES
NOSPS	0	/USED TO INDICATE SAME ERROR OCCURRING
POINTS	TAB	/USED IN FORMATTED MODE FOR INDENTATIONS
/
	.EJECT
/	ORDINARY VARIABLES
/
GETPNT	/USED IN GET AND MUST BE SETUP BEFORE ENTRY
PNTR1	/USED IN: SMOOTH, ALL,  MAKOCT
NUMB	/USED IN:  SMOOTH, GET, MAKOCT
RECORD	/USED IN: CENTIT,CENTER, UNPCK, CKCHAR,SPACES,SWAP,NEWPG
TEMP	/USED IN: HEADSP, SPACES, CNTIT, OMIT,OCTSUB, ALL
	/SMOOTH, ADDON, PCK, HEAD
PNTR	/USED IN:  SMOOTH, ALL
PNTR2	/USED IN:  GET, MAKOCT, SMOOTH, ALL
TEMP1	/USED IN:  OMIT, SMOOTH, HEAD, SPACES
	/ALSO USED IN OCTSUB AND MUST BE SETPU BEFORE ENTRY
SAVEIT	/USED IN: PCK AND ADDON
TEMSAV	/SUED TO SAVE NUMBER OF SPACES REQUESTED TO PUT OUTPUT ON NEXT
	/PAGE
NAMSAV	/USED TO SAVE ACTUAL TITLE LINES FOR A NAMED SPACE THAT IS
	/TO BE PUT OUT ON THE NEXT PAGE
RESERV	/FREE CORE POINTER
SPNUM	/USED AS AN INTERMEDIATE STORE FOR NUMBER OF SPACES AT END
	/OF LINE WHEN LINE NUMBERS ARE ADDED
CNT	/USED IN:  SPACES, MAKOCT, SMOOTH, ALL, HEAD, OCTSUB, PCK
	/	   STPCK, PACK
ADDR3	/USED TO SAVE ADDR2
TSAVE
BCKCNT
LENPNT
WHICH
COUNT
LAST
LONG
MASK
TOUT
SPCNT
IPLACE
OPLACE
OPLSAV
LINCNT
REMB
PLSAV
TABCNT
SPSAVE
SPADDR
CKNUM
HDSP
EXACT
BLOCK
LASTII
BCKSAV	0	/USED TO SAVE NUMBER OF SPACES REQD TO FILL LINE
SAVADR
COUNT1
SPECAL	0
FRSTSP	0	/USED AS FLAG FOR 1ST SPACE DETECTION IF $R IN EFFECT
IEFLAG		/USED TO SAVE ADDRESS OF CURRENT PAGE NUMBER FOR EXTRACTING
		/PAGE NUMBER FOR 'REMB'
CTPNT
PGPNT		/POINTER TO PGTABL
PGOVER
CBLANK
PCNT
POINT
STORE
STORED
TEMPS
FREE.L		/ LOWEST ADDRESS IN FREE CORE
FREE.H		/ HIGHEST ADDRESS IN FREE CORE
/
X10=10
X11=11
X12=12
X13=13
/
PG60=74
/
	.EJECT
/  CAL PARAMETER BLOCKS
/
WAITFR	20;	EV;EV
SEEK	3200;	EV;	INDK; .BLOCK 3
ENTER	3300;	EV;	OUTDK; .SIXBT '12345 LST'
CLOSE	3400;	EV;	OUTDK
READ	2600;	EV;	INDK;  2; BUFFER; 70
WRCPB	2700;	EV;	OUTDK; 2; BUFFER
WRFF	2700;	EV;	OUTDK; 2; FORMFD
WR1SP	2700;	EV;	OUTDK; 2; ONESP
WTFOR	XX
	LAC	EV		/ DO QUICK CHECK SO WE
	SNA
	CAL	WAITFR		/ ONLY WAIT WHEN NECESSARY
	LAC	EV
	SPA
	JMS*	.IOERR
	JMP*	WTFOR
/
	.EJECT
/  THE PROGRAM BEGINS HERE
/
ATS15	JMS*	GTFREE		/ CLAIM ALL FREE CORE IN PARTITION
	LAC	(OUTIMG-1
	DAC*	(X11
WHTRED	DZM*	CHANGE
	ISZ*	DOWE
	CLA
	JMS*	ASK	/ASK FOR FILE NAME
	JMS*	FILENM
	BUFFER+2
	SEEK+3
	LAC	SEEK+5
	SNA
	LAC	SRC		/ DEFAULT EXTENSION IS 'SRC'
	DAC	SEEK+5
	CAL	SEEK		/ ATTEMPT TO OPEN FILE
	CAL	WAITFR
	LAC	EV
	SMA
	JMP	SOUGHT		/ FILE EXISTS AND HAS BEEN OPENED
	SAD	(-13
	SKP			/ FILE NOT FOUND!
	JMS*	.IOERR		/ OTHER SERIOUS (AND FATAL) ERROR
/
	LAC	(2
	JMS*	ASK	/FILE NOT FOUND - TRY AGAIN
	JMP	WHTRED
/
SOUGHT	LAC	SEEK+3
	DAC	ENTER+3		/ MOVE FILE NAME TO 'ENTER' CPB
	LAC	SEEK+4
	DAC	ENTER+4
	CAL	ENTER		/ OPEN OUTPUT FILE
	JMS	WTFOR
/
CHECK	JMP	NEXT	/WILL BE USED AS A SUBROUTINE ENTRY POINT WHEN
	LAC	LINENM	/ WE ARE STARTING WITH A CENTERED PAGE
	SMA
	JMP	.+3	/YES DON'T SET UP PAGE LENGTH
	LAC	LENGTH		/FIRST NON COMMAND INPUT LINE ENCOUNTERED
	DAC	LINENM	/ENSURE MOST UP-TO-DATE PAGE LENGTH IS IN EFFECT
	LAC	.+2
	DAC	NX1	/RESTORE PROPER PROGRAM FLOW
	JMP	NOT
/
	.EJECT
/	GET EACH LINE OF INPUT FILE AND WORK ON IT
/
NEXT	DZM	PCNT	/ZERO COMMAND POINTER NUMBER
	JMS	RASCII	/READ A LINE, CHECK FOR END OF FILE AND UNPCK LINE INTO IMAGE
	SPA
NX0	JMP	FINI	/NEG INDICATES END OF FILE
NXT	SNA	/CHECK AC FOR 0 - INDICATES NOT A COMMAND
NX1	JMS	CHECK	/CHECK INITIAL CONDITIONS BEFORE PROCEEDING
NX2	TAD	(JMP WHERGO
	DAC	WHERGO
NX4	LAC	PCNT
	SAD	(OMITS
	JMP	NXT1
	TCA
	TAD	(ENDD
	SMA!CLA!IAC
	JMP	NXT0
	DAC*	CHANGE	/COMMAND NUMBER OUT OF RANGE - TERMINAL ERROR
	LAC	(46
	JMS*	ASK
/
NXT0	LAC	OMTFLG
	SZA
	JMP	PUTOUT
NXT1	JMS	SETIT
	JMP	NEXT
/
	.EJECT
SETIT	XX
WHERGO	XX
	JMP	CMODE0	/UNFORMATTED MODE FLAG=0 - T
	JMP	CMODE1	/FORMATTED MODE FLAG=1 - T
	JMP	CMODE1	/CENTERED LINE MODE FLAG=2 - T
	JMP	NUMS	/NUMBERED LINE OPTION
	JMP	WIDER	/WIDE LEFT MARGIN OPTION
	JMP	OTAG	/OMIT OPTION - T
	JMP	CSP	/SINGLE SPACING
	JMP	CSP	/DOUBLE SPACING
	JMP	CSP	/WANT SPACING BETWEEN PARAGRAPHS
	JMP	CSP	/DON'T WANT SPACING WETWEEN PARAGRAPHS
	JMP	I	/$I INDEX COMMAND - T
	JMP	JS	/RIGHT JUSTY OPTION
	JMP	ESY	/ALLOW TEXT PAST RIGHT MARGIN
	JMP	TS	/OUTPUT ON TELETYPE
	JMP	R	/RESTRICTED SPACE OPTION
	JMP	ST	/OUTPUT NOT ON TELETYPE
	JMP	NEWP	/NEW PAGE - T
	JMP	NW	/NO WIDE LEFT MARGIN
	JMP	II	/$II INDEX COMMAND - T
	JMP	IE	/$IE - END OF INDEX ENTRY - T
	JMP	NJ	/TURN OFF RIGHT JUSTIFY OPTION
	JMP	IT	/$IT - INDEX TITLE COMMAND - T
	JMP	CSP	/DON'T ALLOW FOR TEXT BEYOND SPECIFIED LEFT MARGIN
	JMP	CMODE1	/CENTERED PAGE MODE FLAG=2 - T
	JMP	NUMSN	/NO LINE NUMBERS
	JMP	CSP	/INHIBIT OUTPUT
	JMP	CSP	/ALLOW OUTPUT - DEFAULT CONDITION
	JMP	NR	/TURN OFF RESTRICTED SPACE OPTION - DEFAULT
	JMP	PGNMOF	/NO PAGE NUMBERS
	JMP	PGNMON	/ALLOW PAGE NUMBERS
	JMP	CMODE1	/DOCUMENT FORMAT MODE FLAGE=1 - T
	JMP	LWIDTH	/LINE WIDTH
	JMP	SPADD	/NUMBER OF SPACES FOLLOWING END OF TEXT TO INSERT NUMBERS
	JMP	HSP	/NUMBER OF SPACES IN HEADER OF EACH PAGE
	JMP	PLEN	/NUMBER OF LINES PER PAGE
	JMP	STRP	/NUMBER OF STARTING PAGE - DEFAULT IS 1
/	JMP	SPREQ	/ SPACE REQUEST - LEAVE 'XX' BLANK LINES
/
	.EJECT
SPREQ	LAC	LINENM	/IS THIS PART OF A CENTERED PAGE
	SMA
	JMP	.+4	/YES - DON'T GO TO SPACES
	JMS	GETRID	/NO - CARRY ON
	JMS	SPACES	/SPACES REQUEST
	JMP*	SETIT
/
	LAC	SPTABL
	TCA
	DAC	SPTABL
CBL.NK	LAC	(ONESP-1
	JMS	INTERC
	ISZ	SPTABL
	JMP	CBL.NK
	JMP*	SETIT
/
NUMS	LAC	(JMS ADDON	/USE DEFAULT NO OF SPACES FOLLOWING OUTPUT TEXT
	DAC	PKOUT	/FOR SOURCE LINE NO INSERTION
	LAC	SPDEF	/DEFAULT IS -12 OCTAL
	DAC	SPNUM
	JMP*	SETIT
/
PGNMON	DZM	PAGENM	/TURN ON PAGE NUMBERS
	LAC	CENTPG	/ARE WE WAITING ON A CENTERED PAGE
	SNA
	DZM	NOPGNM	/NO - JUST RESET FLAG
	JMP*	SETIT
/
PGNMOF	ISZ	PAGENM	/TURN OFF PAGE NUMBERS
	LAC	CENTPG	/ARE WE WAITING ON A CENTERED PAGE
	SNA
	ISZ	NOPGNM	/NO - JUST SET FLAG
	JMP*	SETIT
/
R	LAC	(NOP
	DAC	AGN.
	JMP*	SETIT
/
NR	LAC	SECPL
	DAC	AGN.
	JMP*	SETIT
/
	.EJECT
WIDER	LAC	YES
	SZA
	JMP*	SETIT	/COMMAND IS REDUNDANT
	LAC	(BUFFER-4	/WIDE LEFT MARGIN
	DAC	WIDES
	LAC	MODE
	SZA
	JMP	.+4
	LAC	WIDES
	DAC	WRCPB+4
	ISZ	YES
	LAC	(OUTIMG-2
	DAC	ADDR2
	LAC	MAX
	AAC	10
	DAC	MAX
	JMP*	SETIT
/
JS	ISZ	JUST	/RIGHT JUSTIFIED TEXT
	ISZ	TT
	JMP*	SETIT
/
TS	LAW	-110	/OUTPUT ON TELETYPE
	DAC	MAX
	ISZ	TTOUT
	ISZ	TT
	JMP*	SETIT
/
ST	LAW	-204	/OUTPUT NOT ON TELETYPE
	DAC	MAX
	DZM	TTOUT
	LAC	JUST
	SNA
	DZM	TT
	JMP*	SETIT
/
NW	LAC	YES
	SNA
	JMP*	SETIT	/COMMAND IS REDUNDANT
	LAC	(BUFFER	/NO WIDE LEFT MARGIN
	DAC	WIDES
	LAW	-10
	TAD	MAX
	DAC	MAX
	DZM	YES
	LAC	(OUTIMG-1
	DAC	ADDR2
	JMP*	SETIT
/
	.EJECT
NJ	DZM	JUST	/NO RIGHT JUSTIFY
	LAC	TTOUT
	SNA
	DZM	TT
	JMP*	SETIT
/
ESY	DZM	JUST
	DZM	TT
	JMP*	SETIT
/
NUMSN	LAC	(NOP	/REMOVE INSERTION OF SOURCE LINE NUMBERS
	DAC	PKOUT
	JMP*	SETIT
/
LWIDTH	LAC	TABLE	/LINE WIDTH
	TCA
	DAC	NUMBER
	LAC	TABLE
	TAD	MAX
	SMA
	JMP	MUCH
	LAW	-10
	TAD	TABLE
	SMA
	JMP*	SETIT
	LAW	-20
	SKP
MUCH	LAC	MAX	/DEFAULT OF MAX IF LINE WIDTH TOO LONG OR IF LINE WIDTH < 16
	DAC	NUMBER	/THEN 16 IS MIN
	JMP*	SETIT
/
SPADD	LAC	TABLE	/USER SPECIFIED NUMBER OF SPACES FOLLOWING
	TCA		/OUTPUT FOR LINE NUMBER INSERTION
	DAC	SPNUM
	LAC	(JMS ADDON
	DAC	PKOUT
	JMP*	SETIT
/
	.EJECT
HSP	LAC	TABLE	/GET NUMBER OF SPACES REQ'D
	DAC	HDSP
	TCA
	DAC	HEADSP	/STORE NEG
	AAC	2	/CHECK FOR > 2
	SPA
	JMP	HSPBIG
	LAW	-2	/MAKE HEADSP=2
	DAC	HEADSP
	LAC	(2
	DAC	HDSP
	JMP*	SETIT
/
HSPBIG	LAC	LENGTH	/CHECK THAT HEADSP+PG LENGTH IS NOT >58
	TAD	HEADSP
	AAC	72
	SMA!TCA
	JMP*	SETIT
/
	DAC	TEMP	/SAVE + NO > 58
	LAC	LENGTH	/DETERMINE WHICH IS LARGER
	TCA		/MAKE LENGTH POSITIVE
	TAD	HEADSP
	SPA
	JMP	SMALL
	LAC	LENGTH
	TAD	TEMP	/LENGTH IS LARGER - REDUCE IT
	DAC	LENGTH
	JMP*	SETIT
/
SMALL	LAC	HEADSP	/HEADSP IS LARGER - REDUCE IT
	TAD	TEMP
	DAC	HEADSP
	TCA
	DAC	HDSP
	JMP*	SETIT
/
	.EJECT
PLEN	LAC	TABLE	/GET PAGE LENGTH REQ'D
	TCA
	DAC	LENGTH	/STORE IT
	AAC	3	/MAKE SURE IT IS > 3
	SPA
	JMP	HSPBIG
	LAW	-3
	DAC	LENGTH
	JMP*	SETIT
/
STRP	LAC	TABLE
	DAC	STRPG
	JMP*	SETIT
/
NOT	LAC	(IMAGE-1
	DAC*	(X10
	LAC	MODE
	SNA
	JMP	ZEROM	/UNFORMATTED MODE
	SMA
	JMP	FORMAT	/FORMATTED MODE - EITHER DOCUMENT OR PARAGRAPH
	LAC	(OUTIMG-1
	DAC*	(X11
	JMS	CENTIT
	LAC	(BUFFER-1	/ADDRESS FOR INTERC IF IN $CP
	JMP	PUT
/
	.EJECT
ZEROM	DZM	MASK
PUTOUT	LAC	PKOUT	/ARE WE ADDING LINE NUMBERS
	SAD	(JMS ADDON
	SKP		/YES - REPACK LINE FROM IMAGE
	JMP	PUT0	/NO - JUST CARRY ON
	LAC	ADDR2
	DAC	ADDR3	/SAVE CURRENT ADDR2 FOR PCK
	LAC	(IMAGE-1
	DAC	ADDR2
	JMS	PCK
	LAC	ADDR3
	DAC	ADDR2
PUT0	LAC	YES	/DO WE HAVE A WIDE LEFT MARGIN
	SNA
	JMP	PUT	/NO - JUST PUT LINE OUT
	LAC	BUFFER	/YES - ADDIN TAB
	TAD	(2000
	DAC	BUFFER-4
	DZM	BUFFER-3
	DZM	BUFFER	/TAB IS CONTAINED IN BUFFER-2 AND BUFFER-1
	DZM	BUFFER+1
PUT	JMS	WRITES
	JMP	NEXT
/
CMODE0	JMS	GETRID
	JMS	SHOVE
	DZM	FU
	LAC	WIDES	/PUT EITHER ADDRESS BUFFER OR BUFFER-4 IN WRITE SUBROUTINE
	DAC	WRCPB+4
	DZM	MODE
CLINE	LAC	CNTS
	DAC	LCNT	/MAKE SURE WE COUNT LINES
	JMS	CKNXT
	JMP	NEXT
/
CMODE1	LAC	(BUFFER
	DAC	WRCPB+4
	LAC	PCNT
	SAD	(CUU
	JMP	C
	SAD	(CU
	JMP	C
	SAD	(FUU
	JMP	F	/DOCUMENT FORMATTED MODE
/
	DZM	FU	/SET PARAGRAPH FLAG
/
	.EJECT
FCOM	CLA!IAC
	DAC	MODE	/SET FORMAT MODE FLAG
	DZM	LINCNT	/FOR COUNTING SOURCE LINES IN FORMATTED MODE
	LAC	(ISZ LINCNT
	DAC	LCNT
	JMS	GETRID
FCOM0	JMS	SHOVE
	JMS	CKNXT
	JMP	NEXT
/
F	ISZ	FU
	LAC	(TAB-1
	DAC	POINTS
	JMP	FCOM
/
C	JMS	GETRID
	JMS	SHOVE
	LAW	-1
	DAC	MODE
	LAC	PCNT
	SAD	(CUU
	JMP	CLINE
	JMP	CB
/
NEWP	JMS	CKNXT	/ISSUE CENTERED PAGE IF ANY
	LAC	(NOP
	DAC	GETRID+1
	JMS	GETRID
	LAC	NEWP0+1
	DAC	GETRID+1
	LAC	NEW	/WILL BE NON-ZERO WHEN INTERNALLY GENERATED PAGE
	SNA		/HAS JUST OCCURRED
NEWP0	JMS	NEWPG	/ISSUE REQUEST NEW PAGE
	DZM	NEW
	LAC	FU	/CHECK IF DOCUMENT MODE
	SZA
	JMS	RESET	/YES - DO AGAIN IN CASE WE ARE STAYING IN IT
	JMP	NEXT
/
	.EJECT
GETRID	XX
	DZM	NEW
	JMS	FLUSH
	LAC	FU
	SZA
	JMS	RESET
	JMP*	GETRID
/
CKNXT	XX
	DZM	MASK
	LAC	CENTPG
	SNA
	JMP*	CKNXT
	JMS	CEND
	JMS	RESET	/DO AGAIN INCASE $FU COMMAND TERMINATED CENTERED PAGE
	JMP*	CKNXT
/
OTAG	JMS	GETRID
	JMS	SHOVE
	LAC	OMTFLG	/OMIT OPTION
	SNA!CLA
	CLC
	DAC	OMTFLG
	JMP	NEXT
/
CSP	LAC	PCNT	/S,D,Y,Z,NE,NO,ON
	SAD	(SY
	DZM	DOUBLE
	SAD	(DY
	ISZ	DOUBLE
	SAD	(YY
	ISZ	NOSP
	SAD	(ZY
	DZM	NOSP
	SAD	(NEY
	ISZ	TT
	SAD	(NON
	ISZ	NOTOUT
	SAD	(OUI
	DZM	NOTOUT
	JMP*	SETIT
/
	.EJECT
/	THIS SUBROUTINE CENTERS THE OUTPUT IMAGE LINE IN OUTIMG
/
CENTIT	XX
	LAC	RECORD	/CENTERING MODE
	AAC	-1	/ACCOUNT FOR UNPACKING CARRIAGE RETURN AS WELL
	TAD	NUMBER	/DETERMINE IF LINE IS TOO LONG
	SMA!TCA
	JMP	PUTOUT	/LINE IS TOO LONG - JUST WRITE IT OUT
	RCR		/ DIVIDE (POSITIVE NUMBER OF SPACES LEFT) BY 2
	SNA!TCA
	JMP	PUTOUT	/LINE IS JUST BIG ENOUGH - WRITE IT OUT
	DAC	RECORD
	LAC	(40
BACK	DAC*	X11	/INSERT SPACES INTO OUTPUT BUFFER
	ISZ	RECORD	/ARE WE FINISHED
	JMP	BACK	/NO
BACK1	LAC*	X10	/GET ACTUAL SOURCE TEXT
	DAC*	X11	/PUT INTO OUTPUT IMAGE FILE
	SAD	(175
	JMP	CENERR
	SAD	(15	/ARE WE FINISHED
	SKP		/YES
	JMP	BACK1	/NO
	JMS	PCK
	JMP*	CENTIT
CENERR	ISZ*	CHANGE	/CANNOT HAVE ALTMODE IN CENTERED LINE
	LAC	(43	/DISPLAY LINE AND GET OUT
	JMS*	ASK
/
CB	LAC	CENTPG	/DID WE JUST CENTER A PAGE
	SNA
	JMP	CBEGIN
	LAC	(NOP
	DAC	CNEWPG	/YES - INHIBIT NEW PAGE COMMAND UPON EXIT FROM CEND
	JMS	CEND
	LAC	NEWP0
	DAC	CNEWPG
CBEGIN	DZM	LINENM
	LAC	CNTS
	DAC	LCNT	/MAYBE DONT NEED THESE TWO LINES
	ISZ	CENTPG
	LAC	(CTABLE	/GET ADDRESS OF LINE ADDRESS TABLE
	DAC	CTPNT
	LAW	-1
	TAD	FREE.L		/ START OF FREE CORE BUFFER
	DAC*	CTPNT
	LAC	(JMS INTERC	/CATCH CENTERED PAGE LINES
	DAC	PUT
	JMP	NEXT
/
	.EJECT
/	THIS SUBROUTINE INTERCEPTS THE CENTERED PAGE LINES AND STORES
/	THEM IN THE FREE CORE BUFFER WITH THE ADDRESS BEING STORED
/	STORED IN CTABLE
/
INTERC	XX
	ISZ	LINENM	/COUNT LINE
	DAC*	(X12	/SET UP APPROPRIATE INPUT BUFFER ADDRESS
	IAC
	DAC	SAVADR
	LAC*	CTPNT	/GET NEXT FREE PLACE IN FREE CORE BUFFER
	DAC*	(X13
	LAC*	SAVADR
	AND	(377000
	LRSS	10
	TCA
	DAC	CNT	/NEG OF NO OF WORDS TRANSFERRED
	LAC*	X12
	DAC*	X13
	ISZ	CNT
	JMP	.-3
	ISZ	CTPNT
	LAC*	CTPNT	/HAVE WE EXCEED NUMBER OF LINES FOR CENTERED PAGE
	SMA
	JMP	.+5
	CLA!IAC		/YES - QUIT
	DAC*	CHANGE
	LAC	(20
	JMS*	ASK
	LAC*	(X13
	DAC*	CTPNT
	AAC	204
	TCA
	TAD	FREE.H
	SMA
	JMP*	INTERC
	JMP	INERR5
/
	.EJECT
/	THIS SUBROUTINE OUTPUTS THE CENTERED PAGE FROM CKNXT
/
CEND	XX
	LAW	-1
	DAC*	CTPNT
	LAC	LINENM	/WERE THERE ANY LINES
	SNA
	JMP	CNEW	/NO - JUST OUTPUT A NEW PAGE IF NECESSARY
	LAC	WRCPB+4	/SAVE CURRENT OUTPUT BUFFER ADDRES IN WRITES TO BE REPLACED
	DAC	STORED	/AFTER THIS CENTERED PAGE RELEASED
	LAW	-PG60	/USUALLY 60 LINES FOR 11" PAGE
	TAD	LINENM	/NO OF LINES TO BE CENTERED
	IAC		/TO BIAS  CENTERING UPWARD IF NECESSARY
	STL		/THE ASSUMPTION IS THAT TOO MANY LINES WILL BE
	RAR		/CAUGHT WHEN THE LINES ARE BEING COLLECTED
	DAC	CBLANK	/DIVIDE BY 2
	TAD	HDSP	/ACCOUNT FOR HEADER SPACES
	SPA		/DO WE NEED MORE THAN THE HEADER SPACES
	JMP	CEND0	/YES - PUT OUT NECESSARY SPACES
	SNA		/ARE THERE JUST ENOUGH
	JMP	.+3	/YES - JUST OUTPUT NEW PAGE
	LAC	CBLANK
	DAC	HEADSP	/ALTER HEADSP SO THAT FOR THIS CENTERED PAGE ONLY THE
	JMS	NEWPG	/APPROPRIATE NO OF SPACES WILL BE FORTHCOMING
	LAC	HDSP
	TCA
	DAC	HEADSP
	JMP	CEND1
/
	.EJECT
CEND0	DAC	CBLANK	/MAYBE A CONFLICT WITH FLAG WHATIF IN NEWPG
	JMS	NEWPG
	JMS	BLANK
	ISZ	CBLANK
	JMP	.-2
CEND1	LAC	(CTABLE-1
	DAC*	(X12
CEND2	LAC*	X12
	SPA!IAC		/ACCOUNT FOR USE OF AUTO INDEX REGISTER WHILE COLLECTING
	JMP	COVER
	DAC	WRCPB+4
	JMS	WRITES
	JMP	CEND2
/
COVER	LAC	STORED
	DAC	WRCPB+4
	LAC	(JMS WRITES
	DAC	PUT
CNEW	LAC	PAGENM
	DAC	NOPGNM
CNEWPG	JMS	NEWPG	/ISSUE A NEW PAGE
	DZM	CENTPG
	DZM*	CTPNT	/GET RID OF END OF TEXT MARKER
	JMP*	CEND
/
	.EJECT
/	$IT ENTRY - INDEX TITLE
/
IT	JMS	GETRID
	LAC	IFLAG	/HAVE WE INCOUNTERED A TITLE PREVIOUSLY
	SZA
	JMP	INERR3	/ERROR - OUT OF SEQUENCE OR MORE THAN ONE TITLE
	JMS	SFILE	/INITIATE INDEX FILE
	LAC	(JMP NEXT
	DAC	ITIN0
	LAC	(JMP ITIN	/GET SET TO INTERCEPT ENTRY OF TITLE TEXT
	DAC	NX1
	LAC	(JMP IOUT	/GET SET TO RESTORE REGULAR PROGRAM FLOW
	DAC	NX2	/WHEN NEXT COMMAND IS ENCOUNTERED
	LAC	(JMP INERR6	/TAKE CARE OF ABNORMAL EOF
	DAC	NX0
	ISZ	IFLAG	/SET FLAG FOR TITLE RECIEVED
/
ITIN	JMS	WRDAT1	/SEND OUT LINE IN BUFFER TO INDEX FILE
ITIN0	JMP	NOT	/MODIFIED TO 'JMP NEXT' IF INDEX TITLE
/
/	COMMON EXIT ROUTINE FOR TERMINATING AN INDEX ENTRY
/
IOUT	TAD	(JMP WHERGO
	DAC	WHERGO
	LAC	IOUT
	DAC	NX2
	LAC	(JMP NOT
	DAC	NX1
	DAC	ITIN0
	LAC	(JMP FINI
	DAC	NX0	/ALLOW FOR NORMAL EXIT UPON EOF
/***	.WRITE	TEMDK5,2,DOLIE,34
/***	.WAIT	TEMDK5
	JMP	NX4
/
	.EJECT
/	$II ENTRY
/
II	JMS	INDEX
	JMS	POVER
	LAC	PGPNT	/SAVE ADDRESS OF 2ND ENTRY THIS $II
	DAC	REMBS
	AAC	-1
	DAC	LASTII
	ISZ	PGPNT	/POINTS TO NEXT AVAILABLE ENTRY IN TABLE
	DZM	FIRST	/MARK LAST COMMAND AS $II
/
/	COMMON EXIT FOR INITATING AN INDEX ENTRY EXCEPT $IE
/
INDOUT	LAC	(JMP IOUT
	DAC	NX2
	JMS	WRDAT1
	JMP	NOT
/
/	$I ENTRY
/
I	JMS	INDEX
	JMS	POVER
	LAC	REMBS	/CHECK FOR PREVIOUS $II
	SNA!CLA!IAC
	JMP	INERR2	/NO PREVIOUS $II
	SAD	FIRST	/WAS LAST COMMAND A $I
	JMP	.+3	/YES
	DAC	FIRST	/NO - SET FLAG
	JMP	.+3	/IGNORE FIX FOR PREVIOUS $I
	LAC	STRPG	/FIX UP 2ND ENTRY FOR PREVIOUS $I
	DAC*	IEFLAG
	LAC	PGPNT
	DAC	IEFLAG	/SAVE THIS ADDRESS FOR USE ON NEXT INDEX COMMAND
	ISZ	PGPNT	/MOVE POINTER TO NEXT FREE PLACE
	JMP	INDOUT
/
/	$IE ENTRY
/
IE	LAC	REMBS
	SNA
	JMP	INERR1
	LAC	STRPG
	DAC*	REMBS	/ALWAYS UPDATE LAST $II 2ND ENTRY UPON $IE
	LAC	FIRST	/CHECK FOR PREVIOUS COMMAND
	SNA!CMA
	JMP	IE1	/LAST COMMAND WAS $II HAVE FINISHED
	LAC	STRPG
	DAC*	IEFLAG	/MUST PUT 2ND ENTRY FOR LAST $I
	LAW	-1
IE1	DAC	FIRST
	JMP	INDOUT
/
/	INDEX SUBROUTINES
/
INDEX	XX
	LAC	(JMP ITIN
	DAC	NX1	/GET SET TO INTERCEPT INDEX ENTRY
	LAC	(JMP INERR6
	DAC	NX0	/TAKE CARE OF PREMATURE EOF
	JMS	GETRID
	JMS	CKNXT
	LAW	-12
	DAC	COUNT
	LAC	IFLAG
	SZA!CMA
	JMP*	INDEX
	DAC	IFLAG
	JMS	SFILE
	JMP*	INDEX
/
POVER	XX
	LAC*	PGPNT	/CHECK FOR END OF TABLE
	SPA
	JMS	PGREV	/YES - WRITE OUT BLOCK OF PAGE NUMBERS
	LAC	STRPG
	DAC*	PGPNT	/STORE CURRENT PAGE NUMBER FOR THIS $I OR $II
	ISZ	PGPNT	/MOVE POINTER TO SECOND ENTRY
	LAC	FIRST	/WAS PREVIOUS COMMAND $IE
	SPA
	JMP*	POVER	/YES - GET OUT
	LAC	REMBS	/IS THIS FIRST $II
	SNA
	JMP*	POVER	/YES - GET OUT
	LAC	STRPG
	DAC*	REMBS	/FIX UP PREVIOUS $II
	JMP*	POVER
/
	.EJECT
PGREV	XX
	LAC*	LASTII
	DAC	TEMP	/SAVE LAST $II FIRST PAGE NO
	LAW	-1
	DAC*	LASTII	/PUT IN EOD OF TABLE MARKER
/***	.TRAN	TEMPDK,1,BLOCK,PGTABL,256
/***	.WAIT	TEMPDK
	ISZ	BLOCK	/MOVE BLOCK NUMBER UP ONE
	LAC	BLOCK
	SAD	(211
	JMP	INERR5	/PAGE NUMBER TABLE OVERFLOW
	LAC	LASTII
	DAC*	(X12	/GET SET TO MOVE REMAINING TABLE NUMBERS TO BEGINNING
	LAC	(PGTABL-1	/OF PGTABL
	DAC*	(X13
	LAC	TEMP
	DAC*	X13	/PUT SAVED 1ST ENTRY IN BEGINNING OF TABLE
	LAC	(PGTABLE+1
	DAC	REMBS	/SET UP POINTER FOR 2ND ENTRY OF LAST $II
PGREV1	LAC*	X12
	SPA
	JMP	PGROUT	/FALL OUT WHEN END OF TABLE REACHED
	DAC*	X13
	JMP	PGREV1
PGROUT	LAC*	(X13
	IAC
	DAC	PGPNT	/SET UP TABLE POINT TO 1ST FREE PLACE
	JMP*	PGREV
/
SFILE	XX
/***	.INIT	TEMDK5,1,START
/***	.ENTER	TEMDK5,IFILE
	LAW	-12
	DAC	COUNT
	LAC	(PGTABL
	DAC	PGPNT
	JMP*	SFILE
/
WRDAT1	XX
/***	.WRITE	TEMDK5,2,BUFFER,56
/***	.WAIT	TEMDK5
	ISZ	COUNT
	SKP
	JMP	INERR4
	JMP*	WRDAT1
/
	.EJECT
/	INDEX ERRORS
/
INERR1	LAC	(21
	JMS*	ASK
	JMP	NEXT	/$IE IGNORED BECAUSE IT IS 1ST INDEX COMMAND
/
INERR2	LAC	(13	/NO PREVIOUS $II COMMAND ENCOUNTERED BEFORE THIS
	ISZ*	CHANGE	/$I COMMAND - TERMINAL
	JMS*	ASK
/
INERR3	LAC	(4	/TITLE OUT OF SEQUENCE OR MORE THAN ONE
	JMS*	ASK	/TITLE - IGNORE UNTIL NEXT COMMAND
	LAC	(JMP NEXT
	DAC	NX1
	JMP	NEXT
/
INERR4	LAC	(11	/TOO MANY LINES IN INDEX ENTRY
	ISZ*	CHANGE	/TERMINAL
	JMS*	ASK
/
INERR5	LAC	(10	/TOO MANY INDEX ENTRIES - TABLE OVERFLOW
	ISZ*	CHANGE
	JMS*	ASK
/
/INDEX	JMS	GETRID	/$II, $I AND $IE COME HERE
	JMS	SHOVE
	LAC	(34	/COMMAND NOT IMPLIMENTED
	JMS*	ASK
	CLA!IAC		/DISPLAY SOURCE LINE
	JMS*	ASK
IN1	JMS	RASCII	/IGNORE INPUT UNTIL END OF FILE OR NEXT COMMAND
	SPA
	JMP	INERR6
	SZA
	JMP	NXT
	JMP	IN1
/
INERR6	ISZ*	CHANGE	/EOF REACHED WHILE GETTING INDEX LINES
	LAC	(35
	JMS*	ASK
/
	.EJECT
/	COME HERE WHEN MODE IS FORMATTED
/
FORMAT	LAC	FU	/ARE WE IN PARAGRAPH MODE?
	SZA
	JMP	FGO	/IN DOCUMENT MODE
	LAC	IMAGE	/IN PARAGRAPH MODE
	SAD	(40	/IS THIS A NEW PARAGRAPH
	SKP
	JMP	FGO	/NO - CARRY ON
	JMS	FLUSH	/GET RID OF RESIDUAL TEXT IF ANY
	JMS	SHOVE	/MAKE SURE THAT BLANK LINE OCCURS BETWEEN GROUPS
	LAC	IMAGE+1	/CHECK IF PARA NEEDS TO BE CHANGED
	SAD	(40
	SKP
	JMP	FOR2
/
	DZM	PARA
FOR0	LAC*	X10	/GET CHARACTER FOR IMAGE
	SAD	(15	/IS IT EOSL
	JMP	FERR1	/BLANK LINE ENCOUNTERED
	SAD	(40
	SKP
	JMP	FOR1
	LAC	(440	/PUT MODIFIED SPACE IN OUTIMG
	DAC*	X11
	ISZ	PARA	/COUNT SPACE
	ISZ	NUMB	/REDUCE CURRENT LINE CHARACTER COUNT
	JMP	FOR0	/CONTINUE
/
FOR1	LAW	-1
	TAD*	(X10
	DAC*	(X10
	JMS	SHORT
	JMP	FGO	/EVERYTHING ALRIGHT - CONTINUE
/
	.EJECT
FERR1	ISZ*	CHANGE
	SAD	(440
	LAC	(54	/INDENTATION TOO LARGE
	LAC	(61	/BLANK LINE ENCOUNTERED
	JMS*	ASK
/
FOR2	LAC	PARA
	DAC	TAB
	DZM	TAB+1
	LAW	-1
	DAC	TAB+2
	LAC	(PARA-1	/SETUP OUTIMG INDENTATION FOR 1ST LINE OF PARAGRAPH
	DAC	POINTS
	JMS	RESET
/
FGO	JMS	TRANSF	/TRANSFER TO OUTIMG_IMAGE
	SAD	(15	/EOSL
	JMP	FCK
	SAD	(700000	/EOG
	JMP	FSTAR
/
	LAC	OPLSAV	/DID WE JUST CONTINUE TO FILL A LINE
	SNA
	JMP	FGO1	/NO - CONTINUE AS USUAL
	LAC	BCKCNT	/DID WE ENCOUNTER A SPACE
	SZA
	JMP	FGO1	/YES - CARRY ON
	LAC	EXACT
	SNA
	JMP	FGO0
	DZM	EXACT
	JMP	FGO1
FGO0	LAC	SPCNT	/DID WE SEND OUT A LINE
	SPA!SNA
	JMP	FGO1	/YES - THIS LINE JUST HAS NO SPACES
	AAC	-1
	DAC	SPCNT
/
	LAC	TEMPS	/NO - SPECIAL CASE
	DAC	BCKCNT
	JMS	FSEE
	SPA
	JMP	FLONG	/LONG LINE - CAN CARRY ON AS USUAL
	LAC	OPLSAV
	DAC	OPLACE
	LAC	(IMAGE-1
	JMP	FSHT0	/CARRY ON AS FOR SHORT LINE
/
	.EJECT
FGO1	DZM	OPLSAV
	JMS	FSEE	/REGULAR OUTPUT LINE AVAILABLE SEE IF LONG OR SHORT
	SMA
	JMP	FSHORT
/
FLONG	LAC	(15	/LONG LINE CAN BE USED
	DAC*	X11	/PUT CARRIAGE RETURN IN OUTIMG
/
FORCOM	JMS	SEND	/SEND LINE OUT, RESET NUMB & X11 AND PUT
			/INDENTATION IN FOR NEXT LINE IF IN DOCUMENT MODE
	JMP	FGO	/CONTINUE
/
FSHORT	LAW	-1	/REDUCE EXPANDABLE SPACES BY 1 AND CHECK FOR NON-ZERO
	TAD	SPCNT
	DAC	SPCNT
	SMA!SZA
	JMP	FSHT	/EVERYTHING ALRIGHT PROCEED
/
	LAC	LONG	/LINE HAS NO EXPANDABLE SPACES
	DAC*	(X10	/RESTORE IMAGE POINTER
	ISZ	SPECAL
	LAC	(15
	DAC*	SPECAL	/PLACE IN OUTIMG FOR CARRIAGE RETURN
NOSPER	LAC	NOSPS	/HAS THIS ERROR OCCURRED IN PREVIOUS LINE
	SZA
	JMP	NOSP1	/YES - JUST ISSUE DITTO
	ISZ	NOSPS
	JMS	PCK
	LAC	(60
	JMS*	ASK
	CLA!IAC
NOSP0	JMS*	ASK
	JMP	FORCOM
/
NOSP1	LAC	(3
	JMP	NOSP0
/
	.EJECT
FSHT	LAC	IPLACE
	SAD	(IMAGE-1	/DID PREVIOUS LINE END EXACTLY
	SKP
	JMP	FSHT0
	LAC	NUMB
	DAC	BCKCNT
	AAC	2
	SMA
	JMP	.+3
	LAC	BCKSAV
	DAC	BCKCNT
	LAC	IPLACE
FSHT0	DAC*	(X10
	LAC	(15
	DAC*	OPLACE
	LAC	JUST
	SZA
	JMS	SMOOTH
	JMP	FORCOM
/
/	COME HERE WHEN EOSL FOUND
/
FCK	LAC	LAST	/DID WE TRANSFER ANY CHARACTERS
	SNA
	JMP	NEXT	/NO - GET ANOTHER LINE
	LAC	LONG	/DID WE GET BOTH A LONG AND SHORT LINE
	SZA
	JMP	FCK7	/YES - DECIDE WHICH TO USE
	LAC	NUMB
	SAD	(-1	/SEE IF THERE IS MORE THAN ONE PLACE LEFT IN LINE
	SKP
	JMP	FCK1	/ALRIGHT - MORE THAN ONE PLACE LEFT
	DAC	BCKCNT	/SAVE IT FOR POSSIBLE R.J.
	LAC	(15
	DAC*	X11	/PUT CARRIAGE RETURN
	LAC	JUST	/DO WE RIGHT JUSTIFY
	SZA
	JMS	SMOOTH
FCK0	LAC	(NOP	/DO NOT ALLOW INSERTING FOR A BLANK LINE FROM FLUSH
	DAC	FLUSH0
	JMS	FLUSH	/JUST GET RID OF EXISTING TEXT
	LAC	FCOM0	/REPLACE INSERTION OF BLANK LINES FROM FLUSH
	DAC	FLUSH0
	JMP	NEXT	/GET ANOTHER LINE
/
	.EJECT
FCK1	LAW	-1	/ONLY SHORT LINE - NEED MORE TO FILL IT
	TAD*	(X10
	DAC	TEMP	/SAVE CURRENT PLACE IN IMAGE
	LAC*	(X11
	IAC
	DAC	TEMP1	/SAVE CURRENT PLACE IN OUTIMG
	DAC	OPLSAV
	LAC	NUMB	/SAVE CHARACTER COUNTER INCASE OF A RESTART
	DAC	TEMPS
	LAC	SPCNT
	DAC	COUNT1
	DZM	REMB
FCK2	LAC*	TEMP	/EXAMINE LAST CHARACTER IN IMAGE
	SAD	(56	/A PERIOD?
	SKP
	SAD	(72	/A COLON?
	JMP	FCK5	/YES - PUT IN 2 SPACES AND GET OUT
	SAD	(40	/A SPACE?
	JMP	FCK4	/YES - SUBRACT SPACE AND FIND NEXT NON SPACE CHARACTER
	AND	(400
	SZA		/IS IT AN ALTERED CHARACTER (IE '.....')
FCK20	JMP	FCK40	/YES - IGNORE THIS ONE AND KEEP LOOKING
	LAC	REMB	/WERE WE PREVIOUSLY LOOKING A ALTERED CHARACTERS
	SZA
	JMP	FCK40	/YES - IGNORE THIS ONE ALSO UNTIL SPACE FOUND
/
FCK22	LAC	(40
FCK3	DAC*	TEMP1	/PUT IN JOINER SPACE
	LAC	TEMP1
	DAC*	(X11	/RESTORE OUTIMG POINTER
	DAC	OPLACE
	LAC	(IMAGE-1
	DAC	IPLACE
	LAC	NUMB	/ SAVE NUMBER OF SPACES NEEDED TO
	DAC	BCKSAV	/ FILL OUT LINE
	LAC	(JMP FCK40
	DAC	FCK20
	ISZ	NUMB
	ISZ	SPCNT
	NOP		/INCASE SPCNT GETS -1
	JMP	NEXT
/
	.EJECT
FCK4	LAC	REMB
	SNA
	JMP	FCK4.
	LAC	(JMP FCK22
	DAC	FCK20
FCK4.	DZM	REMB
	LAW	-1
	TAD	SPCNT
	DAC	SPCNT	/REDUCE EXPANDABLE SPACES BY ONE
	SKP
FCK40	ISZ	REMB
	LAW	-1
	TAD	NUMB
	DAC	NUMB	/REDUCE CHARACTER COUNT BY ONE
	SAD	NUMBER
	JMP	FCKERR	/NO MORE CHARACTERS IN LINE
	LAW	-1
	TAD	TEMP
	DAC	TEMP	/MOVE IMAGE POINTER BACK ONE
	LAW	-1
	TAD	TEMP1
	DAC	TEMP1	/MOVE OUTIMG POINT BACK ONE
	JMP	FCK2
/
FCKERR	LAC*	(X11
	IAC
	DAC	TEMP1	/RESTORE OUTIMG POINTER
	LAC	TEMPS
	DAC	NUMB	/RESTORE CHARACTER COUNTER
	LAW	-1
	TAD	COUNT1
	DAC	SPCNT	/SINCE A NON-EXPANDABLE SPACE INSERTED MAKE SURE
	LAC	(440	/THAT WHEN SPCNT INCREMENTED ITS NOT COUNTED
	JMP	FCK3
/
FCK5	LAC	NUMB	/A PERIOD OR COLON ENDS THIS LINE
	SAD	(-2
	SKP!CLC		/ONLY TWO CHARACTERS LEFT THIS LINE
	JMP	FCK6	/MORE THAN TWO CHARACTERS LEFT THIS LINE
	TAD	TEMP1
	DAC*	(X11	/RESTORE OUTIMG POINTER
	JMP	FCK0
/
	.EJECT
FCK6	LAC	(40	/PUT IN TWO SPACES AND EXIT AS IF ONLY A JOINER SPACE
	DAC*	TEMP1
	ISZ	NUMB
	ISZ	TEMP1
	LAC	(400040
	JMP	FCK3
/
FCK7	LAC	NUMB
	SAD	(-20
	JMP	FCK0
	LAC	TOUT	/DID WE ENCOUNTER A SPACE AFTER EOL
	SPA
	JMP	FCK9	/NO - TREAT AS A SHORT LINE
	JMS	FSEE	/LONG AND SHORT LINE EXIST WITH CARRIAGE RETURN
	SPA		/ENDING LONG LINE
	JMP	FCK0	/LONG LING
	JMP	FSHORT
/
FCK9	LAC	OPLSAV	/DID WE JUST CONTINUE TO FILL A LINE
	SNA
	JMP	FSHORT
	LAC	BCKSAV
	DAC	NUMB
	JMP	FSHORT
/
FSTAR	LAC	FU	/ARE WE IN PARAGRAPH MODE
	SZA
	JMP	FSTAR.	/NO - CARRY ON
	LAC	(16	/EOG FOUND WHILE IN PARAGRAPH MODE
	JMS*	ASK
	LAC	(17	/LINE IN QUESTION IS
	JMS*	ASK
	LAC*	(X11
	DAC	TEMP
	AAC	-1
	DAC*	(X11
	LAC	(15
	DAC*	TEMP
	JMS	PCK
	CLA!IAC
	JMS*	ASK
	JMS	FLUSH	/GET LINE PUT OUT
/
	.EJECT
FWARN	LAC*	X10
	SAD	(15
	JMP	NEXT
	SAD	(40
	SKP
	SAD	(440
	JMP	FWARN	/IGNORE SPACES AFTER EOG
	LAW	-1
	TAD*	(X10
	DAC*	(X10
	JMP	FGO
FSTAR.	LAC	NUMB
	SAD	(-20
	JMP	FSTAR0
	LAC	LONG	/DID WE GET BOTH A LONG AND SHORT LINE
	SZA
	JMP	FSTAR1	/YES
/
FSTAR0	LAC	CNTS0-1	/SHORT LINE
	DAC	CNTS0	/MAKE SURE WE GET QUICK EXIT FROM SEND
	JMS	FLUSH	/GET RID OF RESIDUAL TEXT IF ANY
	LAC	(NOP
	DAC	CNTS0	/RESTORE SEND SUBROUTINE
	JMS	RESET	/SET UP FOR NEXT GROUP
	LAC*	X10	/GET NEXT CHARACTER
	SAD	(40
	JMP	.-2	/IGNORE ANY SPACES
	SAD	(15	/END OF LINE
	JMP	NEXT	/IF EOSL FOUND, GET NEXT LINE
	LAW	-1	/THIS CODE EXECUTED IF EOG ENCASED IN INPUT LINE
	TAD*	(X10
	DAC*	(X10	/RESTORE IMAGE POINTER
	JMP	FGO
/
FSTAR1	JMS	FSEE
	SPA
	JMP	FSTAR0	/LONG LINE (TREATED AS SHORT LINE IN THIS CASE)
	JMP	FSHORT	/SHORT LINE, PROGRAM WILL RETURN TO FSTAR WHEN
			/EOG INDICATOR ENCOUNTERED AGAIN
/
	.EJECT
FINI	JMS	GETRID
	JMS	CKNXT
	LAC	WHATIF
	SZA
	JMS	NEWPG
	CAL	CLOSE
	JMS	WTFOR
	LAC	IFLAG
	SNA		/DO WE HAVE AN INDEX FILE
	JMP	FINIS	/NO
	LAC	STRPG
	DAC*	REMBS	/ FIX UP LAST $II
	LAC	FIRST
	SNA		/IF LAST COMMAND WAS $II - THEN CLOSE FILE AND CONTINUE
	JMP	.+3
	LAC	STRPG	/LAST COMMAND WAS $I
	DAC*	IEFLAG	/FIX UP 2ND ENTRY FOR THIS COMMAND
/
INOUT	LAC	(DOLIE-1
	JMS	INTERC
	LAC	(BUFFER-1
	JMS	INTERC
/***	.TRAN	TEMPDK,1,BLOCK,PGTABL,256
/***	.WAIT	TEMPDK
/***	.CLOSE	TEMPDK
/
/	ACTUAL OUTPUT CODE NOT WRITTEN YET
/
FINIS	CAL	(10		/ TASK EXITS HERE
/
	.EJECT
/	THIS ROUTINE READS FROM SOURCE FILE, CHECKS FOR END OF FILE AND
/	UNPACKS LINE INTO IMAGE BUFFER
/
RASCII	XX
	CAL	READ		/ GET A LINE FROM SOURCE FILE
	JMS	WTFOR
	LAC	BUFFER	/CHECK FOR END OF FILE
	AND	(7
	SAD	(5
	JMP	OUT
RAS1.1	JMS	UNPCK	/UNPACK LINE INTO IMAGE BUFFER
	DZM	PCNT
	LAW	777760
	AND	BUFFER+2
	SAD	(221360	/CHECK FOR COMMENT - $/
	JMP	RASCII+1	/IGNORE COMMENT LINES
	AND	(774000
	SAD	(220000	/CHECK FOR COMMAND - $
	JMS	SEARCH	/SET COMMAND POINTER IF A VALID COMMAND
	CLC
LCNT	JMS	CNTIT	/COUNT LINES
	LAC	PCNT
	JMP*	RASCII
OUT	CLC		/NEG AC TO INDICATE END OF FILE
	JMP*	RASCII
/
/DEBUG	.BLOCK	50	/ THIS BLOCK NOT USEFUL WHEN DDT NOT AVAILABLE
/
	.EJECT
SEARCH	XX
	LAC	(MTABLE-1
	DAC*	(X13
S01	ISZ	PCNT	/CHECK FOR SINGLE CHARACTER COMMAND
	LAC*	X13
	SAD	BUFFER+2
	JMP	S02	/FOUND A MATCH
	SNA		/END OF SINGLE CHARACTER GROUP
	JMP	S04+1
	LAC*	X13	/SKIP SECOND WORD
	JMP	S01
/
S02	LAC	(700000
	AND	BUFFER+3	/CHECK SECOND WORD OF SINGLE CHARACTER COMMAND
	SAD*	X13
	JMP*	SEARCH	/FOUND A MATCH
	JMP	S01
/
S04	ISZ	PCNT
	LAC*	X13	/CHECK FOR DOUBLE CHARACTER COMMAND
	SAD	BUFFER+2
	JMP	S05
	SNA		/END OF DOUBLE CHARACTER COMMAND GROUP
	JMP	S06+1
	LAC*	X13	/SKIP SECOND WORD
	JMP	S04
/
S05	LAW	777400
	AND	BUFFER+3	/ CHECK SECOND WORD
	SAD*	X13
	JMP*	SEARCH
	JMP	S04
/
S06	ISZ	PCNT	/CHECK FOR TRIPLE CHARACTER COMMAND
	LAC*	X13
	SAD	BUFFER+2
	JMP	S07
	SNA
	JMP	S08+1
	LAC*	X13
	JMP	S06
/
S07	LAC*	X13	/CHECK FOR SECOND WORD OF TRIPLE CHARACTER COMMAND
	SAD	BUFFER+3
	JMP*	SEARCH
	JMP	S06
/
	.EJECT
S08	ISZ	PCNT
	LAC	(IMAGE+2
	DAC	POINT	/CHECK FOR $FU
	LAC	BUFFER+2
	SAD*	X13
	SKP		/FOUND A MATCH
	JMP	S10
	LAC	BUFFER+3
	AND	(700000
	SAD*	X13
	SKP		/FOUND $FU
	JMP	SEXIT
	ISZ	POINT
S09	LAC	(TAB
	DAC	GETPNT
	LAC	PCNT
	SAD	(FUU
	JMP	SGET
	SAD	(ENDD
	JMP	.+4
	LAC	(TABLE
	DAC	GETPNT
	JMP	SGET
	LAC	(SPTABL
	DAC	GETPNT
SGET	LAC	POINT
	JMS	GET	/GET A NUMBER
	SNA!SPA
SEXIT	DZM	PCNT	/NOT A VALID SEQUENCE
	JMP*	SEARCH
/
S10	LAC*	X13
	ISZ	PCNT
	LAC*	X13
	SNA
	JMP	S12+1
	DAC	CKNXT
	LAC	BUFFER+2
	AND	(777760
	SAD	CKNXT
	JMP	S09
	JMP	S10
/
S12	ISZ	PCNT
	LAW	-1
	TAD	POINT
	DAC	POINT
	JMP	S09
/
	.EJECT
MTABLE	.ASCII	'$U'<15>		/1 - T
	.ASCII	'$F'<15>		/2 - T
CYES	.ASCII	'$C'<15>		/3 - T
	.ASCII	'$N'<15>		/4
	.ASCII	'$M'<15>		/5
OMT	.ASCII	'$O'<15>		/6 - T
SYES	.ASCII	'$S'<15>		/7
DYES	.ASCII	'$D'<15>		/10
YYES	.ASCII	'$Y'<15>		/11
ZYES	.ASCII	'$Z'<15>		/12
INUM0	.ASCII	'$I'<15>		/13 - T
	.ASCII	'$J'<15>		/14
	.ASCII	'$E'<15>		/15
	.ASCII	'$T'<15>		/16
	.ASCII	'$R'<15>		/17
	0
	.ASCII	'$NT'<15>	/20
	.ASCII	'$NP'<15>	/21 - T
	.ASCII	'$NM'<15>	/22
IINUM0	.ASCII	'$II'<15>	/23 - T
IENDS	.ASCII	'$IE'<15>	/24 - T
	.ASCII	'$NJ'<15>	/25
	.ASCII	'$IT'<15>	/26 - T
NEYES	.ASCII	'$NE'<15>	/27
	.EJECT
CPYES	.ASCII	'$CP'<15>	/30 - T
	.ASCII	'$NN'<15>	/31
NONES	.ASCII	'$NO'<15>	/32
ALLSS	.ASCII	'$ON'<15>	/33
	.ASCII	'$NR'<15>	/34
	0
NWANTS	.ASCII	'$NPN'<15>	/35
YWANTS	.ASCII	'$YPN'<15>	/36
	0
FUS	.ASCII	'$FU'	/37 - T (CHECK 1ST WORD AND 2ND ANDED WITH 700000
	.ASCII	'$W'	/40  (CHECK 1ST WORD ANDED WITH 777760)
	.ASCII	'$N'	/41
	.ASCII	'$H'	/42
	.ASCII	'$L'	/43
	.ASCII	'$S'	/44
ENDS	0		/45 - SPACES REQUEST
/
OMITS=OMT-MTABLE/2+1
SY=SYES-MTABLE/2+1
DY=DYES-MTABLE/2+1
YY=YYES-MTABLE/2+1
ZY=ZYES-MTABLE/2+1
INUM=INUM0-MTABLE/2+1
NEY=NEYES-MTABLE-1/2+1
CUU=CYES-MTABLE/2+1
IEND=IENDS-MTABLE-1/2+1
IINUM=IINUM0-MTABLE-1/2+1
NON=NONES-MTABLE-1/2+1
OUI=ALLSS-MTABLE-1/2+1
NWANT=NWANTS-MTABLE-2/2+1
YWANT=YWANTS-MTABLE-2/2+1
CU=CPYES-MTABLE-1/2+1
FUU=FUS-MTABLE-3/2+1
ENDD=ENDS-MTABLE-3/2+1
/
	.EJECT
/	THIS SUBROUTINE COUNTS SOURCE LINES AND PUTS IMAGE IN EMPTY BUFFER
/	0 ENTRY = FROM FORMATTED CODE (NO LINE INCREMENT NEEDED)
/	-1 ENTRY= FROM RASCII (INCREMENT AND PROCESS)
/	+ VE ENTRY = FROM FORMATTED CODE WHERE OUTPUT LINE CONSISTS OF
/		MORE THAN ONE SOURCE LINE
/
CNTIT	XX
	DAC	CKNXT
	LAC	(EMPTY+6
	DAC	TEMP
	LAC	(15
	DAC*	TEMP
	LAC	CKNXT	/CHECK ENTRY NUMBER
	SMA
	JMP	CNT2
	ISZ	LINEN	/IF NEG, INCREMENT AND CONVERT LINE NUMBER
CNT00	LAC	LINEN
	STL
	JMS*	OCTDEC
	EMPTY
	JMP*	CNTIT
/
CNT2	SNA
	JMP	CNT00	/IF ONLY ZERO, THEN DON'T INCREMENT LINE NUMBER
	LAC	LINEN	/+ ENTRY MEANS MORE THAN ONE SOURCE REQD FOR THIS LINE
	STL
	JMS*	OCTDEC
	EMPTY
	LAC	(55	/HYPHEN
	DAC*	TEMP
	LAC	(EMPTY+15
	DAC	TEMP
	LAC	(15
	DAC*	TEMP
	LAC	CKNXT
	TAD	LINEN
	DAC	LINEN
	STL
	JMS*	OCTDEC
	EMPTY+7
	LAC	(EMPTY+7
	DAC	TEMP
CNT5	LAC*	TEMP
	AND	(77
	SAD	(40
	SKP
	JMP*	CNTIT
	DZM*	TEMP
	ISZ	TEMP
	JMP	CNT5
/
	.EJECT
/	THIS SUBROUTINE TRANSFERS CHARACTERS FROM IMAGE TO OUTIMG
/	AND RETURNS WHEN EITHER A) CARRIAGE RETURN FOUND (EOSL)
/	OR B) 1ST SPACE PAST LEGITIMATE EOL ENCOUNTERED (WILL EXIT
/	AFTER 16 CHARACTERS IF NO SPACE ENCOUNTERED)
/
/	IPLACE= PLACE IN IMAGE WHERE 1ST SPACE BEFORE EOL OCCURS
/	OPLACE= PLACE IN OUTIMG WHERE 1ST SPACE BEFORE EOL OCCURS
/	SPCNT= NUMBER OF EXPANDABLE SPACES ENCOUNTERED
/	BCKCNT= NUMBER OF CHARACTERS BEFORE EOL TO 1ST SPACE
/	LONG= FLAG FOR LONG LINE EXISTS (0=NO, 1=YES)
/
TRANSF	XX
	DZM	TOUT	/FLAG FOR EXIT ON LONG LINE
	DZM	LONG
	DZM	LAST
	DZM	BCKCNT
	LAC*	X10
	SAD	(40	/THROW AWAY PRECEEDING SPACES
	JMP	.-2
	SKP
/
TBACK	LAC*	X10	/GET CHARACTER FROM IMAGE
	SAD	(15	/IS IT EOSL (END OF SOURCE LINE)
	JMP*	TRANSF
	SAD	(40	/IS IT A SPACE?
	JMP	TSPACE
	SAD	(700000	/IS IT EOG (END OF GROUP)
	JMP*	TRANSF
	DAC	LAST	/SAVE CHARACTER
TIN	DAC*	X11	/STORE CHARACTER IN OUTIMG
	DZM	NONE	/INDICATE RESIDUAL TEXT EXISTS
	ISZ	NUMB	/HAVE WE FILLED THE LINE
	JMP	TBACK	/NO - CONTINUE
/
	LAC	TOUT	/CHECK IF NUMBER HAS RUN OUT ONCE BEFORE
	SPA
	JMP*	TRANSF	/YES
	LAC*	(X10
	DAC	LONG
	LAC*	(X11
	DAC	SPECAL
	LAW	-20
	DAC	NUMB	/ALLOW FOR 16 CHARACTERS PAST EOL
	LAW	-1
	DAC	TOUT
	JMP	TBACK
/
	.EJECT
TSPACE	SAD	LAST	/WAS PREVIOUS CHARACTER A SPACE
	JMP	TYES	/PUT IN MODIFIED SPACE
	ISZ	TOUT	/COUNT SPACE OR SKIP OUT IF PAST EOL
	SKP
	JMP	TEND
	LAC	NUMB
	DAC	BCKCNT	/SAVE NUMBER OF CHARACTERS LEFT
	DZM	BCKSAV
	ISZ	SPCNT	/COUNT EXPANDABLE SPACE
	LAC*	(X11
	IAC
	DAC	OPLACE	/SAVE EOOL (END OF OUTPUT LINE)
	LAC*	(X10
	DAC	IPLACE	/SAVE RESTART PLACE IN IMAGE IF SHORT LINE USED
	LAC	(40	/RESTORE AC
	JMP	TIN-1
/
TYES	LAC	(400040
	JMP	TIN
/
TEND	LAC	NUMB
	SAD	(-20
	SKP
	JMP*	TRANSF
	LAC*	(X11
	IAC
	DAC	OPLACE
	DZM	BCKCNT
	ISZ	EXACT
	LAC*	(X10
	DAC	IPLACE
	JMP*	TRANSF
/
	.EJECT
/	THIS ROUTINE COUNTS THE SOURCE LINES, PACKS UP OUTIMG
/	WRITES OUT LINE AND IF IN DOCUMENT MODE, SETS UP NEXT LINE'S
/	INDENTATION
/
SEND	XX
	LAC	JUST
	SNA
	DZM	SPCNT	/ZERO EXPANDABLE SPACE COUNTER IF NOT R.J.
	LAC	LINCNT
	SAD	(1	/DID WE ONLY HAVE ONE LINE SINCE THE LAST ONE
	LAW	-1	/YES - ENTER IN ORDINARY WAY
CNTS	JMS	CNTIT
	DZM	LINCNT
	JMS	PCK
	JMS	WRITES
	LAC	(OUTIMG-1
	DAC*	(X11
	LAC	NUMBER
	DAC	NUMB
	LAC	FU
	SNA
	JMP*	SEND
CNTS0	NOP		/A 'JMP* SEND' WILL BE INSERTED IF A RESET REQUIRED
	LAC*	POINTS
	SNA!CMA
	JMP*	SEND	/GO AWAY IF 0 INDENTATION IS REQUESTED
	IAC
	DAC	CNT
	LAC	(440
SEND0	DAC*	X11
	ISZ	NUMB
	SKP
	JMS	SHORT	/IF THIS IS EXECUTED, THEN WILL HAVE TERMINAL
	ISZ	CNT		/EXIT FROM SHORT
	JMP	SEND0
	JMS	SHORT
	JMP*	SEND
/
	.EJECT
/	THIS ROUTINE CHECKS FOR TOO LARGE INDENTATION
/	THERE MUST BE AT LEAST 16 CHARACTERS LEFT IN LINE
/
SHORT	XX
	LAC	NUMB
	AAC	21
	SPA
	JMP*	SHORT
	LAC	(54
	ISZ*	CHANGE
	JMS*	ASK
/
/	THIS ROUTINE GETS RID OF RESIDUAL TEXT WHEN:
/	A) NEW COMMAND ENCOUNTERED
/	B) EOG FOUND
/	C) EOL COINCIDES WITH EOSL
/
FLUSH	XX
	LAC	NONE	/DOES ANY RESIDUAL TEXT EXIST
	SZA
	JMP	FLUSH1	/NO
	DZM	SPCNT	/ZERO EXPANDABLE SPACES COUNTER
	LAC	(15
	DAC*	X11
	JMS	SEND
FLUSH0	JMS	SHOVE	/REPLACED WITH 'NOP' IF LINE IS JUST LONG ENOUGH
	ISZ	NONE
	JMP*	FLUSH
/
FLUSH1	LAC	NUMBER
	DAC	NUMB
	LAC	(OUTIMG-1
	DAC*	(X11
	JMP*	FLUSH
/
/	THIS ROUTINE INSERTS A BLANK LINE BETWEEN GROUPS OR PARAGRAPHS
/	IF OPTION $Y IS IN EFFECT
/
SHOVE	XX
	LAC	NOSP
	SNA
	JMP*	SHOVE
	LAC	DIDWE
	SNA
	JMS	BLANK
	JMP*	SHOVE
/
	.EJECT
/	THIS ROUTINUE RESETS THE DOCUMENT TAB TABLE AND FILLS IN
/	1ST LINE'S INDENTATION.  ALSO CALLED WHEN NEW PARAGRAPH STARTED
/	TO PUT IN INDENTATION
/
RESET	XX
	LAC*	(X11
	SAD	(OUTIMG-1
	SKP
	JMP	RESET4	/WE HAVE ALREADY BEEN HERE
	ISZ	POINTS
RESET3	LAC*	POINTS
	SNA		/CHECK FOR 0 INDENTATION REQUEST
	JMP	RESET2	/HAVE 0 INDENTATION MOVE POINTS AND EXIT
	SMA!CMA
	JMP	RESET0
	LAW	-2
	TAD	POINTS
	DAC	POINTS
	JMP	RESET3
RESET0	IAC
	DAC	CNT
	LAC	(440
RESET1	DAC*	X11
	ISZ	NUMB
	SKP
	JMS	SHORT	/DEFINITELY WILL NOT RETURN AFTER THIS CALL - ERROR
	ISZ	CNT
	JMP	RESET1
	JMS	SHORT
RESET2	ISZ	POINTS
	JMP*	RESET
RESET4	LAC	OUTIMG
	SAD	TABIT
	SKP
	JMP*	RESET
	LAC	(OUTIMG-1
	DAC*	(X11
	JMP	RESET3-1
/
	.EJECT
/	THIS ROUTINE DETERMINES WHICH IS THE OPTIUM LINE IF LONG
/	AND SHORT LINES ARE PERMISSIBLE
/
/	EXIT = 0 OR + THEN SHORT LINE
/	EXIT = -VE THEN LONG LINE
/
FSEE	XX
	LAC	TT	/ARE LONG LINES PERMISSIBLE
	SZA
	JMP*	FSEE	/NO
	LAC	NUMB	/DID A SPACE OCCUR AFTER EOL
	SNA		/WILL BE <16
	JMP*	FSEE	/NO BECAUSE NUMB HAS RUN OUT
	AAC	20	/+ NO OF CHARACTERS AFTER EOL
	TAD	BCKCNT	/- NO OF CHARACTERS BEFORE EOL
	JMP*	FSEE
/
/	THIS SUBROUTINE RIGHT JUSTIFIES TEXT IN OUTIMG
/
SMOOTH	XX
	LAC	BCKCNT
SM0	DAC	TEMP	/NEG NUMBER OF EXTRA SPACES REQD THIS LINE
	SNA		/DO WE NEED ANY SPACES ADDED
	JMP	SMOUT	/NO - GET OUT
	TAD	SPCNT	/POST NUMBER OF EXPANDABLE SPACES IN THIS LINE
	DAC	TEMP1	/SAVE THIS NUMBER
	SMA!SZA	/IF NEG OR ZERO - ALL SPACES IN LINE MUST BE EXPANDED
	JMP	DECIDE	/IF POST - THERE ARE MORE AVAILABLE SPACES IN LINE THAN NEEDED
	LAC	SPCNT	/DID THIS LINE HAVE ANY SPACES
	SZA
	JMP	SM2	/YES
	LAC	(JMP SM1
	DAC	NOSP0+1	/SET UP RETURN FROM ERROR INDICATION
	JMP	NOSPER
SM1	LAC	(JMP FORCOM
	DAC	NOSP0+1	/FIX UP ORIGINAL PROGRAM FLOW
	JMP	SMOUT	/CARRY ON
SM2	JMS	ALL	/INCREMENT ALL EXPANDABLE SPACES BY ONE
	LAC	TEMP1	/GET BACK REDUCED NUMBER OF SPACES NEEDED NOW
	JMP	SM0	/CONTINUE
/
	.EJECT
/	TEMP=NEG OF NUMBER OF EXPANDABLE SPACES REQD
/	TEMP1=POST NUMBER OF SPACES EXTRA THAT DONT NEED TO BE EXPANDED
/
DECIDE	LAC	(OUTIMG-1
	DAC*	(X12	/POINT TO OUTPUT BUFFER
	LAC	(TEMIMG-1
	DAC*	(X13	/POINT TO TEMPORARY BUFFER
	ISZ	WHICH	/-1=EXPAND STARTING AT END OF LINE
			/ANYTHING ELSE=EXPAND AT BEGINNING OF LINE
	JMP	BEGIN
/
	LAC	TEMP1
	TCA
	DAC	TEMP1	/MOVE DOWN IN OUTPUT BUFFER SKIPPING PAST THOSE
			/SPACES THAT DONT NEED TO BE EXPANDED
	LAC*	X12
	DAC*	X13
	SAD	(40
	ISZ	TEMP1
	JMP	.-4
	JMP	BEGIN2
/
BEGIN	LAW	-1
	DAC	WHICH	/ENSURE NEXT LINE INSERTS COME AT END OF LINE
BEGIN2	LAC*	X12
	DAC*	X13
	SAD	(40
	SKP
	JMP	BEGIN2
	LAC	(440	/INSERT A NON-EXPANDABLE SPACE
	DAC*	X13
	ISZ	TEMP
	JMP	BEGIN2
	LAC*	X12	/NOW MOVE DOWN TO THE END OF THE LINE
	DAC*	X13
	SAD	(15
	SKP
	JMP	.-4
	JMS	MOVEBK	/MOVE LINE BACK TO OUTIMG
SMOUT	DZM	SPCNT	/ ZERO EXPANDABLE SPACE COUNTER FOR NEXT COMPLETE LINE
	JMP*	SMOOTH
/
	.EJECT
/	THIS ROUTINE MOVES IMAGE TEXT FROM TEMIMG TO OUTIMG
/
MOVEBK	XX
	LAC	(TEMIMG-1
	DAC*	(X12
	LAC	(OUTIMG-1
	DAC*	(X13
	LAC*	X12
	DAC*	X13
	SAD	(15
	JMP*	MOVEBK
	JMP	.-4
/
/	THIS SUBROUINE EXPANDS ALL EXPANDABLE SPACES BY ONE
/
ALL	XX
	LAC	(TEMIMG-1
	DAC*	(X13
	LAC	(OUTIMG-1
	DAC*	(X12
/
ALL0	LAC*	(X13
	SAD	(WAITS
	JMP	ALL2
	LAC*	X12
	DAC*	X13
	SAD	(40
	SKP
	JMP	ALL1
	LAC	(440	/PUT IN EXTRA NON-EXPANDABLE SPACE
	DAC*	X13
	JMP	ALL0
/
ALL2	LAC	ALLS
	DAC*	PUTIT
	ISZ*	CHANGE
	LAC	(50
	JMS*	ASK	/PUT PROGRAM SHOULD NOT BE HERE
/
ALL1	SAD	(15
	SKP
	JMP	ALL0
	JMS	MOVEBK
	JMP*	ALL
/
	.EJECT
/SUBROUTINE TO CONVERT STRINGS OF DECIMAL IMAGE ASCII NOS TO SINGLE
/OCTAL REPRESENTATIONS 'GETPNT' MUST BE SETUP PRIOR TO ENTRY
/
GET	XX	/ENTER WITH IMAGE ADDRESS IN AC
	DAC	CKNUM
	AAC	-1
	DAC*	(X13	/SET UP POINTER TO IMAGE TEXT
	DAC	PNTR2	/USED TO RETRIEVE OCTAL NUMBER IN CONVRT
	DAC	PNTR1	/USED TO STORE OCTAL NUMBER BACK IN IMAGE
	DZM	SAVEIT	/USED TO COUNT NO OF COMPLETE NOS GOTTEN
	LAC	GETPNT
	DAC	TEMP	/SAVE OUTPUT TABLE ADDRESS FOR LATER FUNCTION CKS
GET0	LAC	(UNITS
	DAC	PNTR	/USED TO POINT TO MULTIPLIER
GET1	LAC*	X13	/GET A CHARACTER
	SAD	(73	/A SEMI COLON?
	JMP	GETMOR	/YES - MORE NUMBERS TO COME
	SAD	(15	/END OF STRING?
	SKP
	SAD	(175
	JMP	GOTALL	/YES - CONVERT LAST NUMBER AND DO FUNCTION CK
	JMS	ISIT	/IS CURRENT CHARACTER A DIGIT
	SPA
	JMP*	GET	/NO GETOUT
	ISZ	PNTR1
	DAC*	PNTR1	/STORE OCTAL NUMBER BACK IN IMAGE
	LAW	-1
	TAD	PNTR
	DAC	PNTR	/MOVE MULTIPLICAN POINTER BACK ONE
	JMP	GET1	/GET ANOTHER CHARACTER
/
GETMOR	ISZ	PNTR1	/MOVE PAST ';'
	JMS	CONVRT	/MAKE A SINGLE OCTAL NO FROM STRING
	JMP	GET0
/
	.EJECT
GOTALL	LAC*	CKNUM
	SAD	(15
	SKP!CLC
	JMP	GOTS
	JMP*	GET
GOTS	JMS	CONVRT	/MAKE A SINGLE OCTAL NO FROM STRING
	LAW	-1
	DAC*	GETPNT	/PUT END OF LIST MARKER IN APPROPRIATE TABLE
/
	LAC	TEMP	/CHECK FOR FUNCTION
	SAD	(TAB	/DOCUMENT FORMAT
	JMP	FUXX
	SAD	(SPTABL	/SPACES REQUEST
	JMP	SXX
	LAC	SAVEIT	/ANY OTHER SHOULD HAVE ONE NUMBER
	SAD	(1
	JMP*	GET	/OK - GET OUT
/
NERR	DAC*	CHANGE	/INAPPROPRIATE NO OF NOS FOR FUNCTION
	LAC	(57
	JMS*	ASK
/
FUXX	LAW	-26	/THERE CAN BE ONLY A MAX OF 22 NOS
	TAD	SAVEIT
	SMA!SZA
	JMP	NERR
	LAC	SAVEIT	/ALSO THERE MUST BE AN EVEN NUMBER OF NOS
	AND	(1
	SZA
	JMP	NERR
	JMP	GETOUT
/
SXX	LAW	-2	/CAN ONLY HAVE A MAX OF 2 NUMBERS FOR SPACES REQUEST
	TAD	SAVEIT
	SMA!SZA
	JMP	NERR
GETOUT	CLA!IAC
	JMP*	GET
/
	.EJECT
/	CHECKS A CHARACTER IN AC FOR BEING A SINGLE DIGIT FROM 0-9
/	0 OR += A NUMBER; NEG AC=NOT A NUMBER
/
ISIT	XX
	AAC	-60	/IS IT LESS THAN 60
	SPA
	JMP	ERR
	AAC	-12
	SMA
	JMP	ERR
	AAC	12	/0 OR + AC OK - DIGIT RETURNED TO AC
	JMP*	ISIT
/
ERR	CLC		/MAKE AC NEG - INDICATES NOT A DIGIT
	JMP*	ISIT
/
/	THIS ROUTINE DOES THE ACTUAL CONVERSION FROM STRING
/	TO SINGLE OCTAL REPRESENTATION
/
CONVRT	XX
	ISZ	SAVEIT
	LAC	PNTR
	DAC*	(X12
	DZM	NUMB
CON0	ISZ	PNTR2
	LAC*	PNTR2	/GET MULTIPLICAN
	DAC	CONPL
	LAC*	X12	/GET MULTIPLIER
	SNA!CLL
	JMP	CONOUT
	MUL
CONPL	XX
	LACQ
	TAD	NUMB
	DAC	NUMB
	JMP	CON0
/
CONOUT	LAC	NUMB
	DAC*	GETPNT
	ISZ	GETPNT
	JMP*	CONVRT
/
	.EJECT
/	UNPACKING ROUTINE
/
UNPCK	XX
	DZM	RECORD
	DZM	FRSTSP
	LAC	(BUFFER+1
	JMS	STUNPK
	LAC	(IMAGE-1
	DAC*	(X13	/COULD ADD A 'DZM MASK' IF NECESSARY
AGN	ISZ	RECORD
	JMS	UNPACK
	DAC	IMAGE-1
TCONT0	SAD	(15	/EOL
	SKP
	SAD	(175	/EOL
	JMP	UNPKED
	SAD	(47	/A QUOTE?
	SKP
	SAD	(135	/A RIGHT SQUARE BRACKET?
	SKP
	SAD	(52	/A STAR?
	JMP	SECOND
	SAD	TABIT	/A TAB?
	SKP
	JMP	AGN.
	LAW	-1	/YES HAVE A TAB
	TAD	RECORD
	CLL
	IDIV;	10
	AAC	-10
	DAC	IMAGE-1	/STORE REMAINDER (THIS IS NO OF SPACES TO BE ADDED)
	LAC	IMAGE-2	/DO WE NEED AN EXPANDABLE SPACE
	SAD	(40
	SKP
	SAD	(440
	JMP	TCONT	/NO - JUST PUT IN AS MANY NON-EXPANDABLE SPACES AS NECESSARY
	LAC	(40	/YES - ADD EXPANDABLE SPACE
	XOR	MASK	/MUST USE MASK IN CASE SINGLE QUOTE IN EFFECT
	DAC*	X13
	ISZ	IMAGE-1
	SKP
	JMP	AGN	/ONLY ONE SPACE REQ'D
/
	.EJECT
TCONT	ISZ	RECORD
	LAC	(440
	DAC*	X13
	ISZ	IMAGE-1
	SKP
	JMP	AGN
	ISZ	RECORD
	JMP	TCONT+1
AGN.	JMP	AGN0-1	/IS REPLACED BY 'NOP' IF $R IS IN FORCE
	SAD	(40	/IS THIS CHARACTER A SPACE
	ISZ	FRSTSP	/YES - SET FLAG
	SAD	(51	/IS IT A LEFT BRACKET
	SKP
	SAD	(56	/A PERIOD?
	SKP
	SAD	(57	/A SLASH?
	JMP	FRSTCK	/YES - SEE WHAT NEXT CHARACTER IS IF NECESSARY
/
	XOR	MASK
AGN0	DAC*	X13	/STORE CHARACTER AND CONTINUE
	DAC	IMAGE-2	/SAVE LAST CHARACTER STORED
	JMP	AGN
/
FRSTCK	LAC	FRSTSP	/HAVE WE ENCOUNTERED A SPACE ALREADY
	SNA
	JMP	SECPL+1	/NO
	LAC	IMAGE-1	/YES - CONTINUE AS USUAL
SECPL	JMP	AGN0-1
/
	ISZ	FRSTSP	/NO - SET FLAG AS IF A SPACE WAS ENCOUNTERED
	LAC	IMAGE-1	/GET BACK CURRENT CHARACTER
	XOR	MASK
	DAC*	X13	/STORE IT
	ISZ	RECORD	/COUNT NEXT CHARACTER
	JMS	UNPACK	/GET NEXT CHARACTER
	SAD	(40	/IS IT A SPACE?
	SKP
	JMP	TCONT0-1	/NO - CONTINUE AS USUAL
	LAC	(440	/GET SET TO STORE ALTERED SPACE
	JMP	AGN0
/
	.EJECT
SECOND	JMS	UNPACK	/GET NEXT CHARACTER
	DAC	IMAGE-2	/STORE IT
	SAD	(15
	SKP
	SAD	(175
	JMP	SECOT	/EOSL - STORE PREVIOUS CHARACTER & GET OUT
	SAD	(47	/A SECOND QUOTE?
	SKP
	SAD	(135	/A SECOND RIGHT SQUARE BRACKET?
	JMP	SEC1	/YES - SAVE ONE AND CONTINUE
	SAD	(57	/A SLASH?
	JMP	EOG	/YES - REPLACE WITH 452 MARKER AND CONTINUE
SEC0	LAC	IMAGE-1	/GET BACK PREVIOUS CHARACTER
	SAD	(47	/A SINGLE QUOTE?
	JMP	CHGMSK	/YES - CHANGE MASK
	SAD	(135	/A SINGLE RIGHT SQURARE BRACKET
	JMP	.+5	/YES - GET SET TO REMOVE SOURCE LINE NUMBERS
	XOR	MASK
	DAC*	X13	/STORE PREVIOUS CHARACTER
	ISZ	RECORD	/COUNT NEXT CHARACTER
	LAC	IMAGE-2	/GET BACK CURRENT CHARACTER
	JMP	AGN0-1
SEC1	SAD	IMAGE-1
	JMP	AGN0
	JMP	SEC0
T0	LAW	-1
	TAD	RECORD
	DAC	RECORD	/REDUCE CHARACTER COUNTER BY ONE
	LAC*	(X13
	DAC	PNTR	/SAVE CURRENT ADDRESS IN IMAGE BUFFER
/
TAKOUT	LAC*	PNTR
	SAD	(133	/A LEFT SQUARE BRACKET?
	JMP	ELM
	LAW	-1
	TAD	PNTR
	DAC	PNTR
	LAW	-1
	TAD	RECORD
	DAC	RECORD
	JMP	TAKOUT
/
	.EJECT
ELM	LAW	-1
	TAD	PNTR
	DAC	PNTR
	LAC*	PNTR
	SAD	(40
	SKP
	JMP	ELM0
	LAW	-1
	TAD	RECORD
	DAC	RECORD
	JMP	ELM
/
ELM0	LAC	PNTR
	DAC*	(X13
	LAC	IMAGE-2	/GET BACK LAST CHARACTER
	SAD	(15
	SKP
	SAD	(175
	JMP	UNPKED	/EOSL - GET OUT
	JMP	AGN
/
	.EJECT
SECOT	LAC	IMAGE-1	/GET BACK PREVIOUS CHARACTER
	SAD	(47	/A QUOTE?
	JMP	CHGMSK	/ALTER MASK, THEN STORE CARRIAGE RETURN AND GET OUT
	SAD	(135	/A RIGHT SQUARE BRACKET
	JMP	T0	/MUST FIRST TAKOUT TO LEFT BRACKET BEFORE EXITING
	DAC*	X13	/STORE PREVIOUS CHARACTER
	ISZ	RECORD	/COUNT IT
	LAC	(15
UNPKED	DAC*	X13
	LAC	RECORD
	RCR
	SZL!RAL		/CHECK FOR EVEN OR ODD
	AAC	3
	ALSS	10
	XOR	(3
	DAC	IMAGE-2	/HEADER WORD PAIR FOR IMAGE IF NECESSARY
	DZM	IMAGE-1
	JMP*	UNPCK
/
EOG	LAC	(700000	/SPECIAL MARKER FOR END OF GROUP IN FORMATTED MODE
	JMP	AGN0
/
CHGMSK	LAC	MASK
	SNA!CLA
	LAC	(400
	DAC	MASK
	LAC	IMAGE-2	/RESTORE FOLLOWING CHARACTER
	SAD	(15
	SKP
	SAD	(175
	JMP	UNPKED-1	/GET OUT
	JMP	AGN0-1	/CARRY ON
/
	.EJECT
/	NORMALLY PACKS A LINE FROM OUTIMG TO BUFFER AND SETS A HEADER
/	WORD PAIR FOR AN ASCII WRITE TO SOURCE OUTPUT DEVICE
/	CAN BE USED FOR ANY IMAGE-PACKED ASCII BUFFER BY
/	CHANGING ADDR2 (IMAGE BUFFER) AND ADDR1 (PACKED ASCII BUFFER)
/
PCK	XX
	DZM	FRSTSP	/ZERO FLAG FOR DETECTING 1ST SPACE
	LAW	-10
	DAC	TABCNT	/SET UP CHARACTER FIELD COUNTER
	LAC	ADDR1
	AAC	-2
	DAC	TEMP
	LAC	ADDR1
	JMS	STPCK
	LAC	ADDR2
	DAC*	(X12
PK0	LAC*	X12
	AND	(177
	SAD	(15
	SKP
	SAD	(175
	JMP	PKOUT
	SAD	(40	/IS IT A SPACE?
	JMP	PSPACE	/YES CHECK IT OUT
	DZM	FRSTSP	/RESET FLAG AS A NON-SPACE CHARACTER HAS BEEN FOUND
	SAD	TABIT	/A TAB?
	JMP	PIN0	/RESET TABCNT AND PACK CHAR UP
PIN	ISZ	TABCNT	/ARE WE AT THE END OF A FIELD
	JMP	PCONT	/NO - CARRY ON
PIN0	DAC	IMAGE-1	/SAVE AC TEMPORARILY
	LAW	-10
	DAC	TABCNT	/RESET FIELD WIDTH COUNTER
	LAC	IMAGE-1	/GET BACK AC
PCONT	JMS	PACK
	JMP	PK0
/
PSPACE	LAC	FRSTSP	/SHOULD WE CHECK THIS SPACE
	SNA
	JMP	PS1	/YES
PS0	LAC	(40	/NO - RESTORE AC AND CONTINUE
	JMP	PIN
PS1	ISZ	TABCNT	/HAS FIELD BEEN EXHAUSTED WITH THIS SPACE
	JMP	PSCONT	/NO - KEEP CHECKING
	LAW	-1
	DAC	TABCNT	/GET SET TO RESET TABCNT AND AC
	JMP	PS0
/
	.EJECT
PSCONT	ISZ	FRSTSP	/SET FLAG
	LAW	-1
	TAD	TABCNT
	DAC	SPSAVE	/SAVE TAB FIELD COUNTER
	LAW	-1
	TAD*	(X12
	DAC	SPADDR	/SAVE CURRENT PLACE
PSAGN	LAC*	X12	/GET A CHARACTER
	AND	(177	/TRIM WORD
	SAD	(15	/IS IT EOL
	SKP
	SAD	(175
	JMP	PSOUT	/YES - RESTORE X12 AND CONTINUE
	SAD	(40	/A SPACE?
	SKP
	JMP	PSOUT	/NO - EXIT
	ISZ	TABCNT	/DID THE FIELD COUNTER RUN OUT
	JMP	PSAGN	/NO
	LAW	-1
	DAC	TABCNT
	LAC	SPSAVE
	CMA
	TAD	SAVEIT
	DAC	SAVEIT
	DZM	FRSTSP
	LAC	TABIT	/PUT TAB IN AC TO BE PACKED UP
	JMP	PIN
/
PSOUT	LAC	SPADDR
	DAC*	(X12
	LAC	SPSAVE
	DAC	TABCNT
	JMP	PK0
/
PKOUT	NOP		/REPLACED BY JMS ADDON IF INSERTING LINE NUMBERS
	JMS	PACK
	ISZ	CNT	/TAKE CARE OF HEADER-WORD PAIR
	LAC	CNT
	ALSS	11
	AAC	2		/ INCLUDE DATA MODE IN HEADER
	DAC*	TEMP
	ISZ	TEMP
	DZM*	TEMP
	JMP*	PCK
/
	.EJECT
STPCK	XX
	DAC	POINT	/STORE OUTPUT BUFFER ADDRESS
	DZM	SAVEIT	/COUNTS CHARACTERS
	DZM	CNT	/COUNTS WORD PAIRS
	LAC	(LEFT
	DAC	SWING
	JMP*	STPCK
/
PACK	XX
	ISZ	SAVEIT	/COUNT CHARACTERS
	CLQ!020000
	JMP*	SWING
SWING	.DSA	LEFT
	TAD*	POINT
	DAC*	POINT
	JMP*	PACK
/
LEFT	ISZ	CNT	/INCREMENT WORD PAIR COUNTER
	RTR
	RTR
	RTR
	RTR		/SHIFT 11 LEFT
	DZM*	POINT
	JMS	SWING
/
LEFT1	RTL
	RTL		/SHIFT 4 LEFT
	JMS	SWING
/
LEFT2	LRS	3
	TAD*	POINT
	DAC*	POINT	/1ST WORD OF PAIR COMPLETE
	ISZ	POINT
	DZM*	POINT
	LACQ
	JMS	SWING
/
LEFT3	RTL
	RTL
	RTL
	RTL		/SHIFT 8 LEFT
	JMS	SWING
/
LEFT4	RAL		/SHIFT 1 LEFT
	JMS	SWING
/
LEFT5	ISZ	POINT
	JMP	LEFT
/
	.EJECT
/	THIS SUBROUTINE ADDS SOURCE LINE INDICATOR TO OUTPUT LINE
/
ADDON	XX
	LAC	SAVEIT	/MUST SEE HOW MANY SPACES TO ADD
	TAD	NUMBER
	SMA
	JMP	ADD5	/WE HAVE EITHER A JUST FULL LINE (0) OR LONG LINE (+)
ADD1	TAD	SPNUM	/NOT A FULL LINE ADD REMAIN SPACES
ADD2	DAC	TSAVE
	LAC	TSAVE
	IAC		/POSITIVE NO OF SPACES REQUIRED
	TAD	TABCNT	/NEG OF CURRENT FIELD COUNTER
	SPA		/CAN WE ADD ANY TABS
	JMP	ADD30	/NO - ONLY NEED SPACES
ADD3	DAC	TSAVE
	LAC	TABIT
	JMS	PACK	/PACK UP A TAB
	LAC	TSAVE	/IS THERE ANY SPACES LEFT
	SNA
	JMP	ADD31	/NO - JUST ADD ON LINE NO
	AAC	-10
	SMA		/IS THE NO OF SPACES LEFT SMALLER THAN A FIELD WIDTH
	JMP	ADD3	/NO - PUT IN ANOTHER TAB
	LAC	TSAVE	/YES - MAKE IT NEG AND INSERT SPACES
	IAC
	DAC	TSAVE
ADD30	LAC	(40
	JMS	PACK
	ISZ	TSAVE
	JMP	.-3
ADD31	LAC	(EMPTY-1
	DAC*	(X12
ADD4	LAC*	X12
	AND	(177	/TRIM TO 7 BITS
	SAD	(15
	JMP*	ADDON
	JMS	PACK
	JMP	ADD4
/
ADD5	SNA
	JMP	ADD1	/A LINE THAT'S JUST FULL - ADDON NO OF SPACES
	DAC	TSAVE	/MORE THAN A FULL LINE
	TAD	SPNUM
	SPA
	JMP	ADD2	/ADD REDUCED AMOUNT OF SPACES
	LAW	-1	/LONGEST LINE
	JMP	ADD2
/
	.EJECT
/	WRITES FROM BUFFER TO OUTPUT SOURCE DEVICE
/
WRITES	XX
	LAC	NOTOUT
	SZA
	JMP	WR1
	LAC	WHATIF
	SNA
	JMP	WR
	LAC	PUTIT
	DAC	TEMP
	LAC	WRITE
	DAC*	TEMP
	ISZ	TEMP
	LAC	WRITE+1
	DAC*	TEMP
	ISZ*	CHANGE
	LAC	(50	/PROGRAM SHOULD NOT BE HERE
	JMS*	ASK
WR	CAL	WRCPB		/ OUTPUT A LINE
	JMS	WTFOR
WR1	DZM	DIDWE
	DZM	NEW	/MAKE SURE NEW PAGE CAN NOW OCCUR
	LAC	DOUBLE
	SZA
	JMS	BLANK
	ISZ	LINENM
	JMP*	WRITES
	JMS	NEWPG
	ISZ	NEW	/FLAG FOR INTERNALLY GENERATED NEW PAGES
	JMP*	WRITES
/
	.EJECT
/	THIS SUBROUTINE PUTS IN HEADER SPACE FOR EACH NEW PAGE
/
HEAD	XX
	LAC	NOTOUT
	SZA
	JMP	HEAD0
	CAL	WRFF		/ OUTPUT A FORM FEED
HEAD0	LAC	NOPGNM	/DO WE WANT PAGE NUMBERS
	SNA
	JMP	HEAD1
	ISZ	STRPG	/NO - COUNT PAGE ANYWAY AND ISSUE BLANK LINE
	JMS	BLANK
	JMP*	HEAD
HEAD1	LAC	STRPG	/YES - CONVERT PAGE NUMBER
	STL
	JMS*	OCTDEC
	PGIMG
	ISZ	STRPG
	LAC	NOTOUT
	SZA
	JMP*	HEAD
	LAC	(OUTIMG-1
	DAC*	(X12
	LAC*	.DIGCT	/NUMBER OF DIGITS CONVERTED
	SZA
	JMP	HEAD2
	ISZ*	CHANGE
	LAC	(55	/SHOULD HAVE FOUND A PAGE NO - DIDN'T
	JMS*	ASK
HEAD2	AAC	5	/WORD PAGE + 1 SPACE
	TAD	NUMBER
	DAC	TEMP1
/
	.EJECT
HEAD20	SMA
	JMP	HEAD22
	AAC	10
	SMA!SZA
	JMP	HEAD21
	DAC	TEMP1
	LAC	TABIT
	DAC*	X12
	LAC	TEMP1
	JMP	HEAD20
HEAD21	LAC	(40
	DAC*	X12
	ISZ	TEMP1	/FILL BEGINNING OF LINE WITH SPACES
	JMP	.-2
HEAD22	LAC	(PGHD-1
	DAC*	(X13
HEAD3	LAC*	X13	/ADD 'PAGE NO. ' AND ACTUAL PAGE NUMBER
	SAD	(760040	/IGNORE SPACES FROM OCTDEC
	JMP	.-2
	DAC*	X12
	SAD	(15
	SKP
	JMP	HEAD3
	JMS	PCK
	ISZ	DIDWE	/INHIBIT INSERTION OF A SPACE
	LAC	WRITES
	DAC	SAVEIT
	LAC	(NOP
	SAD	PKOUT
	JMP	.+3
	DAC	PKOUT
	DAC	HEAD5
	LAC	WRCPB+4	/ACCOUNT FOR POSSIBLE CHANGE OF PACKED BUFFER ADDR
	DAC	STORE	/IF IN UNFORMATTED MODE
	LAC	(BUFFER
	DAC	WRCPB+4
	JMS	WRITES
	LAC	STORE
	DAC	WRCPB+4
	LAC	(JMS ADDON
HEAD5	SKP
	DAC	PKOUT
	LAC	(SKP
	DAC	HEAD5
	LAC	SAVEIT
	DAC	WRITES
	JMP*	HEAD
/
	.EJECT
BLANK	XX
	LAC	NOTOUT
BPL	SZA
	JMP	WY
	ISZ	DIDWE
	CAL	WR1SP		/ OUTPUT A SINGLE SPACE (BLANK LINE)
WY	ISZ	LINENM
	JMP*	BLANK
	LAC	BLANK
	DAC	SAVADR
	JMS	NEWPG
	JMP*	SAVADR
/
SPACES	XX
	LAC	SPTABL+1
	SPA
	CLA
	DAC	SPTABL+1
	LAC	SPTABL	/SAVE SPACE TABLE
	DAC	TEMPS
	TAD	SPTABL+1	/ADD IN FOR TITLE LINES IF ANY
	TAD	LENGTH	/PG LENGTH-SPACE REQUEST
	SMA
	JMP	SPERR	/ASKED FOR A SPACE LARGER THAN THE PAGE LENGTH
	LAC	LINENM	/NUMBER OF LINES LEFT THIS PAGE
	TAD	SPTABL+1	/SUBT NUMBER OF TITLE LINES IF ANY
	TAD	TEMPS	/NUMBER OF SPACES ASKED FOR
	SPA
	JMP	GO	/ENOUGH LINES LEFT
	SNA
	JMP	OPT1	/WILL JUST FIT - ISSUE NEW PAGE AND GET OUT
	DAC	CNT	/SAVE POSITIVE NUMBER OF SPACES LEFT THIS PAGE
	LAC	WHATIF	/ARE WE ALREADY WAITING TO OUTPUT A FIGURE
	SNA
	JMP	SAGN0
	LAC	PUTIT
	DAC	TEMP
	LAC	SPACE
	DAC*	TEMP
	ISZ	TEMP
	LAC	SPACE+1
	DAC*	TEMP
	ISZ	TEMP
	LAC	SPACE+2
	DAC*	TEMP
	ISZ*	CHANGE
	LAC	(50	/PROGRAM SHOULD NOT BE HERE
	JMS*	ASK
/
	.EJECT
SAGN0	LAC	A17
	DAC	TEMP1	/FOR OCTSUB
	LAC	LINENM
	TCA
	JMS	OCTSUB	/CREATE A PACKED ASCII NUMBER OF SPACES LEFT
	LAC	A16
	DAC	TEMP1	/FOR OCTSUB
	LAC	TEMPS	/INSERT NUMBER OF SPACES REQUESTED
	JMS	OCTSUB
	LAC	(5	/TELL USER HOW MUCH SPACE HE REQUIRES
	JMS*	ASK
	LAC	(6	/TELL USER HOW MUCH SPACE AVAILABLE
	JMS*	ASK
	LAC	(7	/ASK USER TO CHOOSE AN OPTION
	JMS	SAGN	/GO GET THE NUMBER
	JMP	SAGN2
SAGN	XX		/THIS ROUTINE ALLOWS FOR USER INTERACTION
	DAC	CNT	/SAVE AC
	DZM*	CHANGE
	ISZ*	DOWE
	JMS*	ASK
	LAC	(TABLE
	DAC	GETPNT
	LAC	(IMAGE
	JMS	GET
	SZA
	JMP*	SAGN
	LAC	(57	/NOT A VALID NUMBER
	JMS*	ASK	/ALLOW USER TO ALTER REQUEST IF HE WANTS TO
	LAC	CNT
	JMP	SAGN+2
/
SAGN2	LAW	-5
	TAD	TABLE
	SPA
	JMP	SETJMP
	LAC	(30	/OPTION CHOICE OUTSIDE RANGE
	JMS*	ASK
	JMP	SAGN
/
	.EJECT
SETJMP	LAC	(JMP DISPCH+1
	TAD	TABLE
	DAC	DISPCH
DISPCH	XX
	JMP	OPT0	/ALLOW ENTRY OF NEW NO. OF SPACES
	JMP	OPT1	/WILL ACCEPT REDUCED SPACE
	JMP	OPT2	/MOVE SPACE TO NEXT PAGE AND FILL CURRENT PAGE WITH TEXT
OPT3	JMS	NEWPG	/JUST GO TO NEW PAGE
OPT4	JMP	GO	/SPREAD SPACES OVER TWO PAGES
/
OPT0	LAC	(31	/ALLOW USER TO ALTER NO OF SPACES
	JMS	SAGN
	LAC	TABLE
	DAC	SPTABL
	JMP	SPACES+1
/
OPT1	JMS	NEWPG
	JMP*	SPACES
/
OPT2	LAC	(36	/OPTION NOT IMPLIMENTED - CHOOSE ANOTHER
	JMS*	ASK
	JMP	SAGN-3
	ISZ	WHATIF	/FLAG FOR FIGURE WAITING IN WINGS
	LAC	TEMPS
	DAC	TEMSAV	/SAVE CURRENT SPACE REQUEST
	LAC	SPTABL+1
	SNA!TCA
	JMP*	SPACES	/GET OUT IF NO TITLE LINES
	DAC	NAMSAV
	DAC	SPTABL+1
	LAC	FREE.L
	DAC*	(X11
	LAC	(IMAGE-1
	DAC*	(X10
	LAC	(RECSAV
	DAC	LENPNT
OPTRED	JMS	RASCII
	SZA
	JMP	WARN
	LAC	RECORD
	DAC*	LENPNT
	ISZ	LENPNT
/
	.EJECT
OR1	LAC*	(X10
	SAD	FREE.H
	JMP	TOVER
	LAC*	X10	/SAVE IMAGE LINES IN FREE CORE
	DAC*	X11
	SAD	(175
	JMP	OPTERR
	SAD	(15
	SKP
	JMP	OR1
	LAC*	(X10
	SAD	FREE.H
	JMP	TOVER
/
	ISZ	SPTABL+1
	JMP	OPTRED
	LAW	-1
	DAC*	LENPNT
	JMP*	SPACES
TOVER	LAC	(42	/TITLE BUFFER OVERFLOW
	SKP
OPTERR	LAC	(41	/CANNOT HAVE ALTMODE IN TITLE LINES
	SKP
WARN	LAC	(40	/END OF FILE REACHED WHILE GETTING TITLE LINES
	DAC	TEMP
	ISZ*	CHANGE
	LAC	TEMP
	JMS*	ASK
/
SPERR	LAC	LINENM
	DAC	SPTABL+1
	TCA
	DAC	CNT	/NUMBER OF SPACES LEFT THIS PAGE
	LAC	(12
	JMS*	ASK	/SPACE REQUEST TOO LARGE
	JMP	SAGN0
/
	.EJECT
GO	LAC	TEMPS
	TCA
	DAC	TEMPS
	LAC	SPACES
	DAC	PLSAV
	JMS	BLANK
	ISZ	TEMPS
	JMP	.-2
	LAC	PLSAV
	DAC	SPACES
	LAC	SPTABL+1	/ARE THERE ANY TITLE LINES
	SNA!TCA
	JMP*	SPACES	/NO - GET OUT
	DAC	SPTABL+1	/YES -MAKE # OF LINES NEG
GETAGN	JMS	RASCII	/GET A TITLE LINE
	SZA
	JMP	WARN
	JMS	CENTIT	/CENTER IT
	JMS	PCK
	JMS	WRITE	/MAYBE SHOULD GO TO PACK FIRST*********
	ISZ	SPTABL+1
	JMP	GETAGN	/NO FINISHED - CONTINUE
	JMP*	SPACES
	.TITLE	STUNPK & UNPACK
/
/  25 JAN 73
/
STUNPK	XX
	DAC*	(X12
	LAC	(UNFRT
	DAC	HINGE
	JMP*	STUNPK
/
UNPACK	XX
	JMP*	HINGE
HINGE	.DSA	UNFRT
	AND	(177	/TRIM TO 7 BITS
	JMP*	UNPACK
/
UNFRT	LAC*	X12
	DAC	CKNXT
	LMQ
	LLS	7	/1ST CHARACTER
	JMS	HINGE
/
UNF1	LLS	7	/2ND CHARACTER
	JMS	HINGE
/
UNF2	LAC*	X12
	LMQ
	LAC	CKNXT	/GET BACK 1ST WORD
	LLS	3	/3RD CHARACTER
	JMS	HINGE
/
UNF3	LLS	7	/4TH CHARACTER
	JMS	HINGE
/
UNF4	LLS	7	/5TH CHARACTER
	JMS	HINGE
	JMP	UNFRT
/
	.EJECT
/	COMMON ENTRY POINT FOR OCTDEC
/
OCTSUB	XX
	STL
	JMS*	OCTDEC
	PGIMG
	LAC	TEMP1
	JMS	STPCK
	LAC*	.DIGCT
	TCA
	DAC	COUNT1
	TAD	(PGIMG+6
	DAC	TEMP
OCTBK	LAC*	TEMP
	AND	(177	/TRIM TO 7 BITS
	JMS	PACK
	ISZ	TEMP
	ISZ	COUNT1
	JMP	OCTBK
	JMP*	OCTSUB
/
	.EJECT
/	NEW PAGE SUBROUTINE
/
NEWPG	XX
	LAC	PKOUT	/SAVE LOCATION INCASE LINE NUMBERS REQ'D
	DAC	TSAVE
	LAC	(NOP
	DAC	PKOUT
	DZM	LINENM
	LAC	HEADSP
	DAC	TEMPS
	JMS	HEAD	/INSERT PAGE NUMBER IF ANY
	JMS	BLANK	/INSERT HEADER BLANK LINES
	ISZ	TEMPS
	JMP	.-2
	LAC	LENGTH	/SETUP NUMBER OF LINES PER PAGE
	DAC	LINENM
	LAC	WHATIF	/ARE WE WAITING TO OUTPUT A FIGURE
	SNA
	JMP	NEWOUT
	LAC	TEMSAV
	DAC	SPTABL
	LAW	-1
	DAC	SPTABL+1
	JMS	SPACES
	LAC	NAMSAV
	SNA
	JMP	NEWOUT
	LAC	(RECSAV
	DAC	LENPNT
	LAC	FREE.L
	DAC*	(X10
/
	.EJECT
NEWAGN	LAC	(OUTIMG-1
	DAC*	(X11
	LAC	LENPNT
	SPA
	JMP	IMPOS
	DAC	RECORD
	JMS	CENTIT
	JMS	PCK
	JMS	WRITES
	ISZ	LENPNT
	ISZ	NAMSAV
	JMP	NEWAGN
NEWOUT	LAC	TSAVE
	DAC	PKOUT
	LAC	(OUTIMG-1
	DAC*	(X12
	LAC	NUMBER
	DAC	NUMB
	JMP*	NEWPG
IMPOS	ISZ*	CHANGE
	LAC	PUTIT
	DAC	TEMP
	LAC	NEWPG
	DAC*	TEMP
	ISZ	TEMP
	LAC	NEWPAG+1
	DAC*	TEMP
	LAC	(50
	JMS*	ASK
/
	.EJECT
/	ARRAYS,VARIABLES AND MESSAGES
/
	.BLOCK	2
	.ASCII	<11>
BUFFER	.BLOCK	70
TAB	.BLOCK	26	/BUFFER FOR PRECEEDING SPACES IN FORMATTED DOCUMENT MODE
TABLE	.BLOCK	26	/BUFFER AREA FOR NUMBERS DETERMINED BY GET
SPTABL	.BLOCK	3
RECSAV	.BLOCK	20
CTABLE	.BLOCK	71	/ENOUGH ROOM FOR 57 CENTERED PAGE LINES
	-1
PGTABL	.BLOCK	400	/ENOUGH ROOM FOR 128 INDEX PAGE ENTRIES
	-1
/
IFILE	.SIXBT	'INDEX@SRC'
ONESP	2002; 0; .ASCII	' '<15>
DOLIE	2002; 0; .ASCII	'$IE'<15>
EMPTY	.BLOCK	15
/
	.EJECT
	144
	12
UNITS	1
	0
/
WRITE	.ASCII	'WRITE'
SPACE	.ASCII	'SPACES'<15>
ALLS	.ASCII	'ALL'
NEWPAG	.ASCII	'NEWPG'
FORMFD	2002; 0; .ASCII <14><15>
NAME3	.SIXBT	'CFILESSRC'
PGHD	120	/P
	101	/A
	107	/G
	105	/E
	40	/SPACE
PGIMG	.BLOCK	6
	15	/CARRIAGE RETURN
/
	0
	0
IMAGE	.BLOCK	512
TABIT	11
OUTIMG	.BLOCK	210
TEMIMG	.BLOCK	210
WAITS	.SIXBT	'TITLESSRC'
	.END	ATS15
[\].
ATS@@@JOB
$JOB 73(010) 'ATS' PAUL HENDERSON
$UIC <ATS>
$MAC BRE_ATS15 028,ASKIT 007,GTFREE 001
$BTK ATS15,ASKIT,GTFREE
$END
$JOB FLUSH
$END
[\].
GTFREE001
	.TITLE	GTFREE
/
/  31 AUG 77 - PAUL HENDERSON
/
/  ROUTINE USED WITH THE ATS15 PACKAGE TO PRE-ALLOCATE I/O BUFFERS,
/  AND TO DETERMINE THE LIMITS OF THE AVAILABLE FREE CORE
/
	.DEC
INDK=15
OUTDK=17
	.OCT
/
	.GLOBL	GTFREE,FREE.L,FREE.H,.IOERR
/
GTFREE	XX
	CAL	PARINF		/ GET INFORMATION ABOUT 'THIS' PARTITION
	LAC	(250		/ PBDL LISTHEAD
LOOK	DAC	SPYADR
	CAL	SPY
	LAC	SPYCON		/ ADDRESS OF PBDL BEING CHECKED
	DAC	P.FP
	AAC	4		/ POINT TO BASE ADDRESS
	DAC	SPYADR
	CAL	SPY
	LAC	SPYCON		/ GET BASE ADDRESS OF PBDL BEING CHECKED AND
	SAD	P.BA		/ COMPARE IT WITH BASE ADDRESS OF 'THIS' PARTITION
	JMP	FOUND		/ WE HAVE FOUND THE CORRECT PBDL NODE!
/
	LAC	P.FP		/ NOT CORRECT ONE YET
	JMP	LOOK		/ GET POINTER TO NEXT PBDL NODE
/
FOUND	LAC	P.FP
	AAC	6		/ POINT TO TASK SIZE
	DAC	SPYADR
	CAL	SPY
	LAC	SPYCON
	DAC*	FREE.L		/ RETURN ADDRESS OF FIRST (LOWEST) FREE LOCATION
	LAC	(INDK
	JMS	PRE		/ PRE-ALLOCATE BUFFERS FOR DISK I/O
	LAC	(OUTDK
	JMS	PRE
	CAL	RAISEB		/ TAKE POSSESSION OF THE FREE CORE
	CAL	(5		/ WAIT UNTIL IT ACTUALLY HAPPENS
	JMS	WTFOR		/ VALIDATE EVENT VARIABLE
	DAC*	FREE.H		/ ADDRESS OF LAST (HIGHEST) FREE LOCATION
	JMP*	GTFREE		/ RETURN TO MAINLINE
/
/  SUBROUTINE TO PRE-ALLOCATE I/O BUFFER
/
PRE	XX
	DAC	PREAL+2		/ INSERT CORRECT LUN
	CAL	PREAL
	JMS	WTFOR
	JMP*	PRE
/
/  SUBROUTINE TO WAIT FOR EVENT VARIABLE
/
WTFOR	XX
	LAC	EV		/ QUICK CHECK
	SNA
	CAL	WAITFR		/ WAIT ONLY WHEN NECESSARY
	LAC	EV
	SPA
	JMS*	.IOERR		/ COMPLAIN ABOUT BAD EV
	JMP*	WTFOR
/
/  CAL PARAMETER BLOCKS
/
PARINF	26;	0; 0; 0; P.BA;P.BA;P.SZ;P.FP
SPY	31;	0;SPYADR;SPYCON
PREAL	2300;	EV;	INDK
RAISEB	27;	EV
WAITFR	20;	EV;EV
	.END
[\].
