Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0088/pilots.mac
There is 1 other file named pilots.mac in the archive. Click here to see a list.
	SEARCH PILUNV,JOBDAT

	TITLE PILOTS - PILOT OTS


	TWOSEG
	RELOC 400000





A=1		;YES/NO FLAG
T1=2		;TEMP
T2=3
T3=4
T4=5
T5=6
T6=7
T=10		;HOLDS ADDR. OF TRAP PC
R=11		;HOLDS LAST RANDOM NUMBER
F=12		;FLAGS
CHAN=13		;POINTER TO FILE/CHANNEL TABLE
TT=15		;PC OF UUO
J=16		;.JBFF
P=17		;PDL FOR PROGRAM & PILOTS


;FLAGS:

NUMBER==1	;NUMERIC INPUT
TAG==2		;STUFF IN TAG
DECIMAL==4	;DECIMAL POINT SEEN
;SET UP PDL, .JB41, AND XPAND CORE IF NEEDED

INIT.:	SETZ	A,		;SET FLAG TO "NO"
	MSTIME			;SAVE TIME OF DAY IN AC0
	MOVE	T2,[JSP TT,UUO]
	MOVEM	T2,.JB41
	MOVE	J,.JBFF		;GET FIRST FREE LOCATION
	MOVE	CHAN,J		;ADDRESS OF CHANNEL TABLE
	ADDI	J,^D45		;3 WORDS/BUFFER * 15 CHANNELS
	HRLZI	P,PDLEN		;MAKE A PDP
	HRR	P,J
	ADDI	J,<-PDLEN>+1	;RESERVE FOR PDL
	ADDI	J,WORK		;+ WORKING STORAGE
	PUSH	P,J		;SAVE IT
	CAMLE	J,.JBREL	;STILL OK CORE LOC?
	JRST	[CORE	J,	;NO EXPAND CORE
		 HALT	.
		 JRST	.+1]
	POP	P,J		;RESTORE J
	MOVEM	J,.JBFF		;UPDATE .JBFF
	SUBI	J,WORK		;SET J TO JUST ABOVE WORKSPACE
	JRST	(T1)		;START PROGRAM


;MUST BE ABS 400040
LOC	400040

TRPLOC:	JRST	LOGOUT		;LOG THE SUCKER OUT

	RELOC	400031		;+10 = 400041


;UUO PROCESSOR

UUO:	HLLZ	T1,.JBUUO	;GET UUO
	SETZ	F,		;CLEAR FLAGS
	MOVSI	T2,-UUOTLN	;UUO TABLE LENGTH
	HLLZ	T3,UUOTAB(T2)	;GET UUO
	LDB	T4,[POINT 4,UUOTAB(T2),12]	;GET AC FIELD
	CAIE	T4,17		;WILD CARD?
	JRST	.+5		;NO
	LDB	T4,[POINT 9,T1,8]
	LDB	T5,[POINT 9,T3,8]
	CAMN	T4,T5		;OPCODES MATCH?
	JRST	@UUOTAB(T2)	;YES
	CAME	T1,T3		;MATCH?
	AOBJN	T2,UUO+3	;NO-BUMP&LOOP
	JUMPGE	T2,UUOERR	;HOLLER IF NOT IN TABLE
	JRST	@UUOTAB(T2)	;DISPATCH
;ACCEPT AN ATOM

ATOM:
REPEAT 0,<			;THIS CODE ONLY SOMETIMES WORKS
	MOVEI	T1,T5		;ADDRESS OF BLOCK
	MOVEI	T5,2
	MOVEI	T6,^D300
	DAEMON	T1,		;TELL DAEMON TO WAKE US LATER
	  JRST	NOWAIA		;IF FAILURE, GO ON
	MOVSI	T1,20		;WAKE ON TTY LINE READY
	HIBER	T1,		;OR ON DAEMON WAKE
	  JRST	NOWAIB		;FAILURE
	SKPINL			;TTY INPUT READY?
	JRST	GONE		;TIMED OUT WITH NO TTY LINE INPUT
				;OK, WOKE ON TTY LINE ACTIVITY
>
NOWAIX:	INCHWL	T1		;GET 1ST CHAR. OF ATOM
	CAIE	T1,40		;NO LEADING SPACES
	CAIN	T1,11		;OR TABS
	JRST	ATOM
	CAIE	T1,","		;NULL FIELD?
	CAIG	T1,40		;OR BREAK?
	POPJ	P,		;YES--DONE
	TRNE	F,NUMBER	;NUMERIC INPUT?
	CAIN	T1,"-"		;OR LEADING -?
	JRST	ATOM2		;NO NUMERIC OR LEADING -
ATOM1:	TRNN	F,NUMBER	;NUMERIC INPUT?
	JRST	ATOM2		;NO
	CAIG	T1,"9"
	CAIGE	T1,"0"		;NUMERIC?
	SKIPA			;NOT NUMERIC
	JRST	ATOM2		;OK
	CAIN	T1,"."		;DECIMAL?
	TROE	F,DECIMAL	;DECIMAL & HASNT BEEN ONE?
	JRST	BADNUM		;NON NUMERIC OR 2 DECIMAL POINTS

ATOM2:	IDPB	T1,T2		;INTO TEMP POINTER
	TRNE	F,TAG		;HAVE TAG STORAGE?
	IDPB	T1,T3		;YES, INTO TAG
	INCHWL	T1		;NEXT CHARACTER
	CAIN	T1,11		;TABS ARE SPACES
	MOVEI	T1,40		;..
	CAIE	T1,","		;DELIMITER?
	CAIN	T1,40		;OR SPACE/TAB?
	POPJ	P,		;YES--DONE
	CAIG	T1,40		;BREAK?
	POPJ	P,		;YES
	JRST	ATOM1		;LOOP UNTIL END OF ATOM
;AL: = FULINE ; A: = YESNO

FULINE:	TRO	F,TAG		;SAY WHOLE LINE INTO ONE TAG
	MOVE	T4,.JBUUO	;FULL LINE IS JUST LIKE NO LINE
	MOVE	T3,[POINT 7,(T4)]	;BUT WITH A TAG
YESNO:	MOVE	T2,[POINT 7,(J)]	;TEMP STORAGE POINTER
	MOVEI	T1,40		;LEADING SPACE
	IDPB	T1,T2		;INTO TEMP STORAGE
NXTATM:	PUSHJ	P,ATOM		;DO ATOM
	CAIGE	T1,40		;BREAK ON REAL BREAK?
	JRST	Y1		;YES
	IDPB	T1,T2		;NO, STUFF BREAK
	TRNE	F,TAG		;HAVE TAG?
	IDPB	T1,T3		;BREAK THERE TOO.
	JRST	NXTATM		;& GET NEXT ATOM

Y1:	CAIN	T1,15		;<CR>?
	INCHWL	T1		;EAT <LF>
	MOVEI	T1,40		;TRAILING SPACE
	IDPB	T1,T2		;INTO TEMP STORAGE
	SETZ	A,		;ASSUME NO
	IDPB	A,T2		;NULL FOR ASCIZ
	TRNE	F,TAG		;IN TAG?
	IDPB	A,T3		;NULL IN TAG ALSO
	MOVE	T1,(J)		;FIRST WORD
	CAME	T1,[ASCIZ/ YES /]; "YES" ?
	CAMN	T1,[ASCIZ/ Y /]	;OR "Y" ?
	SETO	A,		;SET YES
	JRST	ZERXIT		;ZERO TEMP FLAGS & RETURN

;HERE ON A:$TAG OR A:#TAG

ACPT2:	TRO	F,NUMBER	;SAME AS BELOW, BUT NUMERIC
ACPT1:	TRO	F,TAG		;STUFF IN TAG
	MOVE	T4,.JBUUO	;GET DESTINATION
	MOVE	T3,[POINT 7,(T4)]	;DEST. POINTER
	MOVE	T2,[POINT 7,(J)]	;TEMP POINTER
	MOVEI	T1,40		;LEADING SPACE
	IDPB	T1,T2		;INTO TEMP STORAGE
	PUSHJ	P,ATOM		;GET ATOM
ACPT1A:	SETZ	T6,		;NULL
	IDPB	T6,T3		;CAP OFF TAG
	MOVE	T4,(TT)		;GET NEXT WORD IN PROGRAM
	HLLZ	T5,T4		;JUST OPCODE
	CAME	T5,[JUMP]	;ARG?
	JRST	WASTEL		;NO-WASTE REST OF LINE
	MOVE	T3,[POINT 7,(T4)]	;YES-MAKE NEW POINTER
	CAIGE	T1,40		;MORE TO COME?
	JRST	NULLEM		;NO--ZERO THE TAG(S)
	IDPB	T1,T2		;PUT BREAK INTO TEMP
	PUSHJ	P,ATOM		;DO NEXT ATOM
	AOJA	TT,ACPT1A	;ADD ONE TO PSEUDO PC & LOOP
WASTEL:	CAIGE	T1,40		;BREAK?
	JRST	WASTEN		;YES
	IDPB	T1,T2		;PUT INTO TEMP
	INCHWL	T1		;GET NEXT CHAR
	JRST	WASTEL		;LOOP

ENDTMP:	CAIN	T1,15		;<CR>?
	INCHWL	T1		;EAT <LF>
	MOVEI	T1,40		;TRAILING SPACE
	IDPB	T1,T2		;INTO TEMP
	SETZ	T1,		;ZERO
	IDPB	T1,T2		;NULL AT END OF TEMP
	TLNE	T2,760000	;END OF WORD?
	JRST	.-2		;NO, LOOP TO END OF WORD
	POPJ	P,		;YES--RETURN

WASTEN:	PUSHJ	P,ENDTMP	;FINISH OFF TEMP
ZERXIT:	TRZ	F,7		;ZERO TEMP FALGS
	JRST	(TT)

NULLEM:	PUSHJ	P,ENDTMP	;FINISH UP TEMP STORAGE
	SETZM	(T4)		;ZERO DESTINATION
	AOJ	TT,		;NEXT ARG
	HLLZ	T3,(TT)		;OPCODE
	CAME	T3,[JUMP]	;ARG?
	JRST	ZERXIT		;NO-ZERO FLAGS & EXIT
	HRRZ	T4,(TT)		;GET DESTINATION
	JRST	NULLEM+1	;LOOP

BADNUM:	OUTSTR	[ASCIZ/INVALID NUMBER - RETYPE FIELD
/]
	CLRBFI			;KILL THE BUFFER
	JRST	ATOM

NOWAIA:	OUTSTR	[ASCIZ/? DAEMON/]
	SKIPA
NOWAIB:	OUTSTR	[ASCIZ/? HIBERNATE/]
	OUTSTR	[ASCIZ/ ERROR
/]
	JRST	NOWAIX


GONE:	OUTSTR	[ASCIZ /
? TIMED OUT WAITING FOR TTY INPUT
/]
	JRST	LOGOUT		;BETTER THAN NOTHING
;EXACT MATCH

EMATCH:	SETZ	A,		;INITIALLY NO
	HLLZ	T1,(TT)		;GET NEXT WORD IN PROGRAM
	CAME	T1,[JUMP]	;ARG?
	JRST	(TT)		;NO-EXIT
	HRRZ	T1,(TT)		;GET ARG ADDRESS
	MOVE	T2,[POINT 7,(T1)]	;MAKE POINTER
	MOVE	T4,[POINT 7,(T3)]	;POINTER TO UUO ADDRESS
	HRRZ	T3,.JBUUO	;..
	JUMPN	T3,EM1		;JUMP IF UUO SUPPLIED ADDRESS
	MOVE	T3,J		;WE USE TEMP STORAGE INSTEAD
	ILDB	T6,T4		;EAT LEADING SPACE
EM1:	ILDB	T5,T2		;GET SOURCE CHAR
	ILDB	T6,T4		;GET LITERAL CHAR
	JUMPN	T5,EM2		;JUMP IF NOT END OF SOURCE
	SKIPN	T6		;END OF LITERAL?
	JRST	YESMAT		;END OF BOTH AT SAME TIME
	HRRZ	T6,.JBUUO	;MATCH AGIN' TEMP?
	JUMPN	T6,.+3
	ILDB	T6,T4		;EAT TRAILING SPACE
	JUMPE	T6,YESMAT
	AOJA	TT,EMATCH
EM2:	SKIPN	T6
	AOJA	TT,EMATCH
	CAME	T5,T6
	AOJA	TT,EMATCH
	JRST	EM1
;MATCH

MATCH:	MOVE	A,[POINT 7,(J)]
	MOVE	T5,(TT)		;GET ARG
	SKIPE	(T5)		;NULL MATCH STRING?
	JRST	MT1		;NO
	MOVE	T1,[BYTE (7) 40,40,0]
	HLLZ	T2,(J)		;GET INPUT
	TLZ	T2,17		;MASK OFF GARBAGE
	CAMN	T1,T2		;BOTH NULL?
	JRST	YESMAT		;YES, MATCH
MT1:	SKIPN	(T5)		;NULL MATCH STRING & INPUT?
	JRST	MX		;NO WAY
	SETZ	T6,		;CLEAR CHAR. COUNT
M1:	MOVE	T1,A
	MOVE	T2,[POINT 7,(T5)]
M2:	ILDB	T4,T2		;GET ARG CHAR.
	JUMPE	T4,YESMAT	;TESTED ALL ARG.- MATCH
	ILDB	T3,T1		;GET ANS CHAR.
	JUMPE	T3,MX		;END OF ANS - NO MATCH
	CAMN	T3,T4		;COMPARE CHARS.
	AOJA	T6,M2		;MATCH. BUMP COUNT & GO
	IBP	A		;TEST NEXT CHAR. IN ANS
	JRST	M1		;TEST NEXT STRING

MX:	SETZ	A,		;NO MATCH
	AOS	TT		;NEXT ARG
	HLLZ	T1,(TT)
	CAME	T1,[JUMP]
	JRST	(TT)
	JRST	MATCH


;EXITS

DOEXIT:	HLRE	T1,P		;GET PUSHDOWN COUNT
	HRRZS	T1
	CAIE	T1,PDLEN	;AT MAIN LEVEL?
	POPJ	P,		;NO, POP & JUMP
QUITIT:	PUSHJ	P,RELDSK	;RELEASE I/O CHANNELS
	EXIT


RELDSK:	MOVEI	T5,1		;START AT I/O CHANNEL 1
	MOVE	T6,[RELEASE]	;INSTRUCTION TO XCT
	CAIN	T5,17		;ALL 15 CHANNELS?
	POPJ	P,		;YES-EXIT
	DPB	T5,[POINT 4,T6,12]	;STORE CHANNEL
	XCT	T6		;RELEASE CHANNEL
	AOJA	T5,.-4		;LOOP FOR ALL CHANNELS


RUNOFF:	OUTSTR	[ASCIZ/
?ATTEMPT TO DROP OFF END OF PROGRAM.
EXIT ASSUMED.
/]
	JRST	QUITIT
;GET THE NUMBER POINTED TO BY UUO

GETNUM:	HRRZ	T2,.JBUUO
	MOVE	T3,[POINT 7,(T2)]
	JUMPN	T2,.+3
	MOVE	T2,J
	ILDB	T1,T2
	SETZB	T1,T5
GN1:	ILDB	T4,T3
	JUMPE	T4,GXIT
	CAIN	T4,.JBUUO
	JRST	GXIT
	CAIE	T4,"-"
	JRST	.+3
	SETO	T5,
	JRST	GN1
	CAIG	T4,"9"
	CAIGE	T4,"0"
	JRST	NOTNUM
	IMULI	T1,12
	ADDI	T1,-60(T4)
	JRST	GN1
GXIT:	SKIPE	T5
	MOVNS	T1
	POPJ	P,

NOTNUM:	OUTSTR	[ASCIZ/
NON-NUMERIC CHARACTER IN ASSUMED NUMERIC FIELD!
/]
	JRST	GXIT
;PUT THE NUMBER INTO THE ADDRESS OF UUO

PUTNUM:	MOVE	T4,.JBUUO
	MOVE	T3,[POINT 7,(T4)]
	JUMPGE	T1,.+4
	MOVEI	T2,"-"
	IDPB	T2,T3
	MOVMS	T1
	PUSHJ	P,P01
	SETZ	T2,
	IDPB	T2,T3
	POPJ	P,


P01:	IDIVI	T1,12
	JUMPE	T1,.+4
	PUSH	P,T2
	PUSHJ	P,P01
	POP	P,T2
	ADDI	T2,60
	IDPB	T2,T3
	POPJ	P,

P02:	IDIVI	T1,12
	ADDI	T1,60
	IDPB	T1,T3
	ADDI	T2,60
	IDPB	T2,T3
	POPJ	P,
GTNLIT:	PUSHJ	P,GETNUM	;GET THE 1ST NUMBER
	MOVE	T6,T1		;SAVE IT
	HRRZ	T2,(TT)		;GET THE NEXT ADDRESS
	JRST	GETNUM+1	;(PJRST)AND GET ITS NUMBER

GMATCH:	PUSHJ	P,GTNLIT	;MATCH IF 1ST > 2ND
	CAMG	T6,T1
	JRST	NOMAT
	JRST	YESMAT

LMATCH:	PUSHJ	P,GTNLIT	;MATCH IF 1ST < 2ND
	CAML	T6,T1
	JRST	NOMAT
	JRST	YESMAT


NOMAT:	SETZ	A,		;"NO"
	JRST	(TT)

YESMAT:	SETO	A,		;"YES"
	JRST	(TT)

CALLIT:	MOVE	T1,.JBUUO	;GET ADDRESS OF ARG
	MOVE	A,[POINT 7,(T1)]		
	MOVE	T2,[POINT 6,T3]
	SETZ	T3,
CALL1:	ILDB	T4,A
	JUMPE	T4,CALL2-2
	CAIL	T4,140
	SUBI	T4,40
	SUBI	T4,40
	IDPB	T4,T2
	TLNE	T2,770000
	JRST	CALL1
	MOVE	T1,T3
	MOVSI	A,'DSK'
CALL2:	PUSHJ	P,RELDSK	;RELEASE I/O CHANNELS
	MOVE	T2,[RUNIT,,140]
	BLT	T2,ENDRUN	;BLT TO LOW CORE
	JRST	140		;JUMP TO LOW CORE

RUNIT:	MOVEI	T2,1
	PHASE	141
	CORE	T2,
	HALT
	SETZB	T2,T3
	SETZB	T4,T5
	MOVEI	T6,A
	RUN	T6,		;RUN IT
ENDRUN:	HALT
	DEPHASE
LOGOUT:	MOVE	T1,[SIXBIT/LOGOUT/]
	MOVE	A,[SIXBIT/SYS/]
	JRST	CALL2		;RUN SYS:LOGOUT


GETIME:	MSTIME	T1,		;DAYTIME IN MILLISECONDS
	SUB	T1,		;FROM STARTUP
	JUMPGE	T1,G1		;POSITIVE
	MOVMS	T1		;ABS DIFF
	MOVE	T2,[EXP ^D1000*^D60*^D24]
	SUB	T1,T2		;REAL DIFF.
G1:	IDIVI	T1,^D1000	;SECONDS
	PUSHJ	P,PUTNUM	;SAVE SECONDS
	JRST	(TT)		;RETURN

GETDT:	MSTIME	T1,		;GET DAYTIME IN MS
	IDIVI	T1,^D1000	;GET SECONDS
	IDIVI	T1,^D60*^D60	;GET HOURS REM MIN
	MOVE	T5,T2		;SAVE REMAINDER
	MOVE	T4,.JBUUO
	MOVE	T3,[POINT 7,(T4)]
	PUSHJ	P,P01		;TYPE HOURS
	MOVEI	T1,":"
	IDPB	T1,T3		;A COLON
	IDIVI	T5,^D60		;GET MIN
	MOVE	T1,T5
	PUSHJ	P,P02
	MOVEI	T1,":"
	IDPB	T1,T3
	MOVE	T1,T6
	PUSHJ	P,P02
	SETZ	T1,
	IDPB	T1,T3
	JRST	(TT)

GETDAY:	DATE	T1,		;GET DATE
	IDIVI	T1,^D31		;GET DAY-1 IN T2
	MOVEI	T5,1(T2)	;SAVE DAYS
	IDIVI	T1,^D12		;GET MONTHS-1 IN T2
	MOVE	T6,T1		;SAVE YEARS
	MOVEI	T1,1(T2)	;MONTHS ON T1
	MOVE	T4,.JBUUO
	MOVE	T3,[POINT 7,(T4)]
	PUSHJ	P,P01
	MOVEI	T1,"-"
	IDPB	T1,T3		;SEPERATOR
	MOVE	T1,T5		;GET DAY
	PUSHJ	P,P01
	MOVEI	T1,"-"
	IDPB	T1,T3
	MOVEI	T1,100(T6)	;GET YEAR + 64
	PUSHJ	P,P01
	SETZ	T1,
	IDPB	T1,T3
	JRST	(TT)
GETRND:	MSTIME	T1,		;MILLISECOND TIMER
	IDIVI	T1,5		;BY 5
	IMUL	T1,T2
	ADD	T1,0		;PLUS DAYTIME START
	ADD	T1,R		;PLUS LAST RANDOM NUMBER
	SETZ	T2,
	RUNTIM	T2,		;GET RUNTIME
	SUB	T1,T2		;SUBTRACT RUNTIME
	TLZ	T1,400000	;NO NEGITIVE NUMBERS
	MOVE	R,T1		;SAVE FOR NEXT RANDOM NUMBER
	IDIVI	T1,^D100	;DIVIDE OFF JIFFY DEPENDENCY
	IDIVI	T1,^D10		;GET .1 SEC COUNTER
	MOVE	T1,T2		;SAVE REMAINDER
	AOJ	T1,		;MAKE 0-9  1-10
	PUSHJ	P,PUTNUM	;SAVE RANDOM NUMBER
	JRST	(TT)


TRAPIT:	HRRZ	T,.JBUUO	;GET LOC OF TRAP BLOCK
	MOVEM	T,.JBINT	;.JBINT _ ADDRESS
	ADDI	T,2		;ADDR+2 = PC
	JRST	(TT)


COMADR:	PUSHJ	P,GETNUM	;GET COMPUTE NUMBER
	MOVE	T5,T1		;SAVE IT
	ADD	T1,TT		;ADD IT TO LOC
	SOJ	T1,
	SETZ	T3,
	MOVE	T4,TT		;SAVE IT
	ADD	T4,T3
	HLLZ	T2,(T4)		;GET NEXT LOC
	CAMN	T2,[JUMP]	;IS IT AN ARG?
	AOJA	T3,.-4		;YES, KEEP COUNTING
	AOJ	T3,		;NO, MAKE REAL NUMBER
	POPJ	P,		;D= # ARGS. T5= COMP #.


COMJMP:	PUSHJ	P,COMADR	;SEE IF LEGAL ARG.
	JUMPLE	T5,(TT)		;IF COMP < 1, BOMB
	CAMG	T5,T3		;IS COMP. > #ARGS?
	JRST	@(T1)		;<= GO TO ARG
	JRST	(TT)		;> THATS A NO NO. FALL THROUGH.


COMPSH:	PUSHJ	P,COMADR	;CHECK LEGAL COMPUTE NUMBER
	JUMPLE	T5,(TT)		;COMP IS ZERO OR LESS
	CAMLE	T5,T3		;IS COMP > ARGS?
	JRST	(TT)		;ILLEGAL COMP.
	PUSH	P,TT		;SAVE RETURN
	PUSHJ	P,@(T1)		;GOSUB
	POPJ	P,		;RETURN FROM CPUSH.
CTAB:	CPLUS.
	CMIN.
	CMULT.
	CDIV.

CTABL==.-CTAB

CTAB1:	ADD	A,T1
	SUB	A,T1
	IMUL	A,T1
	IDIV	A,T1


COMPX:	PUSH	P,A
	PUSHJ	P,INDEX		;GET DEST. ADDRESS IN T6, BUMP TT
	PUSH	P,T6		;SAVE DEST ADDRESS
	AOJ	TT,		;BUMP TO LOC AFTER JUMP
	PUSHJ	P,INDEX		;PUT JUMP ADDRESS IN T6
	MOVE	T1,(TT)		;GET 1ST NON-INDEX AFTER JUMP
	CAMN	T1,[JFCL]	;JUST A MOVE?
	JRST	CMOVX		;MAY NOT BE NUMERIC THEN.
	MOVE	T2,T6		;MOVE ADDRESS FOR GETNUM
	PUSHJ	P,GETNUM+1	;GET SOURCE NUMBER IN T1
	MOVE	A,T1		;SAVE RUNNING TOTAL
COMPX1:	AOJ	TT,		;POINT TO 1ST OPERATOR INDEX OR 2ND OPERATOR
	PUSHJ	P,INDEX		;GET 1ST OPERATOR ADDRESS & POINT TO 2ND OPERATOR
	MOVE	T2,T6		;MOVE SOURCE ADDRESS
	PUSHJ	P,GETNUM+1	;GET NUMBER IN T1
	HLLZ	T3,T6		;GET OPCODE FOR ADDRESS
	MOVSI	T4,-CTABL	;SO NO INF. LOOP
	CAME	T3,CTAB(T4)	;SPOT OPCODE?
	AOBJN	T4,.-1		;NO-TRY AGAIN
	XCT	CTAB1(T4)	;EXECUTE THE OPERATION
	MOVE	T1,(TT)		;GET NEXT OPERATOR
	CAMN	T1,[JFCL]	;END OF COMPUTE?
	JRST	ECOMPX		;YES, PUT TOTAL IN DEST.
	AOJA	TT,COMPX1	;DOIT AGAIN

INDEX:	MOVE	T6,-1(TT)	;GET OPCODE + ADDRESS
	HLLZ	T1,(TT)		;GET POSSABLE INDEX
	CAME	T1,[INDEX.]	;WAS IT??
	CAMN	T1,[INDEX. 1,]	;OR NUMERIC?
	SKIPA			;YUP
	POPJ	P,		;NO--T6 CONTAINS ALL WE NEED
	HRRZ	T2,(TT)		;GET INDEX ADDRESS
	PUSHJ	P,GETNUM+1	;GET INDEX VALUE
	HLLZ	T2,(TT)		;GET OPCODE
	TLNN	T2,40		;NUMERIC?
	IMULI	T1,TAGSIZ	;NO-INDEX VALUE * WORDS/STORAGE LOC
	TLNE	T2,40		;TEST AGAIN
	IMULI	T1,2		;NUMERIC = 2 WORDS/LOC
	ADD	T6,T1		;+ START LOC = INDEXED ADDRESS
	AOJ	TT,		;POINT TO ADDRESS AFTER INDEX.
	POPJ	P,		;RETURN

ECOMPX:	POP	P,T4		;GET DEST. ADDRESS
	MOVE	T1,A		;MOVE TOTAL FOR PUTNUM
	PUSHJ	P,PUTNUM+1	;DEPOSIT ANSWER IN ASCII
	POP	P,A		;RESTORE REGISTER
	JRST	(TT)		;RETURN

CMOVX:	POP	P,T1		;DEST ADDRESS = (T1)
				;SOURCE ADDRESS = (T6)
	POP	P,A		;RESTORE YES/NO
	MOVE	T2,[POINT 7,(T1)];DEST POINTER
	MOVE	T3,[POINT 7,(T6)];SOURCE POINTER
	ILDB	T4,T3		;GET CHAR
	JUMPE	T4,.+3		;DONE
	IDPB	T4,T2		;PUT CHAR
	JRST	.-3		;LOOP
	IDPB	T4,T2		;TRAILING NULL
	TLNE	T2,760000	;END OF DEST WORD?
	JRST	.-2		;NO-ONCE MORE
	JRST	1(TT)		;YES-ALL DONE
STRNG:	MOVE	T1,.JBUUO	;GET ADDRESS OF DEST TAG
	MOVE	T2,[POINT 7,(T1)]
	HLLZ	T3,(TT)		;GET NEXT OPCODE
	CAME	T3,[JUMP]	;ARG?
	JRST	STREND		;STRING END
	HRRZ	T3,(TT)		;GET ADDRESS
	MOVE	T4,[POINT 7,(T3)]
	ILDB	T5,T4		;GET BYTE
	JUMPE	T5,.+3		;END OF INPUT
	IDPB	T5,T2		;STUFF BYTE
	JRST	.-3		;LOOP
	AOJA	TT,STRNG+2	;NEXT OPCODE

	SETZ	T5,		;FOR UNSTR
STREND:	IDPB	T5,T2		;DEPOSIT NULL
	TLNE	T2,760000	;END OF WORD?
	JRST	STREND		;NO
	JRST	(TT)		;RETURN

UNSTR:	MOVE	T1,.JBUUO	;GET DEST ADDRESS
	MOVE	T2,[POINT 7,(T1)]
	MOVE	T3,(TT)		;GET SOURCE
	MOVE	T4,[POINT 7,(T3)]
	ILDB	T5,T4
	JUMPE	T5,UNSTR1
	CAIE	T5,40		;IF SPACE
	CAIN	T5,11		;OR TAB
	JRST	UNSTR1-1	;DONE
	IDPB	T5,T2		;STORE BYTE
	JRST	.-6		;LOOP

	SETZ	T5,
UNSTR1:	IDPB	T5,T2
	TLNE	T2,760000
	JRST	UNSTR1
	MOVE	T2,[POINT 7,(T3)]	;RESET BYTE POINTER
	ILDB	T5,T4		;GET NEXT BYTE
	JUMPE	T5,STREND
	IDPB	T5,T2		;SHUFFLE REST TO THE LEFT
	JRST	.-3

GETSIZ:	MOVE	T4,(TT)
	MOVE	T2,[POINT 7,(T4)]
	SETZ	T1,
	ILDB	T3,T2		;GET BYTE
	JUMPE	T3,.+2		;DONE
	AOJA	T1,.-2		;LOOP
	PUSHJ	P,PUTNUM	;SAVE NUMBER OF CHARACTERS
	JRST	(TT)		;RETURN
OPENIN:	LDB	T6,[POINT 4,.JBUUO,12]	;GET CHANNEL ASSIGNMENT
	MOVEI	T5,IN
	PUSHJ	P,GETDSK	;GET A DISK
	PUSHJ	P,GETNAM	;GET THE FILENAME
	MOVE	T5,[LOOKUP T1]
	DPB	T6,[POINT 4,T5,12]	;PUT IN CHANNEL
	XCT	T5		;EXECUTE LOOKUP
	  JRST	NOFILE		;NO FILE
	JRST	(TT)		;RETURN

OPNOUT:	LDB	T6,[POINT 4,.JBUUO,12]
	MOVEI	T5,OUT
	PUSHJ	P,GETDSK	;GET A DISK
	PUSHJ	P,GETNAME	;GET THE FILENAME
	MOVE	T5,[ENTER T1]
	DPB	T6,[POINT 4,T5,12]	;PUT IN CHANNEL
	XCT	T5		;EXECUTE ENTER
	  JRST	ENTERR
	JRST	(TT)

GETDSK:	MOVE	T4,[OPEN T1]	;GET UUO
	MOVE	T1,[RELEASE]
	SKIPN	T6		;IF CHANNEL 0
	MOVE	T6,T5		;USE DEFAULT CHANNEL
	DPB	T6,[POINT 4,T4,12]	;STICK CHANNEL #
	DPB	T6,[POINT 4,T1,12]
	XCT	T1		;RELEASE THE CHANNEL
	MOVE	T3,T6		;GET CHANNEL
	IMULI	T3,3		;TIMES BUFFER LENGTH
	ADD	T3,CHAN		;PLUS BUFFER START ADDRESS
	TRNN	T5,IN		;IF INPUT SKIP
	MOVSS	T3		;IF OUTPUT, SWAP HALVES
	SETZ	T1,
	MOVSI	T2,'DSK'
	XCT	T4		;OPEN THE DSK
	JRST	OPNERR		;FAILURE
	POPJ	P,		;RETURN


GETNAM:	MOVE	T4,.JBUUO
	PUSH	P,T6		;SAVE T6
	MOVE	T3,[POINT 7,(T4)]
	MOVE	T5,[POINT 6,T1]
	SETZB	T1,T2
GETN0:	ILDB	T6,T3
	JUMPE	T6,GTNXIT
	CAIN	T6,"."
	JRST	GETN2
	CAIL	T6,140
	SUBI	T6,40
	SUBI	T6,40
	TLNE	T5,770000
	IDPB	T6,T5
	JRST	GETN0

GETN2:	MOVE	T5,[POINT 6,T2]
	JRST	GETN0

GTNXIT:	SETZB	T3,T4
	POP	P,T6		;RESTORE T6
	POPJ	P,

NODSK:	OUTSTR	[ASCIZ/? CANNOT OPEN DISK
/]
	EXIT

NOFILE:	OUTSTR	[ASCIZ/? CANNOT FIND FILE /]
	MOVE	T3,[POINT 6,T1]
	ILDB	T4,T3
	JUMPE	T4,NOFIL1
	ADDI	T4,40
	OUTCHR	T4
	TLNE	T3,770000
	JRST	NOFILE+2

NOFIL1:	JUMPE	T2,NOFIL2
	OUTCHR	["."]
	ILDB	T4,T3
	JUMPE	T4,.-1
	ADDI	T4,40
	OUTCHR	T4
	ILDB	T4,T3
	JUMPN	T4,.-3

NOFIL2:	OUTSTR	[ASCIZ/
/]
	EXIT

OPNERR:	OUTSTR	[ASCIZ/? CANNOT OPEN DSK
/]
	EXIT

ENTERR:	[ASCIZ/? ERROR ON OUTPUT FILE ENTER
/]
	EXIT

NOCHAN:	OUTSTR	[ASCIZ\? ALL I/O CHANNELS USED
\]
	EXIT
GETIT:	MOVE	T1,.JBUUO
	SETO	A,		;ASSUME WE'RE GOING TO MAKE IT
	MOVEI	T5,<TAGSIZ*5>-1	;THATS ALL WE CAN FIT
	MOVE	T2,[POINT 7,(T1)]	;DEST. POINTER
	PUSHJ	P,INCH		;GET CHAR
	CAIN	T4,15		;EOR?
	JRST	GET1
	IDPB	T4,T2		;STUFF IT
	SKIPL	T4		;WIERD FROM EOF?
	SOJG	T5,.-5		;NO, COUNT & LOOP
GET1:	SETZ	T4,
	IDPB	T4,T2		;CAP WITH NULLS
	TLNE	T2,760000	;END OF WORD?
	JRST	.-2		;SOME MORE
	SKIPLE	T5		;HIT <CR>?
	PUSHJ	P,INCH		;WASTE <LF>
	HLLZ	T1,(TT)		;GET NEXT LOC
	CAME	T1,[JUMP]	;ARG?
	JRST	(TT)		;NO, DONE
	MOVE	T1,(TT)		;GET ADDRESS
	AOJ	TT,		;BUMP POINTER
	JRST	GETIT+2		;& LOOP

INCH:	SKIPN	A		;IF ALREADY EOF,
	POPJ	P,		;RETURN
	LDB	T3,[POINT 4,.JBUUO,12]	;GET CHANNEL #
	SKIPN	T3
	MOVEI	T3,IN
	MOVE	T6,[IN]
	DPB	T3,[POINT 4,T6,12]	;MAKE IN UUO IN CASE
	IMULI	T3,3
	ADD	T3,CHAN
	SOSGE	2(T3)		;TEST IBUF+2
	JRST	.+3		;EMPTY
	ILDB	T4,1(T3)	;GET BYTE
	POPJ	P,		;RETURN
	XCT	T6		;IN
	JRST	.-5
	SETZ	A,		;EOF - ZERO YES/NO FLAG
	SETO	T4,		;FLAG CHAR. (NULL WOULDN'T WORK)
	POPJ	P,		;RETURN
PUTIT:	MOVE	T1,.JBUUO
	MOVE	T2,[POINT 7,(T1)]
	ILDB	T4,T2		;GET CHAR.
	JUMPE	T4,.+3		;NULL, END
	PUSHJ	P,OUCH		;SUFF CHAR.
	JRST	.-3		;LOOP
	MOVEI	T4,15
	PUSHJ	P,OUCH		;<CR>
	MOVEI	T4,12
	PUSHJ	P,OUCH		;<LF>
	HLLZ	T1,(TT)		;NEXT
	CAME	T1,[JUMP]	;OK?
	JRST	(TT)		;NG
	MOVE	T1,(TT)		;GET NEXT ADDR.
	AOJ	TT,		;& BUMP
	JRST	PUTIT+1

OUCH:	LDB	T3,[POINT 4,.JBUUO,12]	;GET CHANNEL #
	SKIPN	T3
	MOVEI	T3,OUT
	MOVE	T6,[OUTPUT]
	DPB	T3,[POINT 4,T6,12]
	IMULI	T3,3
	ADD	T3,CHAN
	SOSGE	2(T3)
	JRST	.+3
	IDPB	T4,1(T3)
	POPJ	P,
	XCT	T6
	JRST	OUCH
UUOTAB:	COMP.	COMPX
	ACCPT.	YESNO
	MATCH.	MATCH
	MATX.	EMATCH
	NMAT.	EMATCH
	MATG.	GMATCH
	NMATG.	GMATCH
	MATL.	LMATCH
	NMATL.	LMATCH
	EXIT.	DOEXIT
	ACCPT.	1,ACPT1
	ACCPT.	2,ACPT2
	ACCPT.	3,FULINE
	CALL.	CALLIT
	LOG.	LOGOUT
	QUIT.	QUITIT
	JERK.	RUNOFF
	GETC.	GETIME
	GETR.	GETRND
	GETD.	GETDAY
	GETT.	GETDT
	GETL.	GETSIZ
	STRN.	STRNG
	UNSTR.	UNSTR
	OUT.	17,OPNOUT
	IN.	17,OPENIN
	GET.	17,GETIT
	PUT.	17,PUTIT
	TRAP.	TRAPIT
	CJUMP.	COMJMP
	CPUSH.	COMPSH

	UUOTLN==.-UUOTAB


UUOERR:	OUTSTR	[ASCIZ/NON-PILOT UUO
/]
	EXIT

	END	INIT.