Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-06 - 43,50434/loadvt.s11
There are no other files named loadvt.s11 in the archive.
	TITLE	LOADVT	VS11	2-MAY-75

;	DEC-11-GPBAA-B-LA
;
;	COPYRIGHT (C) 1974
;	DIGITAL EQUIPMENT CORPORATION
;	MAYNARD, MASSACHUSETTS 01754

;	THE INFORMATION IN THIS SOURCE LISTING IS SUBJECT TO
;	CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A
;	COMMITTMENT BY DIGITAL EQUIPMENT CORPORATION.
;	DIGITAL EQUIPTMENT CORPORATION ASSUMES NO RESPONSIBILITY
;	FOR ANY ERRORS THAT MAY APPEAR IN THIS LISTING.

;	THIS SOFTWARE IS FURNISHED TO THE PURCHASER
;	UNDER A LICENSE FOR USE ON A SINGLE COMPUTER 
;	SYSTEM AND CAN BE COPIED (WITH INCLUSION OF DIGITAL'S
;	COPYRIGHT NOTICE) ONLY FOR USE IN SUCH SYSTEM, EXCEPT AS
;	MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.

;	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
;	FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT 
;	THAT IS NOT SUPPLIED BY DIGITAL.

;	WRITTEN BY JACK BURNESS.

;		THIS PROGRAM CAN LOAD THE VT40 FROM ANY DEVICE THAT
;	HAS A PDP-11 BINARY TAPE IN PDP-10 IMAGE FORMAT. IT WILL CONVERT
;	THE 8 BIT CHARACTERS TO 6 BIT CHARACTERS FOR DATA TRANSMISSION.
;	IT WILL ISSUE A 175-123 TO RESET THE VT40 AND A 175-114
;	TO START LOADING IT. IT CAN ALSO RECOGNIZE A BAD CHECKSUM
;	FROM THE VT40 BY THE 175-102 CHARACTERS.




	IFNDEF	NONREN,	<TWOSEG>

	LOC	137
	^D10				;VERSION NUMBER FOR RUN TIME.

	IFNDEF	NONREN,	<RELOC 400000>
	IFDEF	NONREN,	<RELOC>

TITLE:	SIXBIT	/LOADVT/
SUBTTL:	SIXBIT	/VS11  /

	ENTRY		START

	EXTERNAL	.JBREL,	.JBFF
;	CCLSW=1 GIVES NEW COMMAND LANGUAGE FEATURES
	IFNDEF	CCLSW,<CCLSW==1>	;NORMALLY ASSEMBLE WITH CCL FEATURES
	IFE	CCLSW,<TEMPC==0>	;TMPCOR UUO FLAG
	IFNDEF	TEMPC,<TEMPC==1>	;NORMALLY USE CCL WITH TMPCOR UUO
	SUBTTL	VARIABLE PARAMETERS

	PAGSIZ=	^D54		; NUMBER OF LINES ON A PAGE

	NUMBUF=	4		; NUMBER OF BUFFERS PER DEVICE

	CORINC=	2000		; CORE INCREMENT

	SPL=	4		; SYMBOLS PER LINE (SYMBOL TABLE LISTING)

	SPLTTY=	3		; SYMBOLS PER LINE (TTY)

	DATLEN=	^D350		; DATA BLOCK LENGTH

	RLDLEN=	^D40

	WPB=	10		; MACRO BLOCK SIZE

	CPL1=	^D72		; CHARACTERS PER LOGICAL LINE
	CPL2=	^D83		; CHARACTERS PER PHYSICAL LINE
	CPL3=	^D144		; CHARACTERS PER .PDP10 LINE

	PDPLEN=	100		;  PUSH-DOWN POINTER LENGTH

	CRFLEN=	^D36		; CREF SYMBOLS/LINE MAX

	COLLPT=	^D128		;CPL LPT

	COLTTY=	^D72		;CPL TTY

BKT1=	1
BKT2=	2
BKT3=	3
BKT4=	4
BKT6=	6
	SUBTTL	ACCUMULATOR ASSIGNMENTS

	%00=	0		; ACCUMULATION OF SIXBIT SYMBOL, SCRATCH
	%01=	1		; SYMBOL VALUE AND FLAGS SET BY SRCH.  SCRATCH
	%02=	2		; SCRATCH
	%03=	3		; UNIVERSAL SCRATCH
	%04=	4		; UNIVERSAL SCRATCH +1
	%05=	5		; LOCATION COUNTER
	%06=	6		; SCRATCH
	%07=	7		; SYMBOL TABLE SEARCH INDEX
	%10=	10		; EXPRESSION OR TERM VALUE, SCRATCH
	%11=	11		; SCRATCH
	%12=	12		; MACRO STORAGE BYTE POINTER
	%13=	13		; LINE BUFFER BYTE POINTER
	%14=	14		; CURRENT CHARACTER (ASCII)
	%15=	15		; LH - ASSEMBLER FLAGS,  RH - ERROR FLAGS
	%16=	16		; EXEC FLAGS
	%17=	17		; PUSH-DOWN POINTER
	SUBTTL	FLAG REGISTERS

				; %16 - LH

	LSTBIT=	000001		; 1- SUPRESS LISTING OUTPUT
	BINBIT=	000002		; 1- SUPRESS BINARY OUTPUT
	CSWBIT=	000004		; 1- SUPRESS CROSS REFERENCE
	ESWBIT=	000010		; 1- LIST OCTAL
	MSWBIT=	000020		; 1- SUPRESS MACRO LISTING
	NSWBIT=	000040		; 1- SUPRESS ERRORS ON TTY
	RSWBIT=	000100		; 1- REPRODUCE SOURCE
	TTYBIT=	000200		; 1- LISTING IS ON TTY
	ERRBIT=	000400		; 1- ERROR MESSAGES ENABLED


				; %16 - RH

	ARWBIT=	000001		; 1- LEFT ARROW SEEN
	EXTBIT=	000002		; 1- EXPLICIT EXTENSION SEEN
	SWTBIT=	000004		; 1- ENTER SWITCH MODE
	INFBIT=	000010		; 1- VALID INFORMATION SEEN
	FFBIT=	000020		; 1- FORM-FEED SEEN
	ENDBIT=	000400		; 1- END OF ALL INPUT FILES
	SLABIT=	001000		; 1- SWITCH MODE ENTERED WITH A </>
	NULBIT=	010000		; 1- NON-NULL COMMAND STRING
	HDRBIT=	040000		; 1- TIME FOR NEW LISTING PAGE
	SEQBIT=	100000		; 1- SEQUENCE NUMBER SEEN
	MODBIT=	200000		; 1- USER MODE AC'S SET


				; %15 - LH

	ENDFLG=	000020		; 1- END OF SOURCE ENCOUNTERED
	RSWFLG=	000040		; 1- LINE TO BE SUPPRESSED IN REDUCTION
	TTYFLG=	000100		; 1- TTY MODE LISTING FORMAT
	CONFLG=	000200		; 1- CONCATENATION CHARACTER SEEN
	EXTFLG=	000400		; 1- EXTENSION LINE
	TRNFLG=	001000		; 1- TRUNCATION MODE
	P10FLG=	002000		; 1- .PDP10 MODE
	LEDNUL=	004000		; 1- NULL LEADER FROM OPEN FILE.
	TRLNUL=	010000		; 1- NULL TRAILER FROM OPEN FILE.
	XSWFLG=	020000		; 1- RECREATE OBJECT
	FLTFLG=	040000		; 1- ERROR ENCOUNTERED IN FLOATING ROUTINE
	ISWFLG=	100000		; 1- /I SEEN
	P1F=	400000		; 1- PASS 1 IN PROGRESS
	SUBTTL	MISCELLANEOUS PARAMETERS

	TTYDEV=	000010		; 1- DEVICE IS A TTY
	PTRDEV=	000200		; 1- DEVICE IS A PTR
	LPTDEV=	040000		; 1- DEVICE IS A LPT
	CDRDEV=	100000		; 1- DEVICE IS A CDR

	IODATA= 200000		; 1- IO DATA ERROR
	IODEV=  100000		; 1- IO PARITY ERROR
	IOWRLK= 400000		; 1- IO WRITE LOCK ERROR
	IOBKTL=	040000		; 1- IO BLOCK TOO LARGE
	IOEOF=	020000		; 1- END OF FILE ON IO DEVICE


				; DEVICE PARAMETERS

	BIN=	1
	LST=	2
	SRC=	3
	CMD=	4

	ILLCHR=	1		;ILLEGAL CHARACTER SUBSTITUTE
	ELLCHR=	2		;END OF LOGICAL LINE CHARACTER
	INBIT=	2		;DEVICE CAN DO INPUT
	ALMODE=	1		;ASCII LINE MODE


				; OPDEFS

	OPDEF	RESET	[CALLI	 0]
	OPDEF	DEVCHR	[CALLI	 4]
	OPDEF	CORE	[CALLI	11]
	OPDEF	EXIT	[CALLI	12]
	OPDEF	DATE	[CALLI	14]
	OPDEF	APRENB	[CALLI	16]
	OPDEF	MSTIME	[CALLI	23]
	OPDEF	RUNTIM	[CALLI	27]
	OPDEF	ZBINK	[CLOSE BIN,]

	OPDEF	OUTCHR	[TTCALL 1,]
	OPDEF	OUTSTR	[TTCALL 3,]
	OPDEF	INCHWL	[TTCALL 4,]

	OPDEF	IONEOU	[TTCALL	15,]
	OPDEF	WAIT	[CALLI	10]
	OPDEF	INCHRS	[TTCALL	2,]
	OPDEF	SLEEP	[CALLI	31]



	DEFINE	GENM40	(A,B,C,D,E,F)	;GEN MOD 40
<
	XWD	$'A*50*50+$'B*50+$'C , $'D*50*50+$'E*50+$'F
>
	SUBTTL	EXEC

START:				;MAIN ENTRY POINT
IFN CCLSW,<
	TDZA	0,0		;NORMAL ENTRY, CLEAR CCL FLAG
	SETOM	0		;CCL ENTRY, SET FLAG
	MOVEM	0,CCLFLA	;SAVE FLAG
>

NULFIL:	RESET			;RESET ALL I/O
	SKIPN	MESSF		;MESSAGE LEFT?????
	PUSHJ	%17,VT40R	;NOPE. RESET.
	SETZM	MESSF		;RESET FLAG NOW.
	HRRZ	%00,.JBFF
	ADDI	%00,204*NUMBUF*2+200+200	;ACCOUNT FOR POSSIBLE CCL FILES
	CORE	%00,
	 HALT	.
	MOVE	%17,[IOWD PDPLEN,PDPSTK]
IFN CCLSW,<
	SKIPE	CCLFLA
	PUSHJ	%17,DSKNIT	;INIT DSK: FOR COMMAND FILE
				;SKIP RETURN
>
	OUTCHR	["*"]
NXTCCL:
	MOVE	%00,[XWD BZCOR,BZCOR+1]
	SETZB	%01,BZCOR
	BLT	%00,EZCOR-1
	PUSHJ	%17,CORSET	;SET UPPER CORE
	MOVSI	%16,BINBIT!LSTBIT!CSWBIT
	SETZ	%15,		;CLEAR ASSEMBLER FLAG REGISTER
	MOVE	%01,.JBFF
	HRLI	%01,(POINT 7,)
	MOVEM	%01,TTIPNT
START1:
IFN CCLSW,<
	SKIPE	CCLFLA
	PUSHJ	%17,GETCMD	;READ A CHARACTER FROM COMMAND FILE
	SKIPN	CCLFLA
>
	INCHWL	%02
	IDPB	%02,%01
	CAIE	%02,LF
	CAIN	%02,ALTMOD
	TDZA	%02,%02
	JRST	START1
	IDPB	%02,%01
	MOVEI	%01,1(%01)
	MOVEM	%01,.JBFF
	MOVSI	%01,(SIXBIT /TTY/)
	PUSHJ	%17,GETLST	;INITIALIZE THE LISTING FILE

	MOVE	%05,TTIPNT
	MOVEM	%05,TTISAV	;SAVE TTI POINTER
	MOVSI	%01,(SIXBIT /DSK/)
	PUSHJ	%17,GETSRC	;INITIALIZE THE SOURCE FILE
	MOVEI	%10,[ASCIZ ./R REQUIRES LISTING FILE.]
	TLNE	%16,LSTBIT	;IF NO LISTING FILE
	TLNN	%16,RSWBIT	;  BUT /R SEEN,
	CAIA
	JRST	ERROR		;  ERROR
IFN CCLSW,<
	SKIPE	CCLFLA
	OUTSTR	[ASCIZ /LOADVT: /]	;ANNOUNCE YOURSELF
>

	SKIPN	CCLFLA
	OUTSTR	[BYTE (7) CRR, LF, 0]	;CONFIRM ALL'S WELL
	PUSHJ	%17,ACEXCH	;SAVE EXEC AC'S
	TLO	%15,LEDNUL	;TELL OPEN INPUT TO PRODUCE NULL LEADER NOW.
	MOVEI	%03,4		;TELL IT TO PRODUCE 4 CHARACTERS OF IT.
	MOVEM	%03,SRCNUL
	MOVEI	%03,MAJOR
	PUSHJ	%17,0(%03)	;CALL THE ASSEMBLER

	SKPINC			;CLEAR ANY ^O
	 JFCL

IFN CCLSW,<
	SKIPN	CCLFLA
>
	PUSHJ	%17,ACEXCH	;SWAP AC'S


IFN CCLSW,<
	EXTERNAL	.JBERR
	JRST EXIT
>
;INITIALIZE A LISTING FILE
;COLLECTS A DEVICE NAME IN AC %01, A FILE NAME IN XE AND
;AN OPTIONAL FILENAME EXTENSION, THE DEVICE IS INITIALIZED IN
;ASCII LINE MODE ON CHANNEL 2, IF THE DEVICE IS A TTY, THE
;TTYLST FLAG IS SET TO 1, AND THE INBUF/OUTBUF INDEX IS INCREMENTED.

GETLST:	MOVSI	%13,(Z LST,)	;SET SWITCH AC
	SETZM	XE
	PUSHJ	%17,GETNAM	;GET A DEVICE AND FILE NAME
	SKIPA	%03,[SIXBIT /BINARY/]	;IF NULL, AVOID WASTED CYLCE.
	MOVE	%03,[SIXBIT /BINARY/]
	SKIPN	XE		;EXPLICIT CREF NAME?
	MOVEM	%03,XE		;  NO, GIVE IT DEFAULT
	TRON	%16,EXTBIT	;EXPLICIT EXTENSION?
	MOVSI	%14,(SIXBIT /LOD/)	;  NO, SUPPLY ONE
GETLS2:	MOVE	%00,[INIT LST,10]
	MOVSI	%02,LSTBUF	;GET BUFFER HEADER ADDRESS
	PUSHJ	%17,INISET	;INITIALIZE LISTING FILE
	MOVE	%00,%01
	DEVCHR	%00,		;GET DEVICE CHARACTERISTICS
	OUTBUF	LST,NUMBUF
	TLNE	%13,777000	;IS THERE A SWITCH TO PROCESS?
	XCT	%13		;EXECUTE THE ASSEMBLED UUO
	TRZN	%16,EXTBIT	;WAS THERE AN EXTENSION?
	MOVSI	%14,(SIXBIT /LOD/)	;NO
	HLLZM	%14,XE1		;SAVE EXTENSION IN LOOKUP BLOCK
	ENTER	LST,XE		;ENTER FILE NAME IN DIR.
	JRST	ERRNR		;DIRECTORY FULL
	TLZ	%16,LSTBIT	;INDICATE A GOOD LISTING FILE
	TLNE	%16,TTYBIT	;TOGGLE MODE?
	TLC	%15,TTYFLG	;  YES
	POPJ	%17,
;INITIALIZE A SOURCE FILE
;COLLECTS A DEVICE NAME IN AC %01, A FILE NAME IN XE AND
;AN OPTIONAL FILE NAME EXTENSION. THE DEVICE IS INITIALIZED
;IN ASCII LINE MODE ON CHANNEL 3, AND THE FILE NAME ASSOCIATED
;WITH THE SOURCE FILE IS USED AS THE TITLE ON THE LISTING.

GETSRC:	MOVSI	%13,(Z SRC,)	;SET SWITCH AC
	SETZM	XE
	TRNE	%16,ARWBIT	;GIVE ERROR IF ARROW NOT GIVEN.
	PUSHJ	%17,GETNAM	;GET A DEVICE NAME AND FILE NAME
	JRST	ERRSE		;COMMAND ERROR IF A NULL
	MOVE	%00,[INIT SRC,10]
	TLNE	%15,XSWFLG
	HRRI	%00,10
	MOVEI	%02,SRCBUF	;GET BUFFER HEADER ADDRESS
	PUSHJ	%17,INISET	;INITIALIZE THE SOURCE DEVICE
	MOVEI	%05,.JBFFS
	EXCH	%05,.JBFF	;SET TO TOP OF INPUT BUFFER
	INBUF	SRC,NUMBUF
	MOVEM	%05,.JBFF	;RESTORE .JBFF
	TLNE	%13,777000	;IS THERE A SWITCH TO PROCESS?
	XCT	%13		;EXECUTE THE ASSEMBLED UUO
	TRZE	%16,EXTBIT	;WAS AN EXPLICIT EXTENSION SEEN?
	JRST	SRC3A		;YES, LOOK FOR IT
	MOVSI	%14,(SIXBIT /BIN/)
	HLLZM	%14,XE1		;NO, TRY .PAL FIRST
	LOOKUP	SRC,XE
	 CAIA
	POPJ	%17,
	MOVSI	%14,(SIXBIT /BIN/)
	HLLZM	%14,XE1
	LOOKUP	SRC,XE
	TDZA	%14,%14		;NOT FOUND, TRY BLANK
	POPJ	%17,		;FOUND
SRC3A:	HLLZM	%14,XE1		;SAVE EXTENSION IN LOOKUP BLOCK
	LOOKUP	SRC,XE		;LOOKUP FILE NAME
	JRST	ERRCF		;FILE NOT FOUND
	POPJ	%17,		;EXIT


	SUBTTL	COMMAND STRING DECODER

;EXEC COMMAND STRING DISPATCHING
;THIS ROUTINE PICKS UP CHARACTERS FROM THE EXEC TTY BUFFER AND
;DISPATCHES TO THE PROPER ROUTINE DEPENDING ON THE TYPE OF
;CHARACTER. A TABLE OF BYTES AND BYTE POINTERS ALLOWS EACH CHARAC-
;TER IN THE ASCII SET TO BE TREATED INDIVIDUALLY.


GETNAM:	SETZ	%14,		;CLEAR SYMBOL WORD
	MOVE	%06,[POINT 6,%14]


GETCMN:	PUSHJ	%17,GETTTI	;GET NEXT CHARACTER
	CAIN	%05,"["		;PROJECT-PROGRAMMER PAIR?
	JRST	LFTBRA		;YES
	CAIGE	%10,4		;MODIFY CODE IF .GE. 4
	TRNN	%16,SWTBIT	;MODIFY IF SWITCH IS ON
	ADDI	%10,4		;CHANGE DISPATCH BY ADDING 4
	HRRZ	%02,DSPTCH(%10)	;LOAD RIGHT HALF DISPATCH
	CAIL	%10,10		;SKIP IF CORRECT
	HLRZ	%02,DSPTCH-10(%10);OTHERWISE, GET LEFT HALF DSPTCH
	JRST	@%02		;GO TO CORRECT ROUTINE

GETTTI:	ILDB	%05,TTIPNT	;GET A CHARACTER FROM TTY BUFFER
	MOVE	%10,%05		;ANOTHER COPY OF IT IN AC %10
	IDIVI	%10,8		;TRANSLATE TO 4-BIT CODE
	ADD	%10,[POINT 4,BITE,]	;SET BYTE POINTER
	IBP	%10		;MOVE TO PROPER BYTE
	SOJGE	%11,.-1		;TEST FOR END
	LDB	%10,%10		;OK, FETCH BYTE
	CAIN	%10,4		;IS IT A NULL?
	JRST	GETTTI		;YES, TRY AGAIN
	POPJ	%17,		;NO, EXIT

;COMMAND DISPATCH TABLE AND BYTE POINTERS
DSPTCH:	XWD	GETCMN,	ERRBS	;IGNORED CHAR, BAD CHAR(SWITCH)
	XWD	SWTCH,	SWTCHA	;<(>, LETTER(SWITCH MODE)
	XWD	COLON,	ERRBS	;<:>, NUMBER(SWITCH MODE)
	XWD	PERIOD,	SWTCHE	;<.>,<)>ESCAPE SWITCH MODE
	XWD	LFTARW,	ERRIC	;<_> OR <=>, BAD CHAR (NORMAL MODE)
	XWD	COMMA,	STORE	;<,>,ALPHABETICH CHAR (NORMAL)
	XWD	CARRTN,	STORE	;<CR>,NUMERIC CHAR (NORMAL)
	XWD	SLASH,	ERRIC	;</>, <)> ILLEGAL ESCAPE
IFN CCLSW,<
	XWD	RUNUUO,0	;<!>
	XWD	INDFIL,0	;<@>
>
IFE CCLSW,<
	XWD	ERRIC,0
	XWD	ERRIC,0
>
;BYTE TABLE FOR DISPATCHING
;CLASSIFICATION BYTE CODES


;	BYTE	DISP	CLASSIFICATION


;	00	00	ILLEGAL CHARACTER, SWITCH MODE
;	01	01	ALPHABETIC CHARACTER, SWITCH MODE
;	02	02	NUMERIC CHARACTER, SWTICH MODE
;	03	03	SWITCH MODE ESCAPE, SWITCH MODE


;	00	04	ILLEGAL CHARACTER, NORMAL MODE
;	01	05	ALPHABETIC CHARACTER, NORMAL MODE
;	02	06	NUMERIC CHARACTER, NORMAL MODE
;	03	07	SWITCH MODE ESCAPE, NORMAL MODE


;	04	10	IGNORED CHARACTER
;	05	11	ENTER SWITCH MODE WITH A <(>
;	06	12	DEVICE DELIMITER, <:>
;	07	13	FILE EXTENSION DELIMITER, <.>
;	10	14	OUTPUT SPEC. DELIMITER, <_> OR <=>
;	11	15	FILE DELIMITER, <,>
;	12	16	COMMAND TERMINATOR, <CR>
;	13	17	ENTER SWITCH MODE WITH </>
;	14	20	CCL FILE DELIMITER <!>
;	15	21	INDIRECT FILE DELIMITER <@>


;BYTE TABLE:

BITE:
	BYTE	(4)	 4,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  , 4,12, 4, 4,12,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,12,12,  ,  ,  ,  

	BYTE	(4)	 4,14, 4,  ,  ,  ,  ,  
	BYTE	(4)	 5, 3,  ,  ,11,  , 7,13 
	BYTE	(4)	 2, 2, 2, 2, 2, 2, 2, 2
	BYTE	(4)	 2, 2, 6,  ,  ,10,  ,14  

	BYTE	(4)	15, 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1,  ,  ,  ,  ,10

	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,12,  , 4
;LEFT ARROW PROCESSOR
LFTARW:	TRO	%16,ARWBIT	;SET APPROPIATE FLAGS
	TRNN	%16,EXTBIT	;IS THIS A FILE NAME EXTENSION?
	MOVEM	%14,XE		;NO, ITS A FILE NAME
	TRZE	%16,INFBIT	;IS THIS A NULL FILE?
CPOPJ1:	AOS	(%17)		;GOOD EXIT
CPOPJ:	POPJ	%17,		;...

;PERIOD PROCESSOR
PERIOD:	TRO	%16,EXTBIT	;SET FLAG FOR EXPLICIT EXTENSION
	MOVEM	%14,XE		;SAVE THE FILE NAME
	JRST	GETNAM		;RE-ENTER THE GETNAM ROUTINE

;COLON PROCESSOR
COLON:	MOVE	%01,%14		;SET UP NEW DEVICE NAME
	JRST	GETNAM		;RETURN FOR MORE COMMAND

;COMMA PROCESSOR
COMMA:	TRZN	%16,INFBIT	;IS THIS A NULL FILE?
	TRNE	%16,ARWBIT	;ONLY LOOK FOR THEM IF NO _
	SKIPA			;NOT A NULL FILE
	POPJ	%17,		;NULL FILE, EXIT
COMMA1:	TRNN	%16,EXTBIT	;DO WE HAVE A FILE NAME EXTENSION?
	MOVEM	%14,XE		;NO, IT WAS A FILE NAME
	JRST	CPOPJ1		;GOOD EXIT

;CARRIAGE RETURN PROCESSOR
CARRTN:	TRNN	%16,NULBIT	;IS THIS JUST A RANDOM CR?
	JRST	NULFIL		;YES, RESTART COMPLETELY
	TRO	%16,ENDBIT	;IS THIS A NORMAL MODE COMMAND?
	TRNN	%16,ARWBIT	;YES, HAS A LEFT ARROW BEEN SEEN?
	JRST	ERRSE		;NO, SYNTAX ERROR
	JRST	COMMA1		;YES, TREAT IT LIKE A COMMA
;THE FOLLOWING TWO ROUTINES HANDLE ALPHANUMERIC CHARACTERS
;FOUND IN THE COMMAND STRING. IN NORMAL MODE, THE CHARACTER
;IS DEPOSITED TO FORM A SIXBIT SYMBOL. IN SWITCH MODE, THE
;PROPER INSTRUCTION IS EXECUTED WITH THE AID OF A DISPATCH
;TABLE. THEN, IF SWITCH MODE WAS ENTERED WITH A SLASH, THE
;EXEC EXITS FROM SWITCH MODE.


STORE:	TRO	%16,INFBIT!NULBIT;TURN ON BITS FOR CR ROUTINE
	SUBI	%05,40		;CONVERT SIXBIT TO ASCII
	TLNE	%06,770000	;DON'T STORE IF NO ROOM FOR CHAR
	IDPB	%05,%06		;PLOP THE CHARACTER INTO AC %14
	JRST	GETCMN		;RETURN

SWTCHA:	MOVEI	%11,-"A"(%05)
	MOVE	%10,[POINT 4,BYTAB]
	IBP	%10
	SOJGE	%11,.-1
	LDB	%11,%10
	JUMPE	%11,ERRBS
	CAIG	%11,SWTABA-SWTAB;THIS SWITCH LEGAL FOR INPUT?
	TRNN	%16,ARWBIT	;  NO, ERROR IF "_" SEEN
	CAIA			;OK
	JRST	ERRWF		;  ERROR, SWITCH IN WRONG FIELD
	XCT	SWTAB-1(%11)
	JRST	ERRBS
	TRZE	%16,SLABIT	;CALLED BY A SLASH?
	TRZ	%16,SWTBIT	;YES, EXIT FROM SWITCH MODE
	JRST	GETCMN		;NO, RETURN FOR MORE CHARACTERS


;THE FOLLOWING THREE ROUTINES HANDLE THE CONTROL CHARACTERS
;IN THE COMMAND STRING WHICH CAUSE THE EXEC TO ENTER INTO AND
;EXIT FROM SWITCH MODE. THERE ARE TWO TYPES OF SWITCH MODE,
;DEPENDING ON WHETHER IT IS ENTERED WITH A </> OR A <(>.


SLASH:	TRO	%16,SLABIT	;TURN ON THE SPECIAL SWITCH MODE
SWTCH:	TROA	%16,SWTBIT	;TURN ON NORMAL SWITCH MODE
SWTCHE:	TRZ	%16,SWTBIT	;TURN OFF THE NORMAL SWITCH MODE
	JRST	GETCMN		;RETURN FOR MORE CHARACTERS
;DISPATCH TABLE FOR SWITCHES


	DEFINE	SETSW	(LETTER, INSTRUCTION) <
	INSTRUCTION
	Y=<"LETTER"-"A">-^D9*<X=<"LETTER"-"A">/^D9>
	SETCOD	\X,Y>

	DEFINE	SETCOD	(X,Y)
	<BYTAB'X=BYTAB'X!<.-SWTAB>B<4*Y+3>>

BYTAB0=	0
BYTAB1=	0
BYTAB2=	0

SWTAB:

SWTABA:

BYTAB:	+BYTAB0
	+BYTAB1
	+BYTAB2
LFTBRA:	SETZM	XE3		;CLEAR NUMBER
LFTBR1:	HRLZS	XE3		;COMMA, MOVE TO LEFT HALF
LFTBR2:	PUSHJ	%17,GETTTI	;GET NEXT CHAR
	CAIN	%05,"]"		;TERMINAL?
	JRST	GETCMN		;YES, EXIT
	CAIN	%05,","		;SEPARATOR?
	JRST	LFTBR1		;YES
	CAIL	%05,"0"		;TEST FOR OCTAL NUMBER
	CAILE	%05,"7"
	JRST	ERRIC		;IMPROPER CHARACTER
	HRRZ	%10,XE3		;OK, GET PREVIOUS VALUE
	IMULI	%10,8
	ADDI	%10,-"0"(%05)	;ACCUMULATE NEW NUMBER
	HRRM	%10,XE3
	JRST	LFTBR2


;THE FOLLOWING CODE IS USED FOR PROCESSING THE COMMAND
;STRINGS FOR THE CCL COMMAND FEATURES
IFN CCLSW,<


DSKNIT:				;INIT DSK FOR CCL
IFN	TEMPC,<
	HRRZ	%00,.JBFF	;USE .JBFF AS START OF CCL BUFFER
	HRRM	%00,CMDPNT	;DUMMY UP BUFFER HEADER
	HRRM	%00,TMPFIL+1	;SET UP TMPCOR READ BLOCK
	SOS	TMPFIL+1	;MAKE IT PROPER IOWD FORMAT
	HRRI	%01,(SIXBIT /P11/)
	HRLM	%01,TMPFIL	;SETUP NAME OF FILE TO BE READ
	MOVNI	%01,200		;AND WORD COUNT
	HRLM	%01,TMPFIL+1	;IN READ BLOCK
	MOVE	%01,[XWD 2,TMPFIL]	;SET UP AC FOR A READ
	TMPCOR	%01,		;READ AND DELETE "P11" FILE
	JRST	TMPEND		;NO FILE IN CORE TRY DISK
	ADD	%00,%01		;GET END OF FILE
	MOVEM	%00,.JBFF	;UPDATE .JBFF SO FILE ISN'T WIPED OUT
	HRLM	%00,.JBFFI	;SAVE FOR LATER
	IMULI	%01,5		;CALCULATE CHARACTER COUNT
	MOVEM	%01,CMDCNT	;STORE IN BUFFER HEADER
	MOVSI	%01,(POINT 7,,)	;BYTE POINTER
	HLLM	%01,CMDPNT	;BUFFER HEADER NOW SETUP
	SETOM	TMPFLA		;MARK THAT TMPCOR UUO IN PROGRESS
	JRST	CPOPJ1
TMPEND:
	MOVEI	%00,3		;INIT 3 DIGIT COUNTER
	PJOB	%02,		;GET JOB NUMBER
DSKNI1:	IDIVI	%02,^D10	;GET LAST DIGIT
	ADDI	%03,"0"-40	;CONVERT TO SIXBIT
	LSHC	%03,-6		;SLIDE CHAR INTO AC4
	SOJG	%00,DSKNI1	;3 CHARS YET?
	HRRI	%04,(SIXBIT /P11/)	;YES, GET FILENAME ###P11.TMP
	MOVEM	%04,XE		;SAVE FILE NAME IN LOOKUP DIRECTORY
	MOVSI	%04,(SIXBIT /TMP/)	;SET UP EXTENSION
	MOVEM	%04,XE1		;SAVE EXTENSION IN LOOKUP DIRECTORY
	SETZM	XE3		;ZERO PROJ,PROG #'S

	MOVEI	%00,ALMODE	;ASCII LINE DATA MODE
	MOVSI	%01,(SIXBIT /DSK/)
	MOVEI	%02,CMDBUF	;GET BUFFER HEADER ADDRESS
	OPEN	CMD,%00		;INIT DSK OK?
	JRST	DSKNI2		;NO, TYPE MESSAGE
	LOOKUP	CMD,XE		;LOOKUP ###P11, TMP ON DISK
	JRST	DSKNI2		;FILE NOT FOUND
	INBUF	CMD,1		;ONE INPUT BUFFER
	MOVE	%00,.JBFF
	HRLM	%00,.JBFFI
	JRST	CPOPJ1		;FILE FOUND, SKIP RETURN
DSKNI2:	MOVE	%00,.JBFF
	HRLM	%00,.JBFFI
	JRST	ERRCF1


GETCM3:	MOVNI	%00,5		;SKIP OVER SEQUENCE NUMBER
	ADDM	%00,CMDCNT	;REDUCE COUNT BY 5 BYTES
	AOS	CMDPNT		;ADVANCE POINTER, FALL THROUGH

GETCMD:	SOSG	CMDCNT		;ANY CHARACTERS LEFT?
	PUSHJ	%17,GETCM1	;NO GET ANOTHER BUFFER FULL
	ILDB	%05,CMDPNT	;GET CHARACTER
	MOVE	%00,@CMDPNT	;CHECK FOR SEQUENCE NUMBER
	TRNE	%00,1
	JRST	GETCM3		;BY-PASS THE SEQUENCE NUMBER
	CAIN	%05,175		;OLD ALTMODE?
	MOVEI	%05,33		;YES, MAKE IT NEW ALTMODE
	CAIL	%05,140		;IS CHARACTER LOWER CASE?
	TRZ	%05,40		;YES, CHANGE TO UPPER CASE
	MOVE	%02,%05
	POPJ	%17,		;EXIT WITH CHARACTER
GETCM1:

IFN	TEMPC,<
	SKIPE	TMPFLA		;IS A TMPCOR UUO GOING?
	JRST	GETCM2		;YES, THEN WE ARE DONE?
>
	IN	CMD,
	POPJ	%17,		;NO ERRORS OR END OF FILE
	STATZ	CMD,IODATA!IODEV!IOBKTL
	JRST	ERRCMD		;DATA ERRORS
GETCM2:
	JSP	%10,DELFIL	;DELETE FILE
	EXIT


DELFIL:	SKIPE	INDFLA		;DON'T DELETE IF INDIRECT FILE
	JRST	(%10)
	CLOSE	CMD,0		;CLOSE COMMAND FILE
	SETZB	%04,%05
	SETZB	%06,%07
IFN	TEMPC,<
	SKIPE	TMPFLA		;TMPCOR BEING USED?
	JRST	(%10)		;YES, DON'T RENAME FILE?
>
	RENAME	CMD,%04
	JFCL
	JRST	(%10)		;RETURN


RUNUUO:			;PASS PROGRAM CONTROL TO NEXT PROGRAM (LNKX11)
	SKIPN	%01
	MOVSI	%01,(SIXBIT /SYS/)	;IF NO DEVICE, ASSUME SYS:
	TRNN	%16,EXTBIT	;PERIOD TYPED?
	MOVEM	%14,XE		;NO, THEN FILE NAME IS IN %14
	TRNN	%16,EXTBIT	;PERIOD TYPED?
	MOVEI	%14,0		;NO, ASSUME 0 EXTENSION
	HLLZM	%14,XE1		;SAVE IN DIRECTORY
	JSP	%10,DELFIL	;DELETE COMMAND FILE
	MOVE	%00,[XWD 1,%01]	;START INCREMENT,,6 WORD RUN BLOCK ADR
				;%01 = DEVICE
	MOVE	%02,XE		;GET FILENAME
	MOVE	%03,XE1		;GET EXTENSION
	SETZB	%04,%06
	MOVE	%05,XE3		;GET PROJ,PROG
	RUN	%00,		;START NEXT PROGRAM
	JSP	%10,ERROR	;RUN FAILED
	ASCIZ	/LINKAGE ERROR FOR 23/
INDFIL:	TRNN	%16,EXTBIT	;SET UP THE FILENAME IF NECESSARY
	MOVEM	%14,XE
	TRNN	%16,ARWBIT	;NORMAL MODE
	TLNN	%16,BINBIT	;OR BINARY SPECIFIED?
	JRST	ERRIC		;YES, ILLEGAL CHARACTER
	MOVE	%00,[INIT CMD,ALMODE]
	SKIPN	%01		;INIT CMD FOR @ FILE
	MOVSI	%01,(SIXBIT /DSK/)
	MOVEI	%02,CMDBUF
	PUSHJ	%17,CMDSET
	XWD	INBIT,1_ALMODE	;LEGAL BITS FROM DEVCHR
	TRZE	%16,EXTBIT	;EXTENSION?
	JRST	INDFI1		;YES, DON'T TRY ASSUMPTIONS
	MOVSI	%14,(SIXBIT /CMD/)
	HLLZM	%14,XE1
	LOOKUP	CMD,XE
	TDZA	%14,%14		;TRY NULL EXTENSION
	JRST	INDFI2
INDFI1:	HLLZM	%14,XE1
	LOOKUP	CMD,XE
	JRST	ERRCF		;CANNOT FIND COMMAND FILE
INDFI2:	SETOM	CCLFLA		;NON-STANDARD COMMAND STRING
	SETOM	INDFLA		;SET INDIRECT FLAG
	INBUF	CMD,1		;SINGLE BUFFER
	MOVE	%14,.JBFF
	HRLM	%14,.JBFFI	;SAVE DATA RESTORE ADDRESS
	JRST NXTCCL

>
;CALL:	PUSHJ	%17,CMDSET
;	XWD	BITS1,BITS2	;LEGAL BITS ON DEVCHR
;	RETURN

CMDSET:	MOVE	%03,%01		;GET DEVICE NAME
	DEVCHR	%03,
	SETCMM	%03		;COMPLEMENT BITS
	TDNE	%03,@(%17)	;WERE ALL BITS ONE?
	JRST	ERRNIT		;NO
	AOS	(%17)		;YES, SKIP RETURN
				;FULL THROUGH


INISET:	MOVE	%03,[JRST ERRNA];ERROR EXIT FOR INIT
	MOVSI	%04,(POPJ %17,)
	JRST	%00
	SUBTTL	EXEC ERROR ROUTINES

ERRCMD:	MOVEI	%10,[ASCIZ /DEVICE INPUT ERROR FOR COMMAND STRING/]
	JRST ERROR

ERRNIT:	MOVEI	%10,[ASCIZ /IMPROPER IO FOR DEVICE 2/]
	JRST ERROR

IFN CCLSW,<
ERRCF1:	SETZM	CCLFLA		;LOOKUP FOR DSK:###P11.TMP FAILED
>


ERRCF:	MOVEI	%10,[ASCIZ /CANNOT FIND 234/]
	JRST	ERROR

ERRID:	MOVEI	%10,[ASCIZ /INPUT DATA ERROR 234/]
	JRST	ERROR

ERRBS:	MOVEI	%10,[ASCIZ /1 IS A BAD SWITCH/]
	JRST	ERROR

ERRIC:	MOVEI	%10,[ASCIZ /1 IS AN ILLEGAL CHARACTER/]
	JRST	ERROR

ERRNA:	MOVEI	%10,[ASCIZ /2 IS NOT AVAILABLE/]
	JRST	ERROR

ERRNR:	MOVEI	%10,[ASCIZ /NO ROOM FOR 234/]
	JRST	ERROR

ERRSE:	MOVEI	%10,[ASCIZ /SYNTAX ERROR IN COMMAND STRING/]
	JRST	ERROR

ERRNC:	MOVEI	%10,[ASCIZ /INSUFFICIENT CORE/]
	JRST	ERROR

ERRWF:	MOVEI	%10,[ASCIZ /1 ILLEGAL SWITCH FOR INPUT/]
	JRST	ERROR

ERRTF:	MOVEI	%10,[ASCIZ /TOO MANY INPUT FILES/]
	JRST	ERROR

ERRTB:	MOVEI	%10,[ASCIZ /2 ILLEGAL FOR BINARY OUTPUT/]
	JRST	ERROR

ERRLD1:	MOVEI	%10,[ASCIZ / LOAD ERROR ON FILE 234/]
	JRST	ERROR

ERRLD2:	MOVEI	%10,[ASCIZ / TELETYPE INPUT FORBIDDEN DURING LOADING PROCESS.
 LOAD ABORTED DURING FILE:234/]
	JRST	ERROR
ERROR:				;NON-RECOVERABLE ERROR MESSAGE
	PUSHJ	%17,VT40R	;RESET VT40.
	SETOM	MESSF		;AND LEAVE INFO AROUND.
	PUSH	%17,%10		;STACK MESSAGE ADDRESS
	TRNE	%16,MODBIT	;HAVE WE EXEC AC'S?
	PUSHJ	%17,ACEXCH	;  NO, GET THEM
	POP	%17,%10		;RESTORE MESSAGE POINTER
	MOVSI	%16,ERRBIT!LSTBIT!BINBIT	;FUDGE FLAGS
	PUSHJ	%17,LSTCR
	MOVEI	%02,"?"
	PUSHJ	%17,LSTOUT
	PUSHJ	%17,LSTSP	;TYPE SPACE
	PUSHJ	%17,LSTMCR
	PUSHJ	%17,LSTCR
	JRST	START

LSTMCR:	PUSHJ	%17,LSTMSG
	JRST	LSTCR		;LIST MESSAGE AND CRR

LSTMSG:	TLOA	%10,(POINT 7,,)	;SET BYTE POINTER AND SKIP
LSTMS4:	PUSHJ	%17,LSTOUT	;TYPE CHARACTER
LSTMS5:	ILDB	%02,%10		;GET CHARACTER
	JUMPE	%02,CPOPJ	;TEST FOR END
	CAIL	%02,"1"		;TEST FOR SWITCH
	CAILE	%02,"5"
	JRST	LSTMS4		;NO, TYPE THE CHARACTER
	PUSHJ	%17,@[EXP ERR1,ERR2,ERR3,ERR4,DNC]-"1"(%02)
	JRST	LSTMS5		;GET NEXT CHARACTER

ERR1:	MOVE	%02,%05		;GET IMPROPER CHARACTER
	JRST	LSTOUT		;DUMP IT

ERR2:	MOVE	%00,%01		;GET DEVICE NAME
	PUSHJ	%17,LSTSIX	;TYPE IT
	MOVEI	%02,":"
	JRST	LSTOUT		;TYPE ":"

ERR3:	MOVE	%00,XE		;GET FILE NAME
	JRST	LSTSIX		;TYPE IT

ERR4:	HLLZ	%00,XE1		;GET EXTENSION
	JUMPE	%00,CPOPJ	;EXIT IF NULL
	MOVEI	%02,"."
	PUSHJ	%17,LSTOUT	;TYPE "."
	JRST	LSTSIX
EXIT:	CLOSE	SRC,		;CLOSE THE SOURCE DEVICE
	CLOSE	LST,		;CLOSE THE LISTING FILE
	TLON	%16,LSTBIT	;WAS THERE A LISTING FILE?
	PUSHJ	%17,LSTTST	;YES, TEST FOR FINAL ERROR
	TRNN	%16,ENDBIT	;END OF COMMAND STRING?
	JRST	ERRTF		;  NO, MARK ERROR
IFN CCLSW,<
	SKIPN	CCLFLA		;RESTART IF NOT CCL MODE
	JRST	START
	HLRZ	%00,.JBFFI
	MOVEM	%00,.JBFF	;RESTORE DATA AREA

	RELEAS	LST,0
	RELEAS	BIN,0
	RELEAS	SRC,0
EXIT6:	PUSHJ	%17,GETCMD	;GET NEXT COMMAND CHAR
	CAIL	%05,12		;THROW AWAY REST
	CAILE	%05,15		;OF LAST LINE
	CAIA
	JRST	EXIT6
	MOVSI	%05,070000	;BACK UP BYTE
	ADDM	%05,CMDPNT	;POINTER ONE BYTE
	AOS	CMDCNT
	JRST	NXTCCL		;GO DO NEXT COMMAND
>
IFE CCLSW,<
	JRST	START		;BACK TO BEGINNING

>
CORSET:				;INIT DYNAMIC MEMORY
	HRRZ	%00,.JBREL	;GET TOP OF CORE
	MOVEM	%00,SYMTOP
	SUBI	%00,2		;GET POINTER TO BOTTOM OF TABLE
	MOVEM	%00,SYMBOT	;STORE IT
	MOVSI	%00,(1B0)
	MOVEM	%00,@SYMBOT	;STORE LOWER BUMPER
	SETCAM	%00,@SYMTOP	;  AND UPPER BUMPER
	POPJ	%17,


ACEXCH:				;SWAP AC'S
	TRC	%16,MODBIT	;TOGGLE MODE BIT
	EXCH	%00,AC00
	EXCH	%01,AC01
	EXCH	%02,AC02
	EXCH	%03,AC03
	EXCH	%04,AC04
	EXCH	%05,AC05
	EXCH	%06,AC06
	EXCH	%07,AC07
	EXCH	%10,AC10
	EXCH	%11,AC11
	EXCH	%12,AC12
	EXCH	%13,AC13
	EXCH	%14,AC14
	POPJ	%17,
	SUBTTL	EXEC ROUTINES USING ASSEMBLER AC'S


LST3SP:				;LIST SPACES
	PUSHJ	%17,LSTSP
LST2SP:	PUSHJ	%17,LSTSP
LSTSP:	MOVEI	%02,SPACE
	JRST	LSTOUT

LSTNUM:	TROA	%02,"0"		;LIST NUMERIC
LSTASC:	ADDI	%02,40		;CONVERT SIXBIT TO ASCII
	JRST	LSTOUT

LSTCR:	TDZA	%02,%02		;LIST CR-LF
LSTTAB:	MOVEI	%02,TAB		;LIST A TAB
LSTOUT:				;LISTING ROUTINE
	TLNN	%16,LSTBIT!RSWBIT	;LISTING REQUESTED?
	PUSHJ	%17,LPTOUT	;  YES
	TLNE	%16,ERRBIT	;ERROR LISTING?
	TLNE	%16,NSWBIT!TTYBIT	;  YES, TO TTY?
	POPJ	%17,		;  NO
	JUMPE	%02,LSTOU1	;BRANCH IF CR-LF
	OUTCHR	%02		;LIST CHARACTER
	POPJ	%17,		;EXIT

LSTOU1:	OUTSTR	[BYTE (7) CRR, LF, 0]
	POPJ	%17,		;CR-LF TO TTY
LPTOUT:				;OUTPUT TO LISTING DEVICE
LSTDMP:	SOSG	LSTCNT		;DECREMENT ITEM COUNT
	PUSHJ	%17,LIST1	;EMPTY ENTIRE BUFFER
	IDPB	%02,LSTPNT	;STORE THE CHARACTER
	CAIN	%02,LF		;IF LINE FEED
	TLNN	%16,TTYBIT	;AND LISTING IS ON TTY,
	POPJ	%17,
				;DUMP THE BUFFER


LIST1:	OUTPUT	LST,		;EMPTY A BUFFER
LSTTST:	STATO	LST,IODATA!IODEV!IOWRLK	;CHECK FOR ERRORS
	POPJ	%17,		;NO, EXIT
	MOVEI	%10,[ASCIZ /LOAD FILE OUTPUT ERROR/]
	JRST	ERROR		;TYPE MESSAGE
CHAR:	TLNE	%15,LEDNULTRLNUL	;ANY NULL'S AROUND?
	JRST	CHAR7		;YEP. TAKE CARE OF THEM.
	SOSGE	SRCCNT		;DECREMENT ITEM COUNT
	JRST	CHAR4		;GET ANOTHER BUFFER IF NECESSARY
	ILDB	%14,SRCPNT
	POPJ	%17,		;ACCEPT IT

CHAR4:	INPUT	SRC,		;CALL MONITIOR FOR A BUFFER
	STATZ	SRC, IODATA+IODEV+IOBKTL+IOWRLK
	JRST	ERRID		;INPUT TRANSMISSION ERROR
	STATO	SRC, IOEOF	;WAS AN END OF FILE REACHED?
	JRST	CHAR		;GET NEXT CHAR
CHAR5:	CLOSE	SRC,
	TRNN	%16,ENDBIT	;CRR SEEN BY COMMAND SCANNER?
	JRST	CHAR6		;  NO, GET NEXT SOURCE
	TLO	%15,ENDFLG	;YES, FLAG END
	POPJ	%17,

CHAR6:	TLO	%15,TRLNUL	;TELL ABOUT NULL TRAILER.
	SETZ	%14,		;PREPARE TO RETURN A NULL.
	JRST	CHAR8		;AND TAKE CARE OF IT NOW.

CHAR7:	SETZ	%14,		;CLEAR RETURN REGISTER NOW.
	SOSLE	SRCNUL		;ALL DONE WITH NULL'S
	POPJ	%17,		;NOPE. KEEP UP THE GOOD WORK.
	TLZE	%15,LEDNUL	;LEADER ON?
	POPJ	%17,		;YEP. ALL DONE. EXIT NOW.
	TLC	%15,LEDNUL!TRLNUL	;TURN OFF TRAILER, TURN ON LEADER.
	PUSHJ	%17,ACEXCH	;GET EXEC AC'S
	PUSHJ	%17,GETSRC	;GET THE NEXT SOURCE FILE
	TRO	%16,HDRBIT	;START NEW FILE
	PUSHJ	%17,ACEXCH	;SAVE EXEC AC'S AND RETURN

CHAR8:	MOVEI	%01,4		;SET UP FOR FOUR NULL'S
	MOVEM	%01,SRCNUL
	POPJ	%17,		;AND EXIT.



	SUBTTL	ASSEMBLER PROPER
;	THESE ARE THE LISTING ERROR FLAGS.

ERRA=	400000
ERRB=	200000
ERRD=	100000
ERRE=	040000
ERRI=	020000
ERRL=	010000
ERRM=	004000
ERRO=	002000
ERRP=	001000
ERRQ=	000400
ERRR=	000200
ERRT=	000100
ERRU=	000040
ERRN=	000020
ERRZ=	000010		;MARGINAL INSTRUCTION

ERRP1=	000001




MAJOR:	TRZ	%16,HDRBIT	;CLEAR HEADER FLAG.
	WAIT	LST,		;WAIT UNTIL I/O STOPS ON CHANNEL.
	PUSHJ	%17,ISREP	;REPLY THERE?
	JRST	CLENUP		;NOPE. PROBABLY SOME OTHER DEVICE.
MAJORE:	ANDI	%02,177		;JUST 7 BITS, PLEASE.
	CAIE	%02,175		;IS IT 175?
	JRST	ERRLD2		;NO. RANDOM CHARACTERS. IGNORE.
	PUSHJ	%17,ISREP	;GET NEXT CHARACTER.
	JRST	ERRLD2		;NOT ONE THERE. ERROR.
	ANDI	%02,177		;AGAIN JUST 7 BITS.
	CAIN	%02,"B"		;IS IT "BAD"
	JRST	ERRLD1		;YEP. GIVE ERROR MESSAGE.
	CAIE	%02,"G"		;IS IT GOOD?
	JRST	ERRLD2		;NOT GOOD. MUST BE TYPED IN CRAP.

CLENUP:	INCHRS	%02		;WAIT FOR ALL INPUT TO FINISH.
	JRST	.+2
	JRST	.-2

	PUSHJ	%17,VT40R	;RESET VT40

	TLNE	%15,ENDFLG	;ALL DONE?
	POPJ	%17,0		;YEP. EXIT
	SETZ	%05,		;CLEAR WHICH CHAR COUNTER.
	PUSHJ	%17,VT40L	;LOAD VT40
	PUSHJ	%17,VTNULL	;GIVE LEADER.


LOADX:	MOVEI	%07,^D500	;CHECK INPUT EVERY 500 CHARACTERS.

LOADDO:	PUSHJ	%17,LOADLP	;LOAD A CHARACTER.
	SOJG	%07,LOADDO	;LOOP UNTIL SOMETHING HAPPENS.
	JUMPLE	%07,CHKLD	;IT HAPPENED. COUNTER ZERO?
	PUSHJ	%17,VTNULL	;NO. MUST BE END OF FILE.
	PUSHJ	%17,LIST1	;DUMP ALL BUFFERS.
	JRST	MAJOR		;AND CHECK FOR RETURN INDICATION.

CHKLD:	INCHRS	%02		;WAS A CHAR SENT?????
	JRST	LOADX		;NOPE. RECYCLE.
	JRST	MAJORE		;YEP. GO UP AND DO IT AGAIN.







ISREP:	INCHRS	%02		;TEST FOR A CHAR.
	JRST	.+2		;NO
	JRST	CPOPJ1		;RETURN NOW.
	MOVEI	%02,1		;SLEEP FOR ONE SECOND.
	SLEEP	%02,
	INCHRS	%02		;ANYTHING YET?
	POPJ	%17,		;NOPE.
	JRST	CPOPJ1		;YET. RETURN NOW.





SEND6:	ANDI	%01,77		;CLEAN OFF CRAP.
	TRNN	%01,40		;LOWER HALF?
	ADDI	%01,100		;YEP. RAISE IT UP TO LEGAL CHARACTER.
	IMUL	%01,[2010040201]
	AND	%01,[21042104377]
	IDIVI	%01,17_7	;AND CORRECT PARITY.
	ANDI	%02,377
	JRST	LPTOUT		;SEND TO OUTPUTER.


GETCHR:	PUSHJ	%17,CHAR
	TRNN	%16,HDRBIT	;END OF THIS FILE.
	TLNE	%15,ENDFLG	;OR TOTAL END.
	JRST	.+2		;YEP.
	POPJ	%17,
	POP	%17,%02		;POP OFF STRAY ITEM.
	JRST	CPOPJ1		;AND RETURN NOW.












LOADLP:	AOJA	%05,@[EXP SCH1,SCH2,SCH3](%05)	;DISPATCH.

SCH1:	PUSHJ	%17,GETCHR	;GET A CHARACTER NOW.
	MOVE	%12,%14		;SAVE
	MOVE	%01,%14
	LSH	%01,-2
	JRST	SEND6		;SEND IT OUT NOW.

SCH2:	PUSHJ	%17,GETCHR	;GET SECOND CHAR.
	MOVE	%01,%12
	ANDI	%01,3
	LSH	%01,4
	MOVE	%12,%14
	LSH	%14,-4
	ANDI	%14,17
	IOR	%01,%14
	JRST	SEND6


SCH3:	SETZ	%05,		;RESET DISPATCHER.
	PUSHJ	%17,GETCHR	;GET LAST CHARACTER OF 3/4
	MOVE	%01,%14		;GET 2 BITS.
	LSH	%01,-6		;SHIFT OVER TWO BITS.
	ANDI	%01,3		;CHOP OFF CRAP.
	LSH	%12,2		;SHIFT OVER 12 2 PLACES.
	IOR	%01,%12		;MAKE INTO A GOODY.
	PUSHJ	%17,SEND6	;SEND OUT SIX BITS NOW.
	MOVE	%01,%14		;GET THE LAST 6
	JRST	SEND6		;AND SEND THEM ALSO.





















vt40r:	movei	%00,altmod
	ioneou	%00		;because of feebleness in the monitor.
	movei	%00,322
	ioneou	%00
	POPJ	%17,


vt40l:	movei	%00,altmod
	ioneou	%00
	movei	%00,314
	ioneou	%00
	POPJ	%17,

VTNULL:	MOVEI	%07,5
	SETZ	%02,
	PUSHJ	%17,LPTOUT
	SOJG	%07,.-1
	POPJ	%17,0







DNC:	IDIVI	%11,^D10
	HRLM	%12,0(%17)
	SKIPE	%11
	PUSHJ	%17,DNC
	HLRZ	%02,0(%17)
	JRST	LSTNUM


LSTSIX:	MOVSI	%06,(POINT 6,%00,)
LSTSI1:	ILDB	%02,%06
	JUMPE	%02,CPOPJ
	ADDI	%02," "
	PUSHJ	%17,LSTOUT
	TLNE	%06,770000
	JRST	LSTSI1
	POPJ	%17,






	IFNDEF	NONREN,	<RELOC	0>



PDPSTK:	BLOCK	PDPLEN

BZCOR:

AC00:	BLOCK	1
AC01:	BLOCK	1
AC02:	BLOCK	1
AC03:	BLOCK	1
AC04:	BLOCK	1
AC05:	BLOCK	1
AC06:	BLOCK	1
AC07:	BLOCK	1
AC08:	BLOCK	1
AC09:	BLOCK	1
AC10:	BLOCK	1
AC11:	BLOCK	1
AC12:	BLOCK	1
AC13:	BLOCK	1
AC14:	BLOCK	1

.JBFFS:	BLOCK	204*NUMBUF

MESSF:	BLOCK	1
TTIPNT:	BLOCK	1
TTISAV:	BLOCK	1

XESAVE:	BLOCK	1

XE:	BLOCK	1
XE1:	BLOCK	1
XE2:	BLOCK	1
XE3:	BLOCK	1

LSTBUF:	BLOCK	1
LSTPNT:	BLOCK	1
LSTCNT:	BLOCK	1

SRCBUF:	BLOCK	1
SRCPNT:	BLOCK	1
SRCCNT:	BLOCK	1
SRCNUL:	BLOCK	1

TMPFIL:	BLOCK	2
TTLFLA:	BLOCK	1
SYMBOT:	BLOCK	1
SYMTOP:	BLOCK	1




EZCOR:

CCLFLA:	BLOCK	1
TMPFLA:	BLOCK	1
INDFLA:	BLOCK	1
.JBFFI:	BLOCK	1
CMDBUF:	BLOCK	1
CMDPNT:	BLOCK	1
CMDCNT:	BLOCK	1



	LF=12
	ALTMOD=175
	CRR=15
	TAB=11
	SPACE=40







	IFNDEF	NONREN,	<RELOC>




	END	START