Google
 

Trailing-Edge - PDP-10 Archives - custsupcuspmar86_bb-x130b-sb - syschk.mac
There are 6 other files named syschk.mac in the archive. Click here to see a list.
TITLE SYSCHK DECSYSTEM-10 LOADTIME DIAGNOSTICS - V050
SUBTTL SYSCHK.MAC - J.E. STUBBLEBINE  10 SEP 85
	SEARCH	F,S
	$RELOC
	$LOW



;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
.CPYRT<1973,1986>
;COPYRIGHT (C) 1973,1974,1975,1976,1977,1978,1979,1980,1982,1984,1986
;BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;ALL RIGHTS RESERVED.


;
;
XP VSYSCK,050



;MAINTAINER: PDP-10 DIAGNOSTIC GROUP
;AUTHOR: .E. STUBBLEBINE


;LOADTIME DIAGNOSTICS CHECKS FOR THE ACCESSABILITY OF SYSTEM
;PERIPHERALS. CONTROL IS RECEIVED VIA A JSR SYSCHK. THE
;MONITOR "INTTAB" TABLE IS THEN SCANNED IN A MANNER SIMILAR
;TO THE METHOD USED IN "ONCE" TO DETERMINE THE SYSTEM DEVICES.
;THEN A PI ASSIGNMENT OF FOUR IS MADE TO EACH DEVICE AND VERIFIED.
;THE OPERATOR IS INFORMED OF ANY FAILING DEVICES.THIS
;PROGRAM IS DESIGNED TO SCAN FOR STANDARD DEVICES ONLY.



;SUBROUTINE PARAMETERS


EXCASB=1
KA10=1
KI10=1
PRINT=1
TYPIN=1
TOGGLE=1
MEMMAP=1
PGMEND=1
PSHLST=40
DEBUG=100
SIXOUT=1
INHPAG=0


SUBTTL	PERTINENT PROGRAM/SUBROUTINE PARAMETERS, X00R, DECEMBER 6, 1971
;OPERATOR DEFINITIONS, SUBROUTINE CALLS - SHORT COMMAND FORM
OPDEF	PGMINT	[JSP	0,$PGMIN]	;PROGRAM SUBROUTINE INITIALIZATION
OPDEF	ERRHLT	[JSR	$ERHLT]		;PROGRAM ERROR HALT
	IFDEF	PSHLST,<
OPDEF	GO	[PUSHJ	%P,]		;SUBROUTINE CALL
OPDEF	RTN	[POPJ	%P,]		;SUBROUTINE RETURN
	DEFINE	MOVMEM	(FROM,TO)<
	PUSH	P,FROM
	POP	P,TO	>>
	IFDEF	TOGGLE,<
OPDEF	SWITCH	[JSP	0,$SWTCH]	;INPUT CONSOLE SWITCHES>
	IFDEF	TYPIN,<
OPDEF	TTICHR	[JSP	0,$OPTLK]	;TTY, INPUT ANY CHARACTER
OPDEF	TTIYES	[JSP	0,$YESNO]	;TTY, NORMAL RETURN Y
OPDEF	TTINO	[JSP	0,$NOYES]	;TTY, NORMAL RETURN N
OPDEF	TTIOCT	[JSP	0,$TPOCT]	;TTY, INPUT OCTAL WORD
OPDEF	TTIDEC	[JSP	0,$TPDEC]	;TTY, INPUT DECIMAL WORD
OPDEF	TTICNV	[JSP	0,$TPCNV]	;TTY, INPUT CONVERTABLE WORD
OPDEF	TTLOOK	[JSP	0,$TTLK]	;TTY, KEYBOARD CHECK
OPDEF	TTALTM	[JSP	0,$TALTM]	;TTY, ALT-MODE CHECK>
	IFDEF	PRINT,<
OPDEF	PNTA	[JSR	0,$PRINT]	;PRINT ASCII WORD
OPDEF	PNTAF	[JSR	0,$PRNTF]	;FORCED
OPDEF	PNTAL	[JSR	17,$PRINT]	;PRINT ASCIZ LINE
OPDEF	PNTALF	[JSR	17,$PRNTF]
OPDEF	PNT1	[JSR	1,$PRINT]	;PRINT ONE OCTAL DIGIT
OPDEF	PNT1F	[JSR	1,$PRNTF]
OPDEF	PNT2	[JSR	2,$PRINT]	;PRINT TWO OCTAL DIGITS
OPDEF	PNT2F	[JSR	2,$PRNTF]
OPDEF	PNT3	[JSR	3,$PRINT]	;PRINT THREE OCTAL DIGITS
OPDEF	PNT3F	[JSR	3,$PRNTF]
OPDEF	PNT6	[JSR	6,$PRINT]	;PRINT SIX OCTAL DIGITS
OPDEF	PNT6F	[JSR	6,$PRNTF]
OPDEF	PNT10	[JSR	10,$PRINT]	;PRINT TEN OCTAL DIGITS
OPDEF	PNT10F	[JSR	10,$PRNTF]
OPDEF	PNTOCT	[JSR	14,$PRINT]	;PRINT FULL WORD OCTAL
OPDEF	PNTOTF	[JSR	14,$PRNTF]
OPDEF	PNTHW	[JSR	13,$PRINT]	;PRINT OCTAL HALF WORDS, 6 SP 6
OPDEF	PNTHWF	[JSR	13,$PRNTF]
OPDEF	PNTDEC	[JSR	15,$PRINT]	;PRINT DECIMAL, SUPRESS LEADING 0'S
OPDEF	PNTDCF	[JSR	15,$PRNTF]
OPDEF	PNTDS	[JSR	16,$PRINT]	;PRINT DECIMAL, SPACES FOR LD 0'S
OPDEF	PNTDSF	[JSR	16,$PRNTF]
	IFDEF	USRASB,<
OPDEF	DROPDV	[JSP	0,$DRPDV]	;CLOSE LOGICAL FILE, USER MODE>>
	IFDEF	SIXIN,<
OPDEF	TTSIXB	[GO	$TSIXB]		;TTY, INPUT SIXBIT WORD>
	IFDEF	SIXOUT,<
OPDEF	PNTSIX	[GO	$PNTSX]		;PRINT SIXBIT WORD
OPDEF	PNTSXF	[GO	$PTSXF]		;FORCED >
;STANDARD PROGRAM ASSIGNMENTS

;DATA SWITCHES

CYCL50==400000		;50 CYCLE POWER
RSTART==200000		;RESTART TEST, PRINT TOTALS
TOTALS==100000		;PRINT TOTALS, CONTINUE

NOPNT==	040000		;INHIBIT ALL PRINT/TYPE OUT (EXCEPT FORCED)
PNTLPT==020000		;PRINT ALL DATA ON LPT (LOGICAL DEVICE, USER MODE)
DING==	010000		;RING BELL ON ERROR

LOOPER==004000		;ENTER EXERCISE/CHECK LOOP ON ERROR
ERSTOP==002000		;HALT ON TEST ERROR
PALERS==001000		;PRINT ALL ERRORS

FSTCYL==000400		;FAST CYCLE
TXTINH==000200		;INHIBIT ERROR TEXT

;ACCUMULATORS

	IFDEF	PSHLST,<
%P=	17		;PUSHDOWN POINTER AC (IF PUSH LIST USED)>

;PDP-10 STANDARD PC CONTROL FLAGS

AROV==	400000			;ARITHMETIC OVERFLOW
CRY0==	200000			;CARRY 0
CRY1==	100000			;CARRY 1
FOV==	40000			;FLOATING POINT OVERFLOW
BIS==	20000			;BYTE INTERRUPT
USERF==	10000			;USER MODE
EXIOT==	4000			;USER PRIV I/O
FXU==	100			;FLOATING POINT UNDERFLOW
DCK==	40			;DIVIDE CHECK

;PDP-10 STANDARD ADDRESS ASSIGNMENTS

LUUO==	40			;UUO STORAGE, UUO 1-37
LUUOI==	41			;UUO SERVICE INSTRUCTION
;JOB DATA AREA EXTERNALS

JBESYM=36
JOBUUO=40
JOB41=41
JOBREL=44
JOBDDT=74
JOBSYM=116
JOBSA=120
JOBFF=121
JOBREN=124
JOBAPR=125
JOBCNI=126
JOBTPC=127
JOBOPC=130
JOBVER=137

;USER APR ASSIGNMENTS

PDLOVU==200000		;PUSHDOWN LIST OVERFLOW
MPVU==	20000		;MEMORY PROTECTION VIOLATION
NXMU==	10000		;NON-X-MEMORY
CLKU==	1000		;CLOCK
FOVU==	100		;FLOATING OVERFLOW
AROVU==	10		;ARITHMETIC OVERFLOW

;USER MODE PRINT OUTPUT CHANNEL ASSIGNMENTS

$TTYCH==17		;TELETYPE CHANNEL
$DEVCH==16		;LOGICAL DEVICE CHANNEL
$DVCH1==15		;LOGICAL DEV UPDATE INPUT CHANNEL

	XLIST
	IFDEF	EXCASB,<LIST
;PDP-10 STANDARD APR CONO ASSIGNMENTS

IOCLR==	200000			;CLEAR ALL I/O DEVICES
CLKDIS==4000			;DISABLE CLOCK INTERRUPTS
CLKENB==2000			;ENABLE CLOCK INTERRUPTS
CLKCLR==1000			;CLEAR CLOCK FLAG

;PDP-10 STANDARD APR CONI ASSIGNMENTS, RIGHT HALF

CLKENB==2000			;CLOCK INTERRUPT ENABLED
CLK==	1000			;CLOCK FLAG

;PDP-10 STANDARD PI CONO ASSIGNMENTS

PWFCLR==400000			;CLEAR POWER FAIL FLAG
PARCLR==200000			;CLEAR PARITY ERROR FLAG
PARDIS==100000			;DISABLE PARITY INTERRUPTS
PARENB==40000			;ENABLE PARITY INTERRUPTS
PICLR==	10000			;CLEAR PI SYSTEM
REQSET==4000			;SET PROGRAM PI REQUEST
CHNON==	2000			;TURN ON CHANNEL
CHNOFF==1000			;TURN OFF CHANNEL
PIOFF=	400			;TURN OFF PI SYSTEM
PION==	200			;TURN ON PI SYSTEM

;PDP-10 STANDARD PI CONI ASSIGNMENTS

PION==	200			;PI SYSTEM ON

;PDP-10 STANDARD PI CHANNEL ASSIGNMENTS

PICHN1==100			;PI CHANNEL 1
PICHN2==40			;PI CHANNEL 2
PICHN3==20			;PI CHANNEL 3
PICHN4==10			;PI CHANNEL 4
PICHN5==4			;PI CHANNEL 5
PICHN6==2			;PI CHANNEL 6
PICHN7==1			;PI CHANNEL 7
PICHNA==177			;ALL PI CHANNELS, 1 THRU 7

;PDP-10 SPECIAL COMPATABILITY ASSIGNMENTS

PAG==	010			;PAGING I/O DEVICE CODE - KI10

	XLIST
	IFDEF	KA10,<LIST
;KA10 APR CHANNEL ASSIGNMENTS

AAPRC1==1			;APR INTERRUPT CHANNEL

;KA10 APR CONO ASSIGNMENTS

APDCLR==400000			;CLEAR PUSHDOWN OVERFLOW
AABCLR==40000			;CLEAR ADDRESS BREAK
AMPCLR==20000			;CLEAR MEMORY PROTECTION
ANXCLR==10000			;CLEAR NON-X-MEMORY
AFODIS==400			;DISABLE FLOATING POINT OVERFLOW
AFOENB==200			;ENABLE FLOATING POINT OVERFLOW
AFOCLR==100			;CLEAR FLOATING POINT OVERFLOW
AOVDIS==40			;DISABLE OVERFLOW
AOVENB==20			;ENABLE OVERFLOW
AOVCLR==10			;CLEAR OVERFLOW

;KA10 APR CONI ASSIGNMENTS

APDLOV==200000			;PUSHDOWN OVERFLOW
AUSRIO==100000			;USER I/O
AADRBK==40000			;ADDRESS BREAK
AMPV==	20000			;MEMORY PROTECTION VIOLATION
ANXM==	10000			;NON-EXISTENT MEMORY
AFOENB==200			;FLT PT INTERRUPT ENABLED
AFOV==	100			;FLOATING POINT OVERFLOW
ATRPOS==40			;TRAPS OFFSET
AOVENB==20			;OVERFLOW INTERRUPT ENABLED
AOVFLO==10			;ARITHMETIC OVERFLOW

;KA10 PI CONI ASSIGNMENTS

APWRFL==400000			;POWER FAILURE
APARER==200000			;PARITY ERROR
APAREN==100000			;PARITY INTERRUPT ENABLED
>

	XLIST
	IFDEF	KI10,<LIST
;KI10 PC CONTROL FLAGS

LIP==	2000			;LAST INSTRUCTION PUBLIC
TN0==	400			;TN=00, NO TRAP ;TN=01, ARITH TRAP
TN1==	200			;TN=10, PDL OV  ;TN=11, TRAP 3

;KI10 SPECIAL EXEC MODE FLAGS

UOLIP==400000			;UUO OLD L.I.P.
UOUSR==4000			;UUO OLD USER

;KI10 APR CHANNEL ASSIGNMENTS

IAPRC1==1			;APR CLOCK CHANNEL
IAPRE1==10			;APR ERROR CHANNEL

;KI10 APR CONO ASSIGNMENTS

ITMSET==400000			;SET TIME OUT TIMER
ITMDIS==100000			;DISABLE TIME OUT
ITMENB==40000			;ENABLE TIME OUT
IASRTC==20000			;CLEAR AUTO RESTART
IASRTS==10000			;SET AUTO RESTART
IIOPFC==200			;CLEAR I/O PAGE FAIL
INXCLR==100			;CLEAR NON-X-MEM

;KI10 APR CONI ASSIGNMENTS, RIGHT HALF

ITMOUT==400000			;TIMER TIMED OUT
IPARER==200000			;PARITY ERROR
IPAREN==100000			;PARITY ENABLED
ITMOEN==40000			;TIME OUT ENABLED
IPWRFL==20000			;POWER FAIL
IASRTE==10000			;AUTO RESTART ENABLED
IIOPFL==200			;I/O PAGE FAIL
INXM==	100			;NON-X-MEMORY
;KI10 APR CONI ASSIGMENTS, LEFT HALF

IMLAPD==200000			;MEMORY OVERLAP DISABLED
IFMMAN==100000			;FAST MEMORY MANUAL
IMIPGD==40000			;MI PROGRAM DISABLE
ICNSLR==20000			;CONSOLE READ ONLY
ICNSLL==10000			;CONSOLE LOCKED
IP50HZ==4000			;50 HZ POWER
IMGINM==2000			;MANUAL MARGINS
IMAINT==1000			;MAINTENANCE MODE
IPWRLO==400			;POWER LOW
IMGNLO==200			;MARGIN COMPARATOR LOW
SENSE1==40			;SENSE SWITCHES		1
SENSE2==20			;			2
SENSE3==10			;			3
SENSE4==4			;			4
SENSE5==2			;			5
SENSE6==1			;			6

;KI10 APR DATAO ASSIGNMENTS

IEVNPR==20000			;WRITE EVEN PARITY
ISPDOF==10000			;SPEED MARGINS OFF
ISPDON==4000			;SPEED MARGINS ON
IMGNOF==2000			;MARGINS OFF - LH
IMGNON==1000			;MARGINS ON - LH

;KI10 PI CONO ASSIGNMENTS

IRQCLR==20000			;CLEAR PROGRAM PI REQUEST
;KI10 PI CONI ASSIGNMENTS

IINSTF==400000			;ADDRESS CONDITIONS, INST FETCH
IDATAF==200000			;	    	     DATA FETCH
IWRITE==100000			;		     WRITE
IADSTP==40000			;ADDRESS STOP
IADBRK==20000			;ADDRESS BREAK
IADEXC==10000			;ADDRESS SWITCHES EXEC
IADUSR==4000			;  "	  "       USER
IPRSTP==2000			;PARITY STOP
INXSTP==1000			;NON-X-MEM STOP

;KI10 PAG CONI ASSIGNMENTS

EXCMEM==400			;EXEC MEMORY SPACE
AMCLRB==40			;ASSOCIATIVE MEMORY CLEAR BIT

;KI10 PAG DATAO ASSIGNMENTS, LEFT HALF

LDUSRB==400000			;LOAD USER BASE REGISTER
SMLUSR==40000			;SMALL USER, 32K OR UNDER
USRCMP==20000			;USER ADR COMPARE ENABLE

;KI10 PAG DATAO ASSIGNMENTS, RIGHT HALF

LDEXCB==400000			;LOAD EXEC BASE REGISTER
TRPENB==20000			;ENABLE TRAPS

;KI10 PAG DATAI ASSIGNMENTS

SMLUSR==40000			;SMALL USER
USRCMP==20000			;USER ADR COMPARE ENABLED
TRPENB==20000			;RH, TRAPS ENABLED

;KI10 PTR DATAO ASSIGNMENTS

	;ADDRESS CONITIONS, ADDRESS BREAK ;AS ABOVE, PI CONI
	;ADDRESS SWITCHES, 14-35
;KI10 EXEC PAGE MAP PAGE ASSIGNMENTS

PGFTRP==420			;PAGE FAULT TRAP
AROVTP==421			;ARITHMETIC TRAP
PDOVTP==422			;PUSHDOWN OVERFLOW TRAP
TRP3TP==423			;TRAP 3 TRAP

;KI10 USER PAGE MAP PAGE ASSIGNMENTS

PGFTRP==420			;PAGE FAULT TRAP
AROVTP==421			;ARITHMETIC TRAP
PDOVTP==422			;PUSHDOWN OVERFLOW TRAP
TRP3TP==423			;TRAP 3 TRAP

MUUO==	424			;MUUO STORAGE
MUUOPC==425			;C(PC) OF MUUO STORAGE

EXCPFW==426			;EXEC PAGE FAIL WORD
USRPFW==427			;USER PAGE FAIL WORD

KNTRP==	430			;KERNAL	 	NO TRAP - NEW PC'S-
KTRP==	431			;"	 	TRAP
SNTRP==	432			;SUPERVISOR	NO TRAP
STRP==	433			;"		TRAP
CNTRP==	434			;CONCEAL 	NO TRAP
CTRP==	435			;"		TRAP
PNTRP==	436			;PUBLIC		NO TRAP
PTRP==	437			;"		TRAP

>>
	LIST
;KL10 DEFINITIONS

LNXM==2000			;NXM FLAG
LNXCLR==22000			;CLEAR NXM FLAG

LTRPEN==1B22			;TRAP ENABLE

PFNPCW==502			;PAGE FAIL NEW PC WORD

;DTE LOCATIONS AND COMMANDS

DTE==200			;DTE DEVICE CODE
DTEEPW==144			;EXAMINE PROTECTION WORD
DTEFLG==444			;SET BY FE WHEN COMMAND IS COMPLETE
DTEF11==450			;FROM 11 ARGUMENT
DTECMD==451			;COMMAND LOCATION
DTEMTD==455			;MONITOR OUTPUT COMPLETE FLAG (SET BY 11)
DTEMTI==456			;MONITOR INPUT READY FLAG (SET BY 11)

.DTMTO==10B27			;COMMAND TO DO MONITOR OUTPUT
.DTMMC==11B27			;COMMAND TO TURN ON MONITOR MODE CONSOLE

;DTE HARDWARE BITS

TO11DB==1B22			;TO 11 DOORBELL
PILDEN==1B31			;ENABLE LOAD PI
;KS10 DEFINITIONS

SNXM==400			;NXM FLAG
SNXCLR==20400			;CLEAR NXM FLAG

CTYIWD==32			;CTY INPUT WORD
CTYOWD==33			;CTY OUTPUT WORD
	SUBTTL	PROGRAM INTIALIZATION

MONFLG:	-1
MONCTL:	0
%AC0=0
%AC1=1
%AC2=2
%AC3=3
%AC4=4
%AC5=5
%AC6=6
%AC7=7
%AC10=10
%AC11=11
%AC12=12
%AC13=13
%AC14=14

ENTRY	SYSCHK

BEGIN=.
SYSCHK:	0
	MOVEI	T1,%EXIT-1	;SET UP EXIT POINT
	MOVEM	T1,RETCAL#
	MOVE	T1,.CPCPN##
	MOVEM	T1,OURCPU#

	SETZM	REPT#
	SETZM	SCOPE#
	SETOM	LASTPC#
	PGMINT			;INITIALIZE SUBROUTINES
	MOVE	%AC1,[200,,MONSV]
	BLT	%AC1,MONSV+537	;SAVE MONITOR TO SETUP EXEC PAGING
	JSP	$MEMMP
	JRST	%LTD02		;SCAN THE DDB'S
PGMNAM:	ASCIZ/
LOADTIME DIAGNOSTICS/

;EXIT ROUTINE
%EXIT:	MOVE	%AC1,[MONSV,,200]
	BLT	%AC1,200+537	;RESTORE MONITOR
	CONO	APR,200000	;CLEAR PI ASSIGNMENTS SO MONITOR WON'T LOOP
	MOVEI	%AC1,LDEXCB
	IOR	%AC1,SAVPG1#
	SKIPGE	KAILFL
	DATAO	PAG,%AC1
	SKIPG	KAILFL
	JRST	2,@SYSCHK
	CONO	PAG,@SAVPAG#
	DATAO	PAG,SAVPG1
	JRST	2,@SYSCHK

IFE FTKS10,<
%LTD02:	MOVSI	T1,INTNUM##
X0:	HRRZ	T2,INTTAB##(T1)	;PICK UP LOCATION OF THE SKIP CHAIN ENTRY
	JUMPE	T2,X8		;DON'T TEST FOR OFF-LINE IF THERE ISN'T ONE
	CAIL	T2,400000	;OR IF IT'S IN THE HISEG
	JRST	X8
	LDB	T3,PINTCP##
	CAME	T3,OURCPU
	JRST	X8
	LDB	T3,[POINT 6,INTTB1##(T1),8]
	CAIE	T3,LOCSTA##
	JUMPN	T3,X8
	MOVE	T3,(T2)
	HLRZ	T4,T3
	ANDI	T4,(CONSO)
	CAIE	T4,(CONSO)
	JRST	X8
	AND	T3,[77400,,0]
	MOVEI	T4,NXDEVS
	CAME	T3,XDEVTB-1(T4)
	SOJG	T4,.-1
	JUMPE	T4,X1
	HRRZ	T4,INTTB1##(T1)
	JUMPE	T4,X8
	TLZ	T3,400
X1:	LDB	T4,PINTCH##
	HRLI	T4,(CONO)
	IOR	T4,T3
	XCT	T4
	HRRI	T4,T4
	TLC	T4,(<CONI>^!<CONO>)
	XCT	T4
	TRNE	T4,7
	JRST	X8
	HRRZ	T2,INTTB1##(T1)
	JUMPN	T2,X3
	MOVEI	T2,NNDEVS
	CAME	T3,NDEVTB-1(T2)
	SOJG	T2,.-1
	JUMPN	T2,X2
	MOVEI	%AC0,[ASCIZ /%DEVICE WITH DEVICE CODE /]
	PNTAL
	MOVE	%AC0,T3
	LSH	%AC0,-30
	PNT3
	JRST	X7
X2:	MOVEI	J,1
	MOVEI	T2,NDEVT1-1(T2)
	JRST	X4
X3:	LDB	J,DDBNUM##
	JUMPN	J,X4
	CAIE	T2,DSKDDB##
	JRST	X4
	HRRZ	J,INTTAB##(T1)
	HRRZ	J,-KONINT##(J)
	HLLZ	T2,UNINAM##(J)
	JRST	X5
X4:	MOVE	T2,(T2)
	MOVEI	%AC0,[ASCIZ /%DEVICE /]
	CAIN	J,1
	JRST	X6
	HLLZS	T2
X5:	MOVEI	%AC0,[ASCIZ /%CONTROLLER /]
X6:	PNTAL
	MOVE	%AC0,T2
	PNTSXF
	MOVEI	%AC0,SPACE
	PNTAF
X7:	MOVEI	%AC0,[ASCIZ /IS INACCESSIBLE.
/]
	PNTALF
X8:	AOBJN	T1,.+1
	AOBJN	T1,X0
	JRST	%EXIT
XDEVTB:	<324>B11	;DTS
	<334>B11	;DTS FOR DTB
	<344>B11	;TMS
	<354>B11	;TMS FOR MTB
NXDEVS==.-XDEVTB

NDEVTB:	<0>B11		;APR
	<14>B11		;CCI
	<70>B11		;CLK
	<120>B11	;CTY
	<240>B11	;DLS0
	<244>B11	;DLS1
NNDEVS==.-NDEVTB

NDEVT1:	SIXBIT	/APR/
	SIXBIT	/CCI0/
	SIXBIT	/CLK0/
	SIXBIT	/CTY/
	SIXBIT	/DLS0/
	SIXBIT	/DLS1/
>;END IFE FTKS10
IFN FTKS10,<
%LTD02:	MOVEI	T1,TRPADR		;SET UP TRAP ADDRESS
	MOVEM	T1,PFNPCW		; FOR POSSIBLE NXM'S FROM DEVICES
	SETZ	T1,			;TABLE INDEX STARTS AT ZERO
X0:	RDIO	T2,@NDEVTB(T1)		;ACCESS A REGISTER FOR THIS DEVICE
X1:	CAIGE	T1,NNDEVS		;CHECKED ALL THINGS?
	AOJA	T1,X0			;NO--NEXT ONE
	JRST	%EXIT			;YES--ALL DONE

;HERE IF A UBA, RH11, OR UNIT RECORD DEVICE DOESN'T RESPOND

TRPADR:	SKIPG	NDEVT2(T1)		;ARE WE CONFIGURED FOR THIS DEVICE?
	 JRST	X1			;NO--THEN IT SHOULDN'T EXIST!
	MOVEI	%AC0,[ASCIZ /%DEVICE /]	;ASSUME DEVICE
	CAIG	T1,NCTRLR		;COULD IT BE A CONTROLLER?
	MOVEI	%AC0,[ASCIZ /%CONTROLLER /] ;YES--WANT THIS LINE
	CAIG	T1,NUBA			;IS IT A UBA?
	MOVEI	%AC0,[ASCIZ /%UNIBUS ADAPTOR #/] ;YES--WANT THIS LINE
	PNTAL				;PRINT STRING
	MOVE	%AC0,NDEVT1(T1)		;GET SIXBIT NAME
	PNTSXF				;PRINT IT
	MOVEI	%AC0,SPACE		;ASCII SPACE
	PNTAF				;PRINT IT
	MOVEI	%AC0,[ASCIZ /IS INACCESSIBLE
/]
	PNTALF				;PRINT STRING
	JRST	X1			;BACK TO CHECK LOOP

;TABLE OF I/O ADDRESSES FOR PERIPHERAL GEAR THAT IS CHECKED FOR
NDEVTB:	1,,UNBSTW			;UBA #1 STATUS REGISTER
	3,,UNBSTW			;UBA #3 STATUS REGISTER
NUBA==.-NDEVTB-1		;HIGHEST INDEX FOR UNIBUS ADAPTORS
	RH11CA				;RH11 ON UBA1
	RH21CA				;RH11 ON UBA3
	DZ11BA				;DZ11 #0
	DZ11BA+10			;DZ11 #1
	DZ11BA+20			;DZ11 #2
	DZ11BA+30			;DZ11 #3
	KMC1BA			;KMC11
	DUP1BA			;DUP11 #0
	DUP1BA+10		;DUP11 #1
ZZ==0
REPEAT	10,<
	DMR1BA+<ZZ*10>		;DMR11 N
ZZ==ZZ+1
>
NCTRLR==.-NDEVTB-1		;HIGHEST INDEX FOR CONTROLLERS
	LP11CA				;LP20
	CD11BA				;CD20
NNDEVS==.-NDEVTB-1		;HIGHEST INDEX FOR ALL HARDWARE CHECKED


;TABLE OF CORRESPONDING SIXBIT NAMES
NDEVT1:	SIXBIT	/1/
	SIXBIT	/3/
	SIXBIT	/RPA/
	SIXBIT	/MTA/
	SIXBIT	/DZ0/
	SIXBIT	/DZ1/
	SIXBIT	/DZ2/
	SIXBIT	/DZ3/
	SIXBIT	/KMC0/
	SIXBIT	/DUP0/
	SIXBIT	/DUP1/
	SIXBIT	/DMR0/
	SIXBIT	/DMR1/
	SIXBIT	/DMR2/
	SIXBIT	/DMR3/
	SIXBIT	/DMR4/
	SIXBIT	/DMR5/
	SIXBIT	/DMR6/
	SIXBIT	/DMR7/
	SIXBIT	/LPT/
	SIXBIT	/CDR/

;CORRESPONDING TABLE OF HARDWARE CONFIGURATION
;	POSITIVE ENTRY = IS IN SYSTEM
;	NEGATIVE OR ZERO = IS NOT IN SYSTEM
NDEVT2:	M.R11D##		;UBA1 (DISKS)
	M.TRH1##		;UBA3 (TAPES)
	M.R11D##		;RH11 FOR DISKS
	M.TRH1##		;RH11 FOR TAPES
	<M.DZNL##+7>/10		;FIRST DZ11
	<M.DZNL##+7>/20		;SECOND DZ11
	<M.DZNL##+7>/30		;THIRD DZ11
	<M.DZNL##+7>/40		;FOURTH DZ11
	M.KDUP##		;KMC11
	M.KDUP##		;FIRST DUP11
	M.KDUP##/2		;SECOND DUP11
ZZ==0
REPEAT 10,<
	M.DMRN##-ZZ
ZZ==ZZ+1>
	M.LPT##			;MONGEN SYMBOL FOR LPT
	M.CDR##			;MONGEN SYMBOL FOR CDR
>;END IFN FTKS10
SUBTTL PDP-10 DIAGNOSTIC ERROR HANDLER, X03F, JULY 1, 1971

;THE DIAGNOSTIC ERROR HANDLER IS A SUBROUTINE CAPABLE OF REPORTING
;A STANDARD BUT FLEXIBLE FORMAT OF TEST DATA AND DIAGNOSTIC
;INFORMATION.  THE ERROR HANDLER ALSO INTERPRETS AND CONTROLS TEST
;SWITCHES SUCH AS TYPEOUT SUPPRESSION, CONTINUE/HALT OR LOOP ON
;ERROR, AND BELL ON ERROR.

	INTERN	%ERCAL,SCOPE,REPT,LASTPC,PASCTR

%ERCAL:	0
	MOVEM	0,%AC0#
	MOVEM	1,%AC1#
	MOVEM	2,%AC2#
	MOVEM	3,%AC3#
	MOVEM	4,%AC4#
	AOS	ERRCNT#		;INCREMENT ERROR COUNT
	MOVEI	1		;DON'T REPEAT LOOP SECTION
	MOVEM	REPT
	HRRZ	3,%ERCAL	;GET <ADDRESS+1> OF ERROR CALL.
	SWITCH
	CAME	3,LASTPC#	;SKIP IF SAME ERROR
	JRST	.+3
	TLNN	PALERS		;PRINT ALL ERRORS ?
	JRST	%ERSW1		;THIS ERROR ALREADY REPORTED ONCE.

;BYPASS ERROR REPORT IF NOPNT SWITCH IS SET
	TLNE	0,NOPNT
	JRST	%ERSW1+1
	MOVEM	3,LASTPC
	SETZM	%ERCNT#
	SKIPGE	MONCTL		;DIAG MON OR SYS EXER ?
	JRST	%ERPRA		;YES, GO PRINT TITLE
%ERPRB:	SKIPN	PASCTR
	JRST	.+5		;DON'T PRINT PASS COUNTER ON FIRST PASS
	MOVEI	0,[ASCIZ/
TEST PASS COUNT = /]
	PNTAL
	MOVE	0,PASCTR#
	PNTDEC			;PRINT TEST PASS COUNTER
	MOVEI	0,[ASCIZ/
PC=  /]
	PNTAL
	MOVEI	0,-1(3)
	PNT6			;PRINT PC OF ERROR CALL.
	MOVE	0,CONSW
	TLNE	TXTINH		;TEXT INHIBITED ?
	JRST	%ERPR2		;YES
	MOVEI	0,[ASCIZ/
ERROR IN /]
	HLRZ	1,1(3)		;GET NAME OF FAILING TEST
	JUMPE	1,%ERPR1	;JUMP IF NO TEST NAME
	PNTAL
	MOVE	0,1
	PNTAL			;REPORT NAME OF FAILING TEST
	MOVEI	0,[ASCIZ/ - /]
	JRST	.+2
%ERPR1:	MOVEI	0,CRLF
	HRRZ	1,1(3)		;GET NAME OF FUNCTION TESTED
	JUMPE	1,%ERPR2	;JUMP IF NO FUNCTION CALLED OUT.
	PNTAL
	MOVE	0,1
	PNTAL			;REPORT FUNCTION BEING TESTED.

%ERPR2:	SETOM	%DISCR#		;SET 'DISCREPANCY FLAG'.

;GET X FROM JSR X,%ERCAL. PASS X ARGUMENT ONTO $PRINT.

	LDB	4,[POINT 4,-1(3),12]	;PICK UP X ARGUMENT
	MOVEI	2,14
	JUMPN	4,.+2		;PRINT 12 OCTAL DIGITS IF X=0
	MOVEM	2,4
	CAILE	4,14		;MAKE SURE THAT X IS A LEGAL ARGUMENT
	ERRHLT			;PROGRAM CALL ERROR
	LSH	4,^D<35-12>	;PUT X IN AC FIELD
	ADD	4,[JSR $PRINT]
	MOVEI	0,[ASCIZ/
CORRECT:  /]
	HLRZ	2,2(3)		;GET ADDRESS OF EXPECTED TEST RESULTS
	JUMPN	2,.+3
	SETZM	%DISCR		;NO 'CORRECT RESULT' TYPEOUT
	JRST	%ERPR3
	CAILE	2,4		;ARE TEST RESULTS IN AC THAT HAS BEEN SAVED?
	JRST	%ERP2A
	CAIN	2,1		;AC1?
	MOVE	1,%AC1
	CAIN	2,2		;AC2?
	MOVE	1,%AC2
	CAIN	2,3		;AC3?
	MOVE	1,%AC3
	CAIN	2,4		;AC4?
	MOVE	1,%AC4
	JRST	.+2
%ERP2A:	MOVE	1,(2)

;AC1 NOW CONTAINS THE CORRECT TEST RESULTS.
	PNTAL			;CORRECT RESULTS.
	MOVE	0,1
	MOVEM	4,.+1
	0			;JSR X,$PRINT. REPORT CORRECT DATA
	MOVEM	1,%COREC#	;SAVE CORRECT DATA
%ERPR3:	MOVEI	0,[ASCIZ/
ACTUAL:   /]
	HRRZ	2,2(3)		;GET ADDRESS OF ACTUAL TEST RESULTS.
	JUMPN	2,.+3
	SETZM	%DISCR		;NO 'ACTUAL RESULT' TYPEOUT.
	JRST	%ERPR4
	CAILE	2,4		;ARE ACTUAL TEST RESULTS IN AC THAT IS SAVED?
	JRST	%ERP3A
	CAIN	2,1		;AC1?
	MOVE	1,%AC1
	CAIN	2,2		;AC2?
	MOVE	1,%AC2
	CAIN	2,3		;AC3?
	MOVE	1,%AC3
	CAIN	2,4		;AC4?
	MOVE	1,%AC4
	JRST	.+2
%ERP3A:	MOVE	1,(2)

;AC1 CONTAINS THE ACTUAL TEST RESULTS.
	PNTAL			;ACTUAL RESULTS
	MOVE	0,1
	MOVEM	4,.+1
	0			;JSR X,$PRINT. REPORT ACTUAL DATA
	MOVEM	1,%ACTUL#	;SAVE ACTUAL DATA

%ERPR4:	MOVEI	0,[ASCIZ/
DISCREP:  /]
	SKIPN	%DISCR		;REPORT DATA DISCREPANCY IF BOTH CORRECT AND
	JRST	%ERPR5		;ACTUAL DATA REPORTED.
	MOVE	1,%COREC
	XOR	1,%ACTUL	;XOR CORRECT & ACTUAL DATA
	PNTAL
	MOVE	0,1
	MOVEM	4,.+1
	0			;JSR X,$PRINT. REPORT DISC BETWEEN COR. & ACT.
;PICK UP AND REPORT DIAGNOSTIC COMMENT IF ANY.
%ERPR5:	MOVE	0,CONSW
	TLNE	TXTINH		;TEXT INHIBITED ?
	JRST	%ERPR6		;YES
	HRRZ	1,3(3)		;GET ADDRESS OF ASCIZ TEXT.
	JUMPE	1,%ERPR6	;EXIT FROM ERROR PRINT IF NO DIAGNOSTIC TEXT.
	MOVEI	0,CRLF
	PNTAL
	MOVE	0,1
	PNTAL
%ERPR6:	MOVEI	CRLF
	PNTA

	JRST	.+1		;TO ADD ROUTINE, PLACE JRST HERE

;EXAMINE DATA SWITCHES (OR SOFTWARE SWITCHES IF USER MODE).

%ERSW1:	SWITCH			;READ DATA SWITCHES
	MOVEM	0,4
	TLNN	4,ERSTOP	;IS 'HALT ON ERROR' SWITCH SET, (SWITCH ERSTOP)
	JRST	%ERSW2		;NO

;EXECUTE HALT IF SWITCH ERSTOP SET.

	MOVE	0,%ERCAL	;SETUP FOR ERRHLT
	MOVEM	0,$ERHLT
	MOVE	0,%AC0		;RESTORE AC'S
	MOVE	1,%AC1
	MOVE	2,%AC2
	MOVE	3,%AC3
	MOVE	4,%AC4
	JRST	$ERHLT+1	;USE SUBROUTINE ERROR HALT

%ERPRA:	MOVEI	PGMNAM		;PRINT PROGRAM NAME
	SKIPN	%ERFST#		;ON FIRST ERROR ONLY
	PNTAL
	SETOM	%ERFST
	JRST	%ERPRB
;EXAMINE LOOPER SWITCH AND SCOPE LOOP ON ERROR IF SET.

%ERSW2:	TLNE	4,LOOPER
	JRST	.+3
	SETZM	SCOPE		;SCOPE PREVIOUSLY DEFINED .
	JRST	%ERSW3
	SETOM	SCOPE		;FORCE TEST TO LOOP.
	MOVE	0,%ERCAL
	SOS
	AOS	1,%ERCNT	;INCREMENT ERROR COUNT
	HRL	1,0
	SKIPN	USER		;USER MODE ?
	DATAO	PI,1		;DISPLAY ERROR PC,ERROR COUNT.

;RING TTY BELL IF DING SWITCH IS SET.
%ERSW3:	TLNN	4,DING
	JRST	%EXCAL
	MOVEI	0,BELL		;BELL CODE
	PNTAF

;RETURN TO ERROR CALL ADDRESS+1
%EXCAL:	MOVE	0,%AC0
	MOVE	1,%AC1
	MOVE	2,%AC2
	MOVE	3,%AC3
	MOVE	4,%AC4
	SKIPL	MONCTL		;UNDER DIAGNOSTIC MONITOR ?
	JRSTF	@%ERCAL		;NO, CONTINUE PROGRAM
	MOVE	0,ERRCNT	;YES
	CAIL	0,5		;PRINTED ALLOWED ERRORS ?
	JRST	.+3
	MOVE	0,%AC0
	JRSTF	@%ERCAL		;NO, CONTINUE PROGRAM
	AOS	17,RETCAL	;YES
	JRST	(17)		;RETURN TO CALLING PROGRAM
SUBTTL	PROGRAM SUBROUTINE INITIALIZATION, X00R, DECEMBER 6,1971

$PGMIN:	MOVEM	0,$ACA0#
	SETOM	USER#
	TLNN	0,USERF		;USER MODE ?
	SETZM	USER		;EXEC MODE
	SKIPN	MONFLG		;DIAG MON, SPECIAL USER MODE ?
	SETZM	USER		;YES, TREAT I/O AS EXEC
	SKIPE	USER		;EXEC ?
	JRST	.+3		;NO
	CONO	PI,10000	;CLEAR PI SYSTEM
	CONO	APR,200000	;CLEAR I/O
IFE FTKS10,<
	CONO	DTE,PILDEN!0	;NO PI'S FROM DTE
>
	SKIPE	USER		;USER ?
	RESET			;YES, CLEAR I/O
	JRST	2,@.+1		;CLEAR PC FLAGS
	XWD	0,.+1
	MOVE	CONSW
	MOVEM	$SVCSW#		;SAVE PREVIOUS SWITCHES
	SETZM	CONSW#		;CLEAR SWITCH REGISTER
	XLIST
	IFDEF	PSHLST,<LIST
	MOVE	%P,PLIST		;INIT PUSH POINTER
	MOVEI	0,$PSHER
	PUSH	%P,0		;SET ERR FOR EXCESSIVE POP'S>
	XLIST
	IFDEF	PRINT,<LIST
	JSP	$PNTIN		;INIT PRINT SUBROUTINE>
	XLIST
	IFDEF	TYPIN,<LIST
	JSP	$TYPIN		;INIT TTY INPUT SUBROUTINE>
	XLIST
	IFDEF	TOGGLE,<LIST
	JSP	$SWTIN		;INIT SWITCH INPUT SUBROUTINE>
	LIST
	JSP	$CPUTP		;DETERMINE CPU TYPE
	XLIST
	IFDEF	UUOS,<LIST
	JSP	$UUOIN		;INIT UUO SUBROUTINE>
	XLIST
	IFDEF	INTRPT,<LIST
	JSP	$ITRIN		;INIT INTERRUPT SUBROUTINE>
	LIST
	SETOM	$ONETM#		;SET ONE TIME FLAG
	JRST	@$ACA0		;EXIT
;DETERMINE PROCESSOR TYPE
$CPUTP:	MOVEM	0,$ACB0#
	SETZM	KAILFL#		;KAILFL =0, KA10; =-1, KI10; =+1 KL10
	SETZM	KSFLG#		;CLEAR KS10 FLAG
	JFCL	17,.+1
	JRST	.+1
	JFCL	1,$PDP6		;PDP-6 HAS PC CHANGE FLAG
	MOVEI	0,0
	BLT	0,0		;NOOP BLT
	JUMPN	0,$CPUTL	;NON-ZERO IF A KL10
	MOVNI	0,1		;KA10, KI10 DO NOT
	AOBJN	0,.+1		;CARRY INTO BIT 17 DETERMINES CP
	JUMPN	0,$CPUTA	;KI10 IF (AC) = 0,,0
	MOVEI	0,INXM		;KI NXM FLAG AND NXM CLEAR
	SOSA	KAILFL		;REMEMBER CPU IS A KI
$CPUTA:	MOVEI	0,ANXM		;KA NXM FLAG AND NXM CLEAR
	MOVEM	0,NXM#		;NXM FLAG
	JRST	$CPUT1		;STORE BIT TO CLEAR NXM AND EXIT
$CPUTL:	AOS	KAILFL		;REMEMBER CPU IS A KL OR KS
	BLKI	APR,0		;GET PROCESSOR INFO
	ANDI	0,17777		;ONLY SERIAL
	CAIL	0,10000		;IS IT A KS10?
	SETOM	KSFLG		;YES, SET THIS FLAG
	MOVEI	0,LNXM		;KL NXM FLAG
	SKIPE	KSFLG		;KS10?
	MOVEI	0,SNXM		;YES--KS NXM FLAG
	MOVEM	0,NXM		;REMEMBER THAT
	MOVEI	0,LNXCLR	;CLEAR KL NXM
	SKIPE	KSFLG		;KS10?
	MOVEI	0,SNXCLR	;CLEAR KS NXM
$CPUT1:	MOVEM	0,CLRNXM#	;BITS WHICH CLEAR NXM
	JRST	@$ACB0
	IFNDEF	INTRPT,<$PDP6: ERRHLT>

;SUBROUTINE ERROR HALT
$ERHLT:	0
	MOVEM	0,$ERH0#	;SAVE AC0
	MOVEI	[ASCIZ/
ERROR HALT AT /]
	PNTALF
	MOVE	$ERHLT
	SOS
	PNT6F
	MOVEI	CRLF
	PNTAF
	MOVE	0,$ERH0
	SKIPE	USER		;USER MODE ?
	EXIT	1,
	SKIPL	MONCTL		;UNDER MONITOR CONTROL ?
	HALT	@$ERHLT		;NO
	MOVE	0,CONSW
	IFDEF	TOGGLE,<SWITCH>
	TLNE	0,ERSTOP	;HALT ON ERROR SWITCH SET ?
	JRST	.+3
	AOS	17,RETCAL#	;RETURN TO CALLING PROGRAM
	JRST	(17)
	MOVE	0,$ERH0
	HALT	@$ERHLT
	XLIST
	IFDEF	PSHLST,<LIST
;PUSH DOWN LIST EXCESSIVE POPJ ROUTINE
$PSHER:	MOVEI	PGMNAM
	SKIPGE	MONCTL
	PNTALF
	MOVEI	[ASCIZ/
**********
PUSHDOWN LIST UNDERFLOW ERROR/]
	PNTALF
	ERRHLT>
	XLIST
	IFDEF	INTRPT,<LIST
SUBTTL INTERRUPT HANDLING SUBROUTINE, X00R, DECEMBER 6,1971

;INITIALIZE FOR INTERRUPTS AND TRAPPING.
$ITRIN:	MOVEM	0,$ACB0#
	SKIPE	USER		;PROCESSOR IN USER MODE?
	IFNDEF	USRASB,<ERRHLT>
	IFDEF	USRASB,<JRST	$ITRUS		;YES>
	SKIPN	KAILFL
	IFNDEF	KA10,<ERRHLT>
	IFDEF	KA10,<JRST $KA10>
	IFNDEF	KI10,<ERRHLT>
	IFDEF	KI10,<JRST $KI10>
;PDP-6 INITIALIZATION
$PDP6:	SKIPE	USER		;USER MODE?
	JRST	$ITRUS		;YES
	MOVEI	[ASCIZ/
PDP-6 CODE NOT IMPLEMENTED/]
	PNTALF
	ERRHLT
	HALT	BEGIN

;USER MODE INITIALIZATION
$ITRUS:	MOVEI	ITRUSR		;SETUP USER APR TRAPPING
	MOVEM	JOBAPR
	MOVEI	PDLOVU!MPVU!NXMU
	CALL	[SIXBIT/APRENB/]
	JRST	@$ACB0
;USER MODE INTERRUPTS
ITRUSR:	MOVE	JOBTPC
	MOVEM	ITRCH1		;SAVE TRAPPED ADDRESS
	MOVE	JOBCNI
	MOVEM	$SVAPR#		;SAVE CAUSE
	SETZM	$SVPI#
	TRNE	PDLOVU
	JRST	$PDOVU		;PUSHDOWN OVERFLOW
	TRNE	MPVU
	JRST	$MPVU		;MEMORY PROTECTION VIOLATION
	TRNE	NXMU
	JRST	$NXMU		;NON-X-MEMORY
	JRST .+1		;TO HANDLE OTHERS, PLACE TRANSFER HERE
	JRST	$ITRHL+1	;ERROR

$PDOVU:	MOVEI	[ASCIZ/
PUSHDOWN OVERFLOW/]
	JRST	$ITR1A
$MPVU:	MOVEI	[ASCIZ/
MEMORY PROTECTION VIOLATION/]
	JRST	$ITR1A
$NXMU:	MOVEI	[ASCIZ/
NON-EXISTANT MEMORY/]
	JRST	$ITR1A
;COMMON INTERRUPT HANDLERS

$ITRHL:	JRST	.+1		;TO HANDLE OTHERS, PLACE TRANSFER HERE
	MOVEI	[ASCIZ/
ERROR INTERRUPT/]
	JRST	$ITR1A

$PARER:	MOVEI	[ASCIZ/
MEMORY PARITY INTERRUPT/]
	JRST	$ITR1A

;COMMON EXEC MODE POWER FAILURE ROUTINE

$PWRDN:	MOVEM	0,$ACD0#
	MOVE	[1,,POWER+1]
	BLT	POWER+17
	CONI	APR,$SVAPR	;SAVE APR SYSTEM
	CONI	PI,$SVPI	;SAVE PI SYSTEM
	SKIPE	KAILFL		;KI10?
	DATAI	PAG,$SVPAG#	;YES, SAVE PAG SYSTEM
	SETOM	$PWRF#
	HALT	BEGIN

;RESTORE PROCESSOR ON RESTART

	SKIPN	$PWRF		;DID POWER FAIL WORK?
	JRST	$PWRFL		;NO
	SKIPN	KAILFL
	IFNDEF	KA10,<JRST $PWRFL>
	IFDEF	KA10,<JRST $KARST>
	IFNDEF	KI10,<JRST $PWRFL>
	IFDEF	KI10,<JRST $KIRST>

$RSTCM:	MOVS	[1,,POWER+1]	;RESTORE AC'S
	BLT	17
	SETZM	$PWRF
	JRST	.+1		;TO ADD ROUTINE, PLACE TRANSFER HERE
	JRST	@$ACD0

$PWRFL:	PGMINT
	MOVEI	[ASCIZ/
POWER INTERRUPT FAILED
/]
	PNTALF
	HALT	BEGIN
;PRINT CAUSE AND OTHER PERTINENT INFO

$ITR1A:	MOVEM	0,$ITAC0#
	MOVEI	PGMNAM
	SKIPGE	MONCTL		;PRINT PROGRAM NAME
	PNTALF			;IF UNDER DIAG MONITOR
	MOVE	0,$ITAC0
	PNTALF			;PRINT CAUSE
	MOVEI	[ASCIZ/
APR            PI             FLAGS  PC      PROG
/]
	PNTALF
	MOVE	$SVAPR
	PNTHWF			;PRINT APR CONI BITS
	MOVEI	SPACE
	PNTAF
	MOVE	$SVPI
	PNTHWF			;PRINT PI CONI BITS
	MOVEI	SPACE
	PNTAF
	MOVE	ITRCH1
	SOS
	PNTHWF			;PRINT FLAGS, PC
	IFDEF	PSHLST,<
	MOVEI	SPACE
	PNTAF
	HRRZ	0,(%P)
	SOS
	PNT6F			;PRINT LAST PUSHJ ENTRY>
	MOVEI	CRLF2
	PNTAF
	JRST	.+1		;TO ADD ROUTINE, PLACE TRANSFER HERE
	ERRHLT
	HALT	BEGIN

;COMMON INTERRUPT ROUTINE

	IFNDEF	SLDCDE,<
ITRCH1:	0			;TO PROVIDE SOLID CODE, DEFINE SLDCDE>
	MOVEM	0,$ACC0#
	SKIPN	KAILFL
	IFNDEF	KA10,<ERRHLT>
	IFDEF	KA10,<JRST $KAITR> ;KA10
	IFNDEF	KI10,<ERRHLT>
	IFDEF	KI10,<JRST $KIITR> ;KI10

	XLIST
	IFDEF	KA10,<LIST
;KA10 INTERRUPT ROUTINE

$KAITR:	CONSO	PI,APWRFL	;POWER FAILURE?
	JRST	$KAIT1		;NO
	JSP	$PWRDN		;YES, SAVE PROCESSOR STATE AND HALT

	MOVE	0,$ACC0
	JRSTF	@ITRCH1		;CONTINUE PROGRAM ON RESTART

$KAIT1:	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	CONSZ	PI,APARER
	JRST	$PARER		;PARITY ERROR
	CONSZ	APR,APDLOV
	JRST	$PDOVU		;PUSHDOWN OVERFLOW
	CONSZ	APR,AMPV
	JRST	$MPVU		;MEMORY PROTECTION VIOLATION
	CONSZ	APR,ANXM
	JRST	$NXMU		;NON-X-MEMORY
	JRST	$ITRHL		;REST COMMON

;KA10 POWER FAIL RESTART

$KARST:	CONO	APR,$KAINT
	CONO	PI,PWFCLR!PARCLR!PARDIS!PICLR!CHNOFF!PIOFF
	MOVE	1,$SVAPR
	TRZ	1,775550	;CLEAR MISC APR BITS
	CONO	APR,(1)		;RESET APR SYSTEM
	MOVE	1,$SVPI
	TRZ	1,777400	;CLEAR MISC PI BITS
	MOVE	2,$SVPI
	TRNE	2,APAREN	;WAS PARITY ENABLED
	TRO	1,PARENB	;YES
	TRO	1,CHNON		;SET PI CHANNEL ON BIT
	CONO	PI,(1)		;RESET PI SYSTEM
	JRST	$RSTCM		;REST COMMON
;KA10 INTERRUPT INITIALIZATION

$KAINT=APDCLR!IOCLR!AABCLR!AMPCLR!ANXCLR!CLKDIS!CLKCLR!AFODIS!AFOCLR!AOVDIS!AOVCLR

$KA10:	MOVE	[JSR ITRCH1]
	MOVEM	42		;SETUP INTERRUPT TRAP
	MOVEM	44
	MOVEM	46
	MOVEM	50
	MOVEM	52
	MOVEM	54
	MOVEM	56
	CONO	APR,$KAINT
	CONO	PI,PARCLR!PARDIS!PICLR!CHNOFF!PIOFF
	SETZM	$PWRF
	CONO	APR,AAPRC1	;ASSIGN CHANNEL 1
	CONO	PI,PARENB!CHNON!PION!PICHN1
	JRST	@$ACB0
>
	XLIST
	IFDEF	KI10,<LIST
;KI10 INTERRUPT ROUTINE

$KIITR:	CONSO	APR,IPWRFL	;POWER FAILURE?
	JRST	$KIIT1		;NO
	JSP	$PWRDN		;YES, SAVE PROCESSOR STATE AND HALT

	MOVE	0,$ACC0
	JRSTF	@ITRCH1		;CONTINUE PROGRAM ON RESTART

$KIIT1:	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	CONSZ	APR,IPARER
	JRST	$PARER		;PARITY ERROR
	CONSZ	APR,INXM
	JRST	$NXMU		;NON-X-MEMORY
	JRST	$ITRHL		;REST COMMON

;KI10 TRAP ROUTINE

PDLOV:	0
	MOVE	PDLOV		;SAVE TRAPPED ADDRESS
	MOVEM	ITRCH1
	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	JRST	$PDOVU

PGFAIL:	0
	MOVE	PGFAIL		;SAVE FAILED ADDRESS
	MOVEM	ITRCH1
	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	MOVEI	[ASCIZ/
PAGE FAIL TRAP ERROR
PAGE FAIL WORD- /]
	PNTALF
	MOVE	EXCPFW
	PNTHWF
	SETZM	0
	JRST	$ITR1A
;KI10 TRAP 3 ROUTINE

TRAP3:	0
	MOVE	TRAP3
	MOVEM	ITRCH1
	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	MOVEI	[ASCIZ/
TRAP 3 ERROR/]
	JRST	$ITR1A

;MONITOR UUO ERROR ROUTINE

MUUOER:	MOVE	MUUOPC
	MOVEM	ITRCH1
	CONI	APR,$SVAPR
	CONI	PI,$SVPI
	MOVEI	[ASCIZ/
MONITOR UUO ERROR
MUUO= /]
	PNTALF
	MOVE	MUUO
	PNTHWF			;PRINT MUUO
	SETZM	0
	JRST	$ITR1A
;KI10 POWER FAIL RESTART

$KIRST:	CONO	APR,IOCLR!ITMDIS!IASRTC!CLKDIS!CLKCLR!IIOPFC!INXCLR
	CONO	PI,PWFCLR!PARCLR!PARDIS!IRQCLR!PICLR!CHNOFF!PIOFF
	CONO	PAG,0
	DATAO	APR,[IMGNOF,,ISPDOF]
	MOVE	0,$SVPAG
	TLO	0,LDUSRB
	TRO	0,LDEXCB
	DATAO	PAG,0		;RESET PAG SYSTEM
	MOVE	1,$SVPI
	TRZ	1,777400	;CLEAR MISC PI BITS
	TRO	1,CHNON		;SET PI CHANNEL ON BIT
	MOVE	2,$SVAPR
	TRNE	2,IPAREN	;WAS PARITY ENABLED?
	TRO	1,PARENB	;YES
	MOVE	3,2
	TRZ	3,720700	;CLEAR MISC APR BITS
	TRNE	2,ITMOEN	;WAS TIME OUT ENABLED?
	TRO	3,ITMSET!ITMENB ;YES
	CONO	APR,(3)		;RESET APR SYSTEM
	CONO	PI,(1)		;RESET PI SYSTEM
	JRST	$RSTCM		;RESET COMMON
;KI10 INTERRUPT AND TRAP INITIALIZATION

$KI10:	MOVE	[JSR ITRCH1]
	MOVEM	42		;SETUP INTERRUPT TRAP
	MOVEM	44
	MOVEM	46
	MOVEM	50
	MOVEM	52
	MOVEM	54
	MOVEM	56
	MOVE	[JSR PGFAIL]
	MOVEM	PGFTRP		;SETUP PAGE FAIL TRAP
	MOVSI	(JFCL)
	MOVEM	AROVTP		;SETUP ARITHMETIC TRAP
	MOVE	[JSR PDLOV]
	MOVEM	PDOVTP		;SETUP PDL OV TRAP
	MOVE	[JSR TRAP3]
	MOVEM	TRP3TP		;SETUP TRAP 3
	MOVEI	MUUOER
	MOVEM	KNTRP		;SETUP MUUO AS ERROR
	MOVEM	KTRP
	MOVEM	SNTRP
	MOVEM	STRP
	MOVEM	CNTRP
	MOVEM	CTRP
	MOVEM	PNTRP
	MOVEM	PTRP
	CONO	PI,PWFCLR!PARCLR!PARDIS!IRQCLR!PICLR!CHNOFF!PIOFF
	SKIPL	MONCTL		;DIAGNOSTIC MONITOR?
	CONO	APR,IOCLR!ITMDIS!IASRTC!CLKDIS!CLKCLR!IIOPFC!INXCLR
	SKIPGE	MONCTL		;YES
	CONO	APR,IOCLR!CLKDIS!CLKCLR!INXCLR
	CONO	PAG,0
	SKIPL	MONCTL
	DATAO	APR,[IMGNOF,,ISPDOF]
	SKIPE	MONFLG
	DATAO	PAG,[LDUSRB,,LDEXCB!TRPENB]
	CONO	APR,IAPRE1	;ERROR CHANNEL 1
	CONO	PI,PARENB!CHNON!PION!PICHN1
	JRST	@$ACB0

>>
	XLIST
	IFDEF	MEMMAP,<LIST
SUBTTL	MEMORY MAPPING SUBROUTINE, X00R, DECEMBER 6,1971

;DETERMINE MEMORY SIZE AND PRINT MEMORY MAP

$MEMMP:	MOVEM	0,$ACB0
	SETZM	$SEGM#		;CLEAR NON-CONSEC FLAG
	SETZM	$ITRLV#		;CLEAR INTERLV ERROR FLAG
	MOVE	MEMSIZ
	MOVEM	$MSZSV#		;SAVE PREVIOUS MEMSIZE
	SETZM	MEMSIZ		;CLEAR MAP STORAGE
	MOVE	[MEMSIZ,,MEMSIZ+1]
	BLT	MEMSZ3+377
	SETZB	0,3
	SKIPN	USER		;EXEC MODE ?
	IFNDEF	EXCASB,<ERRHLT>
	IFDEF	EXCASB,<
	JRST	$MEMEX		;YES >

	IFNDEF	USRASB,<ERRHLT>
	IFDEF	USRASB,<
	HRRZ	JOBREL		;GET HIGHEST REL ADR
	MOVEM	MEMSIZ		;SAVE AS MEMORY SIZE
	JRST	$PMAP5		;GO PRINT	>
	XLIST
	IFDEF	EXCASB,<LIST
;KI10, KL10, SETUP PAGE MAP FOR 256K, RELOCATION = ACTUAL

	IFNDEF	INHPAG,<INHPAG==0>

$EPMPS:	0
	MOVE	0,CONSW		;GET SWITCHES
	TDNE	0,[INHPAG]	;IS PAGING INHIBITED ?
	JRST	$EPMP5		;YES
	SKIPN	MONFLG
	JRST	@$EPMPS		;SPECIAL USER MODE
	DATAI	PAG,SAVPG1
	SKIPLE	KAILFL
	CONI	PAG,SAVPAG
	MOVSI	2,-200
	MOVE	[500376,,500377]
$EPMP1:	ADD	[2,,2]
	MOVEM	200(2)
	AOBJN	2,$EPMP1
	MOVSI	2,-20
	MOVE	[500336,,500337]
$EPMP2:	ADD	[2,,2]
	MOVEM	400(2)
	AOBJN	2,$EPMP2	;EXEC PER-PROCESS
	SKIPG	KAILFL
	JRST	$EPMP4
	MOVSI	2,-140
	MOVE	[500000,,500001]
$EPMP3:	MOVEM	600(2)
	ADD	[2,,2]
	AOBJN	2,$EPMP3
	MOVEI	2,NXMLOC
	MOVEM	2,PFNPCW
	DATAO	PAG,[100000,,0]
	MOVEI	2,LTRPEN
	CONO	PAG,(2)
	CAIA
$EPMP4:	MOVEI	2,LDEXCB+TRPENB+0
	SKIPGE	KAILFL
	DATAO	PAG,2
	SKIPE	KAILFL
	MOVEM	2,CLRPM#
	JRST	@$EPMPS

$EPMP5:	MOVEI	2,337777	;PAGING INHIBITED
	JRST	$MEMX2		;START AT 112K-1
;EXEC MODE MEMORY MAPPING

$MEMEX:	SKIPE	KAILFL
	IFNDEF	KI10,<ERRHLT>
	IFDEF	KI10,<
	JSR	$EPMPS		;KI10, SETUP PAGE MAP >
	HRLOI	2,17
	SKIPN	KAILFL
	MOVEI	2,-1		;START AT 256K
	SKIPE	KSFLG		;KS10?
	HRLOI	2,1		;YES--THEN START AT 512K
$MEMX2:	SKIPN	MONFLG		;SPECIAL USER MODE ?
	MOVEI	2,77777		;YES, START AT 32K
	MOVEM	2,$MEMAX#

;NON-X-MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX7

$M1:	CONO	APR,@CLRNXM
	PUSHJ	%P,CHKWRD
	CONSO	APR,@NXM	;NON-X-MEM ?
	JRST	$M5		;NO
	CONO	APR,@CLRNXM	;YES, CLEAR FLAG
	SUBI	2,1000		;DECREMENT ADDRESS
	CAIL	2,17777		;LESS THAN 8K ?
	JRST	$M1		;NO
	JRST	$MERR		;YES, ERROR
;EXISTANT MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX7

$M3:	PUSHJ	%P,CHKWRD
	CONSZ	APR,@NXM	;EXISTANT MEMORY ?
	AOJA	2,$M6		;NO
	SUBI	2,100		;YES, DECREMENT ADDRESS
	CAIL	2,0		;COMPLETED ?
	JRST	$M3		;NO
	AOJA	2,$M7		;YES

;SAVE MEMORY ADDRESSES

$M5:	MOVEM	2,MEMSIZ(3)
	JRST	$M3

$M6:	MOVEM	2,MEMSIZ+1(3)
	ADDI	3,2
	SOJA	2,$M1

$M7:	MOVEM	2,MEMSIZ+1(3)
	CAIE	3,0
	SETOM	$SEGM
	SETZM	3
	MOVE	2,$MEMAX

IFN FTKS10,<
	JRST	$PMAP3		;NO INTERLEAVING ON KS10
>

;NON-X-MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX6

$M1A:	CONO	APR,@CLRNXM
	PUSHJ	%P,CHKWM1
	CONSO	APR,@NXM	;NON-X-MEM ?
	JRST	$M5A		;NO
	CONO	APR,@CLRNXM	;YES, CLEAR FLAG
	SUBI	2,1000		;DECREMENT ADDRESS
	CAIL	2,17777		;LESS THAN 8K ?
	JRST	$M1A		;NO
	JRST	$MERR		;YES, ERROR
;EXISTANT MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX6

$M3A:	PUSHJ	%P,CHKWM1
	CONSZ	APR,@NXM	;EXISTANT MEMORY ?
	AOJA	2,$M6A		;NO
	SUBI	2,100		;YES, DECREMENT ADDRESS
	CAIL	2,0		;COMPLETED ?
	JRST	$M3A		;NO
	AOJA	2,$M7A		;YES

;SAVE MEMORY ADDRESSES

$M5A:	MOVEM	2,MEMSZ1(3)
	JRST	$M3A

$M6A:	MOVEM	2,MEMSZ1+1(3)
	ADDI	3,2
	SOJA	2,$M1A

$M7A:	MOVEM	2,MEMSZ1+1(3)
	CAIE	3,0
	SETOM	$SEGM
	SETZM	3
	MOVE	2,$MEMAX

;NON-X-MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX5

$M1B:	CONO	APR,@CLRNXM
	PUSHJ	%P,CHKWM2
	CONSO	APR,@NXM	;NON-X-MEM ?
	JRST	$M5B		;NO
	CONO	APR,@CLRNXM	;YES, CLEAR THE FLAG
	SUBI	2,1000		;DECREMENT ADDRESS
	CAIL	2,17777		;LESS THAN 8K ?
	JRST	$M1B		;NO
	JRST	$MERR		;YES, ERROR
;EXISTANT MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX5

$M3B:	PUSHJ	%P,CHKWM2
	CONSZ	APR,@NXM	;EXISTANT MEMORY ?
	AOJA	2,$M6B		;NO
	SUBI	2,100		;YES, DECREMENT ADDRESS
	CAIL	2,0		;COMPLETED ?
	JRST	$M3B		;NO
	AOJA	2,$M7B		;YES

;SAVE MEMORY ADDRESSES

$M5B:	MOVEM	2,MEMSZ2(3)
	JRST	$M3B

$M6B:	MOVEM	2,MEMSZ2+1(3)
	ADDI	3,2
	SOJA	2,$M1B

$M7B:	MOVEM	2,MEMSZ2+1(3)
	CAIE	3,0
	SETOM	$SEGM
	SETZM	3
	MOVE	2,$MEMAX

;NON-X-MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX4

$M1C:	CONO	APR,@CLRNXM
	PUSHJ	%P,CHKWM3
	CONSO	APR,@NXM	;NON-X-MEM ?
	JRST	$M5C		;NO
	CONO	APR,@CLRNXM	;YES, CLEAR THE FLAG
	SUBI	2,1000		;DECREMENT ADDRESS
	CAIL	2,17777		;LESS THAN 8K ?
	JRST	$M1C		;NO
	JRST	$MERR		;YES, ERROR

;EXISTANT MEMORY MAPPER
;INTERLEAVING ADDRESSES XXX4

$M3C:	PUSHJ	%P,CHKWM3
	CONSZ	APR,@NXM	;EXISTANT MEMORY ?
	AOJA	2,$M6C		;NO
	SUBI	2,100		;YES, DECREMENT ADDRESS
	CAIL	2,0		;COMPLETED ?
	JRST	$M3C		;NO
	AOJA	2,$M7C		;YES

;SAVE MEMORY ADDRESSES

$M5C:	MOVEM	2,MEMSZ3(3)
	JRST	$M3C

$M6C:	MOVEM	2,MEMSZ3+1(3)
	ADDI	3,2
	SOJA	2,$M1C
$M7C:	MOVEM	2,MEMSZ3+1(3)
	JRST	$PMAP
CHKWM3:	SUBI	2,3
	PUSHJ	%P,CHKWRD
	ADDI	2,3
	POPJ	%P,

CHKWM2:	SUBI	2,2
	PUSHJ	%P,CHKWRD
	ADDI	2,2
	POPJ	%P,

CHKWM1:	SUBI	2,1
	PUSHJ	%P,CHKWRD
	ADDI	2,1
	POPJ	%P,

CHKWRD:	SKIPE	KAILFL
	JRST	CHKWR1
	CAM	(2)
	POPJ	%P,
CHKWR1:	MOVE	1,2
	LSH	1,-^D9
	MOVEI	1,500000(1)
	HRLM	1,200
	SKIPGE	KAILFL
	DATAO	PAG,CLRPM
	SKIPLE	KAILFL
	CONO	PAG,@CLRPM
	MOVE	1,2
	ANDI	1,777
	IORI	1,400000
	CAM	(1)
NXMLOC:	POPJ	%P,
>
;PRINT MEMORY MAP
$PMAP:	MOVE	0,MEMSIZ	;COMPARE FIRST MAP WORD OF EACH INTERLV
	MOVE	1,MEMSIZ+1
	CAMN	0,MEMSZ1
	CAME	1,MEMSZ1+1
	SETOM	$ITRLV		;IF ALL SAME, NO INTERLV PROBLEM
	MOVE	0,MEMSZ1	;IF NOT, PRINT ALL 4 MAPS
	MOVE	1,MEMSZ1+1
	CAMN	0,MEMSZ2
	CAME	1,MEMSZ2+1
	SETOM	$ITRLV
	MOVE	0,MEMSZ2
	MOVE	1,MEMSZ2+1
	CAMN	0,MEMSZ3
	CAME	1,MEMSZ3+1
	SETOM	$ITRLV
	SKIPE	$SEGM		;IF NON-CONSEC ALWAYS PRINT
	JRST	$PMAP1
	SKIPE	$ITRLV		;IF INTERLV PROB ALWAYS PRINT
	JRST	$PMAP1
$PMAP5:	SKIPL	MONCTL		;UNDER DIAGNOSTIC MONITOR ?
	JRST	$PMAP3		;NO
	SKIPE	USER		;USER MODE ?
	JRST	$PMAP4		;YES
	HLRZ	MONCTL		;FIRST PASS ?
	CAIE	-1
	JRST	$PMAP4		;NO
$PMAP3:	MOVE	MEMSIZ		;SAME AS PREVIOUS ?
	CAMN	0,$MSZSV
	JRST	$PMAP4		;YES, MUST BE RESTART
$PMAP1:	MOVEI	[ASCIZ?
MEMORY MAP =
FROM   TO     SIZE/K?]
	SKIPE	KAILFL
	MOVEI	[ASCIZ?
MEMORY MAP =
FROM     TO       SIZE/K?]
	PNTAL
	MOVEI	CRLF
	SKIPE	$ITRLV
	MOVEI	[ASCIZ/	ADR SEQ
/]
	PNTAL
	SETZB	0,3
$PMAPL:	SKIPN	2,MEMSIZ(3)	;GET MAP COORDINATES
	JRST	$PMAP2
	MOVE	0,MEMSIZ+1(3)
	SKIPE	KAILFL
	JRST	$PMPL1
	HRLZS	0
	HRR	0,MEMSIZ(3)
	PNTHW
	JRST	$PMPL2
$PMPL1:	PNT10
	MOVE	0,MEMSIZ(3)
	PNT10
$PMPL2:	MOVE	0,2
	AOS
	SUB	0,MEMSIZ+1(3)
	IDIVI	^D1024
	PNTDEC			;PRINT DECIMAL SIZE
	MOVEI	CRLF
	SKIPE	$ITRLV
	MOVEI	$XXX7
	PNTAL
	AOS	3
	AOJA	3,$PMAPL	;GET NEXT IF ANY
$PMAP2:	SKIPN	$ITRLV		;INTERLEAVING ERROR ?
	JRST	$PMAP4		;NO
	SETZB	0,3
$PMP1:	SKIPN	2,MEMSZ1(3)
	JRST	$PMP2
	MOVE	0,MEMSZ1+1(3)
	SKIPE	KAILFL
	JRST	$PMPL3
	HRLZS	0
	HRR	0,MEMSZ1(3)
	PNTHW
	JRST	$PMPL4
$PMPL3:	PNT10
	MOVE	0,MEMSZ1(3)
	PNT10
$PMPL4:	MOVE	0,2
	AOS
	SUB	0,MEMSZ1+1(3)
	IDIVI	^D1024
	PNTDEC
	MOVE	4,3
	LSH	4,-3
	MOVEI	$ASPNT(4)
	PNTA
	MOVEI	CRLF
	PNTA
	AOS	3
	AOJA	3,$PMP1

$PMP2:	CAIE	3,1400
	JRST	.-2
	MOVEI	[ASCIZ/
MAPPING ERROR; MEMORY INTERLEAVING ?
/]
	PNTALF
	MOVEI	[ASCIZ/
MAPPING ERROR; NON-CONSECUTIVE MEMORY MODULES ?
/]
	SKIPE	$SEGM
	PNTALF
	ERRHLT
	HALT	BEGIN
$PMAP4:	SKIPN	$SEGM
	JRST	@$ACB0
	SOS	3
	MOVE	2,MEMSIZ(3)
	MOVEM	2,MEMSIZ
	MOVEI	[ASCIZ/
MAPPING ERROR; NON-CONSECUTIVE MEMORY MODULES ?
/]
	JRST	$MERR+1
$MERR:	MOVEI	[ASCIZ/
MAPPING ERROR; NON-X-MEMORY BELOW 8K ?
/]
	PNTALF
	ERRHLT
	HALT	BEGIN

$ASPNT:	ASCII/	XXX6/
	ASCII/	XXX5/
	ASCII/	XXX4/
$XXX7:	ASCIZ/	XXX7
/
>
	XLIST
	IFDEF	UUOS,<LIST
SUBTTL	UUO HANDLING SUBROUTINE, X00R, DECEMBER 6,1971

	IFNDEF	SLDCDE,<
UUORTN:	0			;TO PROVIDE SOLID CODE MOVE THIS>
	SKIPE	$UOREC#		;A RECURSIVE UUO ?
	JRST	$UUOER		;YES, ILLEGAL
	SETOM	$UOREC		;SET DOING UUO FLAG
	MOVEM	0,$UOAC0#	;SAVE AC0
	MOVE	UUORTN
	MOVEM	$SVUPC#
	MOVE	JOBUUO
	MOVEM	$SVUUO#
	LSH	-^D27
	CAILE	37		;UUO IN CORRECT RANGE ?
	JRST	$UUOER		;NO
	ADD	[JRST @UUODIS]
	MOVEM	$UUOGO
	MOVE	$UOAC0
	IFDEF	PSHLST,<
	PUSH	%P,UUORTN	;MAKE RECURSIVE
	SETZM	$UOREC	>
$UUOGO:	JRST	@UUODIS		;DISPATCH TO UUO ROUTINE

;UUO EXIT ROUTINE

	AOS	UUORTN		;SKIP RETURN, +2
	IFDEF	PSHLST,<
	AOS	(%P)	>

	SETZM	$UOREC		;CLEAR DOING UUO FLAG
	IFDEF	PSHLST,<
	RTN		>
	JRST	2,@UUORTN	;RESTORE FLAGS AND EXIT
;ILLEGAL OR UNCODED UUO ROUTINE

$UUOER:	MOVEI	PGMNAM
	SKIPGE	MONCTL
	PNTALF
	MOVEI	[ASCIZ/
ILLEGAL UUO EXECUTED
UUO            FLAGS      PC    PROG
/]
	PNTALF			;PRINT HEADER
	MOVE	$SVUUO
	PNTHWF			;PRINT UUO
	MOVEI	SPACE
	PNTAF
	MOVE	$SVUPC
	SOS
	PNTHWF			;PRINT FLAGS, PC
	IFDEF	PSHLST,<
	MOVEI	SPACE
	PNTAF
	HRRZ	0,(%P)
	SUBI	0,1
	PNT6F			;PRINT LAST PUSHJ ENTRY>
	MOVEI	CRLF2
	PNTAF
	JRST	.+1		;TO ADD ROUTINE, PLACE JRST HERE
	ERRHLT
	JRST	@UUORTN
;UUO DISPATCH TABLE

UUODIS:	$UUOER			;ILL UUO, 0
	$UUOER			;UUO 1
	$UUOER			;UUO 2
	$UUOER			;UUO 3
	$UUOER			;UUO 4
	$UUOER			;UUO 5
	$UUOER			;UUO 6
	$UUOER			;UUO 7
	$UUOER			;UUO 10
	$UUOER			;UUO 11
	$UUOER			;UUO 12
	$UUOER			;UUO 13
	$UUOER			;UUO 14
	$UUOER			;UUO 15
	$UUOER			;UUO 16
	$UUOER			;UUO 17
	$UUOER			;UUO 20
	$UUOER			;UUO 21
	$UUOER			;UUO 22
	$UUOER			;UUO 23
	$UUOER			;UUO 24
	$UUOER			;UUO 25
	$UUOER			;UUO 26
	$UUOER			;UUO 27
	$UUOER			;UUO 30
	$UUOER			;UUO 31
	$UUOER			;UUO 32
	$UUOER			;UUO 33
	$UUOER			;UUO 34
	$UUOER			;UUO 35
	$UUOER			;UUO 36
	$UUOER			;UUO 37


;UUO INITIALIZATION

$UUOIN:	MOVEM	0,$ACB0
	MOVE	[JSR	UUORTN]
	MOVEM	JOB41		;SETUP UUO TRAP
	SETZM	$UOREC
	JRST	@$ACB0

>

	XLIST
	IFDEF	TOGGLE,<LIST
SUBTTL	CONSOLE DATA SWITCH INPUT SUBROUTINE, X00R, DECEMBER 6,1971

;INPUT CONSOLE SWITCHES IN EXEC MODE OR IN USER MODE IF NON-TTY SWITCH CONTROL

$SWTCH:	MOVEM	0,$SACA0#
	SETZ	0,
	JRST	@$SACA0

;SWITCH INITIALIZATION ROUTINE

$SWTIN:	MOVEM	0,$ACB0#
	SETZM	$USWTF#		;CLEAR TTY CONTROL FLAG
	SKIPN	USER		;USER MODE ?
	JRST	$SWIN1		;NO, EXEC MODE
	IFNDEF	USRASB,<ERRHLT >
	IFDEF	USRASB,<JRST $SWINT >

$SWIN1:	SWITCH
	TLNN	PNTLPT		;PRINT ON LPT/LOGICAL DEVICE ?
	JRST	@$ACB0		;NO
	MOVEI	PGMNAM
	PNTAL			;YES, IDENTIFY OUTPUT FILE
	MOVEI	[ASCIZ/
DATA SWITCHES = /]
	PNTAL
	MOVE	CONSW
	PNTHW			;PRINT PRESENT SWITCH SETTINGS
	MOVEI	CRLF2
	PNTA
	JRST	@$ACB0

	XLIST
	IFDEF	USRASB,<LIST
;SWITCH USER MODE INITIALIZATION ROUTINE

$SWINT:	SKIPGE	MONCTL		;SYS EXERCISER MODE ?
	JRST	$SWIN2		;YES
$SW1:	MOVEI	[ASCIZ/
TELETYPE SWITCH CONTROL ? - 0,S,Y OR N <CR> - /]
	PNTALF			;ASK FOR SWITCH CONTROL MODE
	TTICHR
	JRST	$SW1
	LSH	0,7		;POSITION 1ST CHAR
	MOVEM	$SW#
	TTICHR
	JRST	$SW1
	OR	0,$SW
	MOVEM	0,$SW
	CAIN	0,14015		;"0" (CR)
	JRST	$SW5
	CAIN	0,24615		;"S" (CR)
	JRST	$SW6
	CAIN	0,26215		;"Y" (CR)
	JRST	$SW2
	CAIN	0,23415		;"N" (CR)
	JRST	$SWIN1
	TTCALL	11,0		;ERROR, CLEAR TYPE-IN BUFFER
	JRST	$SW1

$SW6:	MOVE	0,$SVCSW	;"S", USE PREVIOUSLY SET SWITCHES
	JRST	$SW4

$SW2:	MOVEI	[ASCIZ/
SPECIFY LH SWITCHES IN OCTAL - /]
	PNTALF
	TTIOCT			;INPUT 6 OCTALS
	JRST	$SW2		;ERROR
	HRLZM	0,$SW#		;MOVE LH WORD TO SW
$SW3:	MOVEI	[ASCIZ/SPECIFY RH SWITCHES IN OCTAL - /]
	PNTALF
	TTIOCT			;INPUT 6 OCTALS
	JRST	$SW3		;ERROR
	HLL	0,$SW		;GET LH SWITCHES
$SW4:	MOVEM	0,CONSW		;SAVE SWITCHES IN CONSW
$SW5:	SETOM	$USWTF		;SET TTY INPUT SWITCH FLAG
	JRST	$SWIN1

$SWIN2:	MOVE	0,SWTEXR	;GET SYS EXER SWITCHES
	JRST	$SW4
>>
	XLIST
	IFDEF	TYPIN,<LIST
SUBTTL	TELETYPE INPUT SUBROUTINE, X00R, DECEMBER 6,1971
;CARRIAGE RETURN OR COMMA TERMINATES OCTAL, DECIMAL, OR CONVERT TYPE-IN.
;CHARACTER OR NUMBER RETURNED IN AC0.
;OPERATOR WAIT TIME (OPTIME) INITIALIZED
;AS NUMBER OF SECONDS OF WAIT TIME IN EXEC MODE.
;CALL SEQUENCE IS AS FOLLOWS:
;	JSP	NAME
;	NO/ERROR RESPONSE RETURN
;	NORMAL RESPONSE RETURN
;$OPTLK =	INPUT ANY CHARACTER
;$YESNO =	ASK QUESTION, CORRECT RESPONSE Y
;$NOYES =	ASK QUESTION, CORRECT RESPONSE N
;$TPOCT =	INPUT UP TO 12 OCTALS
;$TPDEC =	INPUT UP TO 11 DECIMALS
;$TPCNV =	INPUT UP TO 9 CONVERT'S
;$TTLK =	KEYBOARD CHECK, INPUT ANY CHARACTER
;$TALTM =	KEYBOARD, ALT-MODE CHECK

;TELETYPE INPUT INITIALIZATION

$TYPIN:	MOVEM	0,$ACB0
	MOVEI	^D180
	MOVEM	OPTIME#		;INIT OPERATOR WAIT TIME AS 180 SEC.
	SKIPN	KSFLG		;IF A KS10
	SKIPG	KAILFL		;IF A KL10
	JRST	@$ACB0
	SETZM	DTEEPW		;INIT SECONDARY PROTOCALL
	SETZM	DTEMTI
	SETZM	DTEFLG
	MOVEI	0,.DTMMC
	MOVEM	0,DTECMD
	CONO	DTE,TO11DB	;TELL THE 11
	SKIPN	DTEFLG
	JRST	.-1		;WAIT UNTIL THE 11 KNOWS
	JRST	@$ACB0

;TELETYPE KEYBOARD CHECK ROUTINE
;CHECKS FOR ANY KEY STRUCK, RETURNS IMMEDIATELY
;RETURNS +1 IF NO TYPEIN, RETURNS +2 IF CHAR TYPED

$TTLK:	MOVEM	0,$TACA0
	SETZM	0
	SKIPGE	MONCTL		;NO CHECK IF MONITOR
	JRST	@$TACA0
	SKIPN	USER		;EXEC MODE ?
	JRST	$HEAR+3		;GO CHECK AND INPUT, EXEC MODE
	TTCALL	2,0
	JRST	@$TACA0		;NO CHAR
	JRST	$TTUSR+1	;CHAR WAS TYPED

;TELETYPE ALT-MODE CHECK ROUTINE

$TALTM:	MOVEM	0,$TALT0#
	TTLOOK
	JRST	$TALT1+1	;NO TYPE-IN
	CAIE	175
	CAIN	176
	JRST	$TALT1		;ALT-MODE
	CAIE	33
	SKIPA
$TALT1:	AOS	$TALT0		;ALT-MODE, RETURN + 2
	JRST	@$TALT0
;TELETYPE INPUT OPERATOR RESPONSE ROUTINE
;ALLOWS WAIT OF N SECONDS FOR TYPE-IN
;IF NO RESPONSE, RETURNS +1, NORMAL RETURN +2
$OPTLK:	MOVEM	0,$TACB0#
	MOVEM	4,$TACB4#	;SAVE AC
	JSP	$HEAR		;NO, INPUT FROM TTY
	JRST	.-1		;NO RESPONSE, REPEAT
	AOS	$TACB0		;CHAR TYPED, RETURN +2
	MOVE	4,$TACB4
	JRST	@$TACB0

;TELETYPE INPUT CHARACTER ROUTINE
$HEAR:	MOVEM	0,$TACA0#
	SKIPE	USER		;EXEC MODE ?
	JRST	$TTUSR		;NO..USER MODE INPUT
	JSR	$TYI		;KEY BEEN STRUCK?
	JRST	@$TACA0		;NO
	JSR	$TYO		;ECHO CHAR
	ANDI	0,177
	CAIE	0,15		;IS IT CR ?
	JRST	.+4		;NO
	MOVEM	0,$CHRIN#	;SAVE CHAR
	MOVEI	0,012		;ECHO LF
	JSR	$TYO
	MOVE	0,$CHRIN	;RESTORE CHAR
	CAIN	0,003		;IS IT ^C ?
	JRST	$HEAR1		;YES, TERMINATE
$HEAR2:	JRST	.+3
$TTUSR:	TTCALL	0,0		;INPUT TTY, USER MODE
	ANDI	0,177		;CLEAR PARITY BIT
	CAIL	0,"A"+40	;CONVERT TO UPPER CASE
	CAILE	0,"Z"+40
	CAIA
	SUBI	0,40
	MOVEM	0,$CHRIN	;SAVE CHARACTER
	SKIPN	USER
	JRST	.+4
	CAIN	0,15		;IS IT CR ?
	TTCALL	0,0		;YES, GET RID OF LF
	MOVE	0,$CHRIN	;RESTORE CHARACTER
	AOS	$TACA0
	JRST	@$TACA0		;RETURN +2
	MOVEM	0,JOBOPC	;2-TERMINATED IN JOBOPC
	JRST	@CNTLC		;3-TERMINATE
$HEAR1:	JSP	0,.-2		;1-SAVE PC WHERE
	JRST	$HEAR2		;4-HERE IF CONTINUED
;YES/NO TYPE-IN ROUTINE
;ACCEPTS Y OR N
;FOR YESNO, Y IS SKIP RETURN, CARRAGE RETURN IS DIRECT RETURN
;FOR NOYES, N IS SKIP RETURN, CARRAGE RETURN IS DIRECT RETURN
;'Y OR N <CR> - ' ASKED UPON ENTRY

$NOYES:	MOVEM	0,$TACC0#
	MOVEI	0,1		;INIT FOR N ANSWER
	JRST	.+3
$YESNO:	MOVEM	0,$TACC0
	MOVEI	0,0		;INIT FOR Y ANSWER
	MOVEM	1,$TACC1#
	MOVEM	2,$TACC2#
	MOVE	2,0
$YN1:	SETZM	$PTINH
	TTICHR			;INPUT FROM TTY
	JRST	$YN2		;NO RESPONSE
	CAIN	0,"Y"		;IS IT A 'Y' ?
	TRCA	2,1	;YES-COMPLIMENT RETURN
	CAIN	0,"N"		;OR AN 'N' ?
	CAIA			;YES
	JRST	$YN5		;NEITHER, CR?
	TTICHR
	JRST	$YN2
$YN5:	CAIE	0,15
	JRST	$YN3
	ADDM	2,$TACC0
$YN2:	MOVE	2,$TACC2
	MOVE	0,1
	MOVE	1,$TACC1
	JRST	@$TACC0

$YN3:	SKIPE	USER
	TTCALL	11,0		;IF USER, CLEAR TYPE-IN BUFFER
	MOVEI	CRLF
	PNTAF
	MOVEI	[ASCIZ/Y OR N /]
	PNTALF
	JRST	$YN1

	26215			;'Y' (CR)
	23415			;'N' (CR)
	26215			;'Y' (CR)
;OCTAL-DECIMAL-CONVERT TYPE-IN ROUTINE
;ACCEPTS 0 TO 12 OCTALS, 0 TO 11 DECIMALS, 0 TO 9 CONVERT CHARACTERS
;NUMBER RETURNED IN AC0.

$TPCNV:	MOVEM	0,$TACD0#
	MOVEI	2		;SET INDEX TO CONVERT
	JRST	.+6
$TPDEC:	MOVEM	0,$TACD0
	MOVEI	1		;SET INDEX TO DECIMAL
	JRST	.+3
$TPOCT:	MOVEM	0,$TACD0
	MOVEI	0		;SET INDEX TO OCTAL
	MOVEM	1,$TACD1#	;SAVE AC'S
	MOVEM	2,$TACD2#
	MOVEM	3,$TACD3#
	MOVE	3,0
	SETZB	1,2		;CLEAR DATA REG, CHAR COUNTER
	SETZM	$TYPNB#		;CLEAR ERR NUMBER
	SETZM	$NEGF#		;CLEAR NEGATE FLAG
	SETZM	$CNVD#		;CLEAR DECIMAL CONVERT FLAG

;INPUT AND COMPUTE NUMBER

$TYPLP:	TTICHR			;INPUT FROM TTY
	JRST	$TPERR		;NO RESPONSE, GO TO ERROR EXIT
	CAIN	0,"-"		;IS IT MINUS ?
	JRST	$NEGX		;YES
	CAIN	0,"."		;IS IT PERIOD ?
	JRST	$CNVX		;YES
	CAIN	0,15		;IS IT CR ?
	JRST	$TPEXT		;YES
	CAIN	0,","		;IS IT COMMA ?
	JRST	$TPEXT		;YES
	CAIL	0,"0"		;A VALID DIGIT ?
	XCT	$TPCK(3)
	JRST	$TPERR		;NO
	AOS	2		;INCREMENT CHARACTER COUNTER
	XCT	$TPMUL(3)	;MULT BY OCTAL/DECIMAL BASE, SHIFT CONVERT
	SUBI	60		;ADD IN NEW CHAR
	ADD	1,0
	JRST	$TYPLP		;REPEAT TILL CR OR COMMA
;CHECK FOR PROPER AMOUNT OF CHARACTERS

$TPEXT:	XCT	$TPNBR(3)	;PROPER NUMBER OF CHARACTERS
	JRST	$TPERR		;NO
	CAIN	3,2		;CONVERT ?
	JRST	$CNVX1		;YES
$TPEX1:	MOVE	3,$TACD3	;RESTORE AC'S
	MOVE	2,$TACD2
	MOVE	0,1		;PUT NUMBER IN AC0
	SKIPE	$NEGF		;NEGATE ?
	MOVN	0,1		;YES
	MOVE	1,$TACD1
	AOS	$TACD0
	JRST	@$TACD0		;RETURN +2

$TPERR:	MOVE	3,$TACD3	;ERROR EXIT
	MOVE	2,$TACD2
	MOVEM	1,$TYPNB	;SAVE NUMBER
	MOVE	1,$TACD1
	JRST	@$TACD0

;NUMBER COMPUTING CONSTANTS

$TPCK:	CAILE	0,"7"		;OCTAL NUMBER CHECK
	CAILE	0,"9"		;DECIMAL NUMBER CHECK
	CAILE	0,"9"		;CONVERT NUMBER CHECK
$TPMUL:	IMULI	1,^D8		;OCTAL BASE MULTIPLIER
	IMULI	1,^D10		;DECIMAL BASE MULTIPLIER
	LSH	1,4		;CONVERT SHIFT
$TPNBR:	CAILE	2,^D12		;ACCEPT UP TO 12 OCTALS
	CAILE	2,^D11		;ACCEPT UP TO 11 DECIMALS
	CAILE	2,^D9		;ACCEPT UP TO 9 CONVERT
$NEGX:	SKIPE	2		;1ST CHAR ?
	JRST	$TPERR		;NO, ERROR
	SETOM	$NEGF		;YES, SET NEGATE FLAG
	JRST	$TYPLP		;GET NEXT CHAR

$CNVX:	CAIE	3,2		;PERIOD, IN CONVERT ?
	JRST	$TPERR		;NO, ERROR
	SETOM	$CNVD		;YES, SET DECIMAL FLAG
	JRST	$TYPLP		;GET NEXT CHAR

;CONVERT CONVERSION ROUTINE

$CNVX1:	MOVEI	2,^D9		;NINE DIGITS
	SETZM	0
	SKIPE	$CNVD		;OCTAL OR DECIMAL ?
	JRST	$CNVX2		;DECIMAL
	TDNE	1,[421042104210]	;OCTAL
	JRST	$TPERR		;OCTAL ERROR, 8 OR 9 INPUT
	LSH	1,1		;SQUEEZE OUT 4TH BIT
	LSHC	0,3		;COMPACT INTO OCTAL
	SOJN	2,.-2		;COMPLETED ?
	MOVE	1,0
	JRST	$TPEX1

$CNVX2:	SETZM	3		;DECIMAL
	SETZM	0
	IMULI	3,^D10		;MULTIPLY BY DECIMAL BASE
	LSHC	0,4		;UNPACK NEXT DIGIT
	ADD	3,0		;ADD IN
	SOJN	2,.-4		;COMPLETED ?
	MOVE	1,3
	JRST	$TPEX1
>
	XLIST
	IFDEF	SIXIN,<LIST
SUBTTL	SIXBIT TYPE-IN SUBROUTINE, X00R, DECEMBER 6,1971

;TELETYPE SIXBIT INPUT ROUTINE
;INPUTS UP TO SIX CHARACTERS, TERMINATES WITH A CR OR COMMA.
;SIXBIT WORD RETURNED IN AC0

$TSIXB:	MOVEM	0,$TSX0#
	MOVEM	1,$TSX1#
	MOVEM	2,$TSX2#
	MOVE	2,[POINT 6,1]
	MOVEI	1,0
$TSXB1:	TTICHR
	JRST	$TSXB3		;NO RESPONSE
	CAIN	0,15
	JRST	$TSXB2		;CR, TERMINATE
	CAIN	0,","
	JRST	$TSXB2		;COMMA, TERMINATE
	CAIL	0,"0"
	CAILE	0,"Z"
	JRST	$TSXB3		;ERROR
	CAILE	0,"9"
	CAIL	0,"A"
	CAIA			;ALPHA-NUMERIC
	JRST	$TSXB3		;ERROR
	TRC	0,40		;CONVERT TO SIX-BIT
	TRNE	1,77
	JRST	$TSXB3		;TOO MANY CHAR'S
	IDPB	0,2		;PUT INTO WORD
	JRST	$TSXB1		;REPEAT

$TSXB2:	AOS	(P)		;RETURN + 2

$TSXB3:	MOVE	0,1		;SIXBIT WORD IN AC0
	MOVE	1,$TSX1
	MOVE	2,$TSX2
	RTN
>
	XLIST
	IFDEF	SIXOUT,<LIST
SUBTTL	SIXBIT PRINT SUBROUTINE, X00R, DECEMBER 6,1971

;PRINTS SIXBIT WORD IN AC0

$PTSXF:	MOVEM	2,$PTSX2#
	MOVEI	2,1		;SETUP FORCED PRINT INDEX
	JRST	.+3

$PNTSX:	MOVEM	2,$PTSX2
	MOVEI	2,0		;SETUP NORMAL PRINT INDEX
	MOVEM	1,$PTSX1#
	MOVE	1,0		;PUT SIXBIT WORD IN AC1

$PTSX4:	MOVEI	0,0
	LSHC	0,6		;GET NEXT CHAR INTO AC0
	ADDI	0,40		;CONVERT TO ASCII
	LSH	0,^D29		;POSITION
	MOVEM	0,$PTSX3#	;SAVE
	MOVEI	0,$PTSX3	;SETUP ADDRESS
	XCT	$PTSXI(2)	;PRINT
	JUMPN	1,$PTSX4	;LOOP TILL ALL PRINTED
	RTN			;EXIT

$PTSXI:	PNTA			;PRINT ASCII
	PNTAF			;PRINT ASCII FORCED

>
	XLIST
	IFDEF	PRINT,<LIST
SUBTTL	PRINT SUBROUTINE, X00R, DECEMBER 6,1971

;THIS IS A SUBROUTINE THAT PRINTS ASCII MESSAGES, DECIMAL NUMBERS
;OR A DESIGNATED AMOUNT OF OCTAL DIGITS.
;YOU ENTER THIS ROUTINE WITH AC0 CONTAINING THE ADDRESS OF THE ASCII
;MESSAGE OR THE OCTAL OR DECIMAL NUMBERS TO BE PRINTED.

;THE FOLLOWING MISCELLANEOUS PRINT CHARACTERS ARE INCLUDED
;TO FACILITATE PRINTING AND ARE CALLED AS FOLLOWS:
;	MOVEI	NAME
;	PNTA		;OR PNTAF
CRLF:	ASCII/
/
CRLF2:	ASCII/

/
COMMA:	ASCII/,/
PERIOD:	ASCII/./
SPACE:	ASCII/ /
TAB:	ASCII/	/
MINUS:
	ASCII/-/
PLUS:	ASCII/+/
	ASCII/*/
	ASCII/@/
	ASCII/(/
	ASCII/)/
BELL:	XWD	034000,0
QUEST:	ASCII/?/
	ASCII!/!
	ASCII/$/

;PRINT SUBROUTINE INITIALIZATION
;INITIALIZES CONTROL WORDS, AND TTY IF IN USER MODE

$PNTIN:	MOVEM	0,$ACB0#
	SETZM	$TYOFF#		;CLEAR TTY INITED FLAG
	SETZM	$DVOFF#		;CLEAR DEVICE INITED FLAG
	SETZM	PDISF#		;CLEAR PRINT DISABLED FLAG
	SETZM	$PTINH#		;CLEAR PRINT 'TYPE-IN INHIBIT' FLAG
	SETZM	PNTFLG#		;CLEAR IN PRINT FLAG
	SETOM	PNTSPC#		;SET PRINT SPACE FLAG
	MOVNI	0,^D5000	;SET PRINT ENABLE TO 5000 LINES
	MOVEM	0,PNTENB
	SKIPE	USER		;EXEC MODE ?
	JSP	$USERM		;NO, USER MODE TTY INIT
	JRST	@$ACB0
	IFNDEF	SLDCDE,<
$PRNTF:	0			;TO PROVIDE SOLID CODE, MOVE THIS>
	SETOM	PNTFLG		;SET IN PRINT FLAG
	MOVEM	0,$PACA0#	;FORCE PRINTOUT
	MOVE	0,$PRNTF
	MOVEM	0,$PRINT
	SETOM	$PNTTY#
	JRST	$PNTIA
	IFNDEF	SLDCDE,<
$PRINT:	0			;TO PROVIDE SOLID CODE, MOVE THIS>
	SETOM	PNTFLG		;SET IN PRINT FLAG
	MOVEM	0,$PACA0	;SAVE AC 0
	SETZM	$PNTTY
	SKIPL	PNTENB#
	JRST	$PNTIB		;DON'T PRINT OVER 5000(10) LINES
	MOVE	0,CONSW
	IFDEF	TOGGLE,<
	SWITCH			;READ DATA SWITCHES >
	TLNN	0,NOPNT		;NO PRINT SWITCH SET
	JRST	.+3
	MOVE	0,$PACA0
	JRST	@$PRINT

;DETERMINE PRINT MODE
$PNTIA:	MOVEM	1,$PACA1#	;SAVE AC1.
	MOVEM	2,$PACA2#	;SAVE AC2.
	MOVEM	3,$PACA3#	;SAVE AC3.
	MOVEM	4,$PACA4#	;SAVE AC4.
	MOVE	0,$PACA0	;RESTORE AC0
	SETZM	$PNT#		;CLEAR PRINT HALF WORDS FLAG
	MOVE	1,$PRINT	;MOVE C(JSR+1) INTO AC1.
	MOVE	2,-1(1)		;MOVE THE JSR INTO AC2.
	ROT	2,15		;GET X
	ANDI	2,17		;OUT OF THE JSR.
	CAIN	2,17		;X=17?
	JRST	$ASCPN-1	;YES. PRINT MORE THAN 1 WORD.
	JUMPE	2,$ASCPN	;X=0? YES. GO PRINT 1 WORD.
	CAIN	2,15		;X=15?
	JRST	$DECPN		;YES, PRINT DECIMALS
	CAIN	2,16		;X=16?
	JRST	$DECSP		;YES, PRINT DECIMALS, LEADING SPACES
	CAIN	2,13		;X=13?
	JRST	$PNTI3		;YES, PRINT OCTALS, 6 SP 6
;OCTAL PRINTOUT ROUTINE
;PRINTS NUMBER IN AC0
$PNTI1:	MOVE	3,2		;MOVE X INTO AC3.
	ROT	0,-3		;ROT OCTAL NUM 3 PLACES
	SOJN	3,.-1		;X AMOUNT OF TIMES.
$PNTI2:	MOVEI	1,6		;PUT 6 INTO AC1 SO THAT
	ROTC	0,3		;C(AC1) AFTER THE ROTC WILL BE 60
	JSP	3,$TOUT		;PLUS NUMBER TO BE PRINTED..GO PNT NUM.
	SOJN	2,$PNTI2	;SUB 1 FROM X...PRINT UNTIL X=0.
	MOVEM	1,$PNTSV#	;SAVE NUMBER
	SKIPN	PNTSPC
	JRST	.+3
	MOVEI	1,40		;AT THIS POINT WE HAVE PRINTED
	JSP	3,$TOUT		;X AMOUNT OF NUMBER(S) AND NOW A SPACE.
	SKIPN	$PNT#		; PRINT 6 SP 6 FLAG SET?
	JRST	$PNTI4		;NO, EXIT
	MOVE	1,$PNTSV	;RESTORE NUMBER
	MOVEI	2,6		;SETUP FOR 2ND HALF
	SETZM	$PNT		;CLEAR PRINT SPACE FLAG
	JRST	$PNTI2		;PRINT REST OF NUMBER

$PNTI3:	MOVEI	3,14		;SETUP FOR LH WORD
	MOVEI	2,6		;SETUP FOR FIRST HALF
	SETOM	$PNT		;SET PRINT 6 SP 6 FLAG
	SETOM	PNTSPC
	JRST	$PNTI1+1	;PRINT FIRST HALF NUMBER

;PRINT ROUTINE EXIT
$PNTI4:	SETZM	$PNTTY
	MOVE	0,$PACA0	;RESTORE AC0.
	MOVE	1,$PACA1	;RESTORE AC1.
	MOVE	2,$PACA2	;RESTORE AC2.
	MOVE	3,$PACA3	;RESTORE AC3.
	MOVE	4,$PACA4	;RESTORE AC4.
	SETZM	PNTFLG		;CLEAR IN PRINT FLAG
	JRST	@$PRINT		;RETURN.

$PNTIB:	SKIPE	PDISF#		;FIRST TIME PRINT DISABLED
	JRST	@$PRINT		;NO
	SETOM	PDISF
	MOVEM	1,$PACA1	;SAVE AC'S
	MOVEM	2,$PACA2
	MOVEM	3,$PACA3
	MOVEM	4,$PACA4
	SETOM	$PNTTY
	MOVEI	[ASCIZ/
**********
EXCEEDED ALLOWED PRINTOUTS, ONLY FORCED PRINTOUTS FROM THIS POINT
**********
/]
	JRST	$ASCPN-1	;PRINT ASCII
;ASCII PRINTOUT ROUTINE
;PRINTS ASCII WHOSE ADDRESS IS IN AC0

	SETOM	$PNT#		;SET PRINT MORE THAN 1 WORD FLAG.
$ASCPN:	MOVEM	0,$POINT#	;SAVE ADDRESS OF ASCII MESSAGE.
$ASCP1:	MOVEI	2,5		;5 = NUM OF ASCII CHAR. IN A WORD.
	MOVE	0,@$POINT	;C(AC0) = FIRST WORD OF ASCII MESS.
$ASCP2:	SETZ	1,		;CLEAR AC1.
	ROTC	0,7		;C(AC1) = CHAR TO BE PRINTED.
	JUMPE	1,$PNTI4	;CHAR = 0?..NO MORE CHAR..LEAVE.
	JSP	3,$TOUT		;PRINT A CHAR.
	SOJN	2,$ASCP2	;PNT ALL CHAR FROM THIS WORD?
	AOS	$POINT		;YES. INC TO GET NEXT WORD.
	SKIPN	$PNT		;PNT MORE THAN ONE CHAR FLAG SET?
	JRST	$PNTI4		;NO..LEAVE.
	JRST	$ASCP1		;YES...RETURN TO PNT NEXT WORD.

;DECIMAL PRINTOUT ROUTINE
;PRINTS NUMBER IN AC0

$DECSP:	SETOM	$PNT		;SET LEADING SPACES PRINT CONTROL
$DECPN:	MOVEM	17,$PAC17#	;SAVE AC17
	MOVE	17,$PLST	;SETUP PUSH LIST
	PUSHJ	17,$RADIX	;GO TO DECIMAL-ASCII CONVERSION
	MOVE	17,$PAC17	;RESTORE AC17
	JRST	$PNTI4

$RADIX:	MOVEI	2,^D10		;SETUP DIGIT COUNTER
	LSHC	0,-^D35		;SHIFT RIGHT 35 BITS INTO AC1
	LSH	1,-1		;VACATE AC1 SIGN BIT
	DIVI	0,^D10		;DIVIDE DOUBLE LENGTH INTERGER BY 10
	HRLM	1,(17)		;SAVE DIGIT
	SOS	2		;COUNT DIGIT
	JUMPE	0,$LDSPS	;ALL DIGITS FORMED?
	PUSHJ	17,$RADIX+1	;NO, COMPUTE NEXT ONE
$DECP1:	HLRZ	1,(17)		;YES, RETRIEVE DIGIT
	ADDI	1,60		;CONVERT TO ASCII
	JSP	3,$TOUT		;TYPE-OUT
	POPJ	17,		;GET NEXT/EXIT

$LDSPS:	SKIPN	$PNT		;LEADING SPACES PRINT SET?
	JRST	$DECP1		;NO
	SOJL	2,$DECP1	;SPACES COMPLETE ?
	MOVEI	1,40		;NO, PRINT LEADING SPACE
	JSP	3,$TOUT
	JRST	.-3		;CHECK FOR NEXT

;COMPUTE CHARACTER PARITY, COUNT LINES

$TOUT:	MOVEM	0,$PACB0#	;SAVE AC0.
	SKIPE	USER
	JRST	$TOUTB		;DON'T COMPUTE PARITY IN USER MODE
	XLIST
	IFDEF	EXCASB,< LIST
	JSR	$TYI		;KEY STRUCK ?
	JRST	$TOUTX		;NO
	ANDI	0,177
	CAIN	0,003		;IS IT ^C ?
	JRST	$TUTX2		;YES, TERMINATE
	IFDEF	ALTGO,<
	JSP	4,$TUTX1	;GO CHECK IF ALT-MODE
	JRST	.+2		;NO
	JRST	$TUTX3		;YES, GO TO USER'S ROUTINE >
	MOVEI	0,336		;^
	JSR	$TYO
	MOVEI	0,317		;O
	JSR	$TYO
	MOVEI	0,15
	JSR	$TYO
	MOVEI	0,12
	JSR	$TYO
	SETOM	$PTINH
$TOUTX:	SETZ	0,		;CLEAR AC0..USE AS BIT CNTR.
	MOVE	4,1		;PUT CHAR INTO AC4.
	ANDI	4,-1(4)		;THIS WILL CLEAR 1 BIT AT A TIME.
	SKIPE	4		;ALL THE BITS?
	AOJA	0,.-2		;NO. RETURN TO DO ANDI AGAIN.
	TRNN	0,1		;BIT CNTR ODD?
	TRC	1,200		;COMP HI ORDER BIT..EVEN PAR. >
	LIST
$TOUTB:	MOVE	CONSW
	AOS	$CARCT#		;INC CHAR CNTR.
	CAIE	1,215		;CHAR A CR?
	JRST	.+4		;NO
	SETZM	$PTINH
	AOS	PNTENB		;COUNT LINES, TILL NO MORE
	SETZM	$CARCT		;CLR CHAR CNTR.
	CAIN	1,12		;IS CHAR A LF?
	SETZM	$CARCT		;YES. CLR CHAR CNTR.
	SKIPE	$PNTTY
	JRST	.+3		;DON'T CHEK NON-PNT SW IF FORCED PRINTOUT
	TLNE	0,NOPNT		;IS NON PNT SWITCH ON?
	JRST	(3)		;YES. RETURN.
	SKIPE	USER		;EXEC MODE ?
	JRST	$TOUT2		;NO..USER MODE GO DO OUTPUT.
	JRST	$TOUTC		;YES
$TOUTA:	MOVE	0,$PACB0	;RESTORE AC0
	JRST	(3)		;RETURN


	IFDEF	EXCASB,<
	IFDEF	ALTGO,<
$TUTX1:	MOVEM	4,$TALT0
	JRST	$TALTM+3	>
	MOVEM	0,JOBOPC	;2-TERMINATED IN JOBOPC
	JRST	@CNTLC		;3-TERMINATE
$TUTX2:	JSP	0,.-2		;1-SAVE PC WHERE
	JRST	$TOUTX		;4-HERE IF CONTINUED
	IFDEF	ALTGO,<
	MOVEM	0,JOBOPC	;2-TERMINATED IN JOBOPC
	JRST	@ALTMGO		;3-TERMINATE
$TUTX3:	JSP	0,.-2		;1-SAVE PC WHERE
	JRST	$TOUTX		;4-HERE IF CONTINUED	>>
	IFNDEF	EXCASB,<$TOUTC:	ERRHLT	>
	IFNDEF	USRASB,<$USERM:	ERRHLT
	$TOUT2:	ERRHLT	>
	XLIST
	IFDEF	EXCASB,<LIST
;EXEC MODE CHARACTER OUTPUT

$TOUTC:	TLNE	0,PNTLPT	;PRINT ON LINE PRINTER ?
	JRST	$TOUT1		;YES
$PNTY1:	SKIPE	$PTINH		;TYPE-IN INHIBIT ?
	JRST	$TOUTA		;YES
	CAIN	1,11		;IS CHAR A TAB?
	JRST	$TABS		;YES. TURN TAB INTO SPACES.
	EXCH	0,1
	CAIE	0,215		;IS CHAR A CR ?
	JRST	.+2		;NO
	JSR	$TYO		;YES, OUTPUT CR CR
	JSR	$TYO		;PRINT A CHAR.
	JRST	$TOUTA

;EXEC MODE LPT OUTPUT
$TOUT1:	MOVEM	1,$PNTYC#	;SAVE CHAR
	LSH	1,1		;C(AC1) HAS TO BE LEFT JUSTIFIED.
	ANDI	1,376		;CLEAR PARITY BIT
	DATAO	LPT,1		;PRINT CHAR ONTO LPT.
	MOVEI	1,^D<<1000*500>/7>		;ABOUT 500 MS.
	CONSO	LPT,100		;LPT DONE?
	SOJG	1,.-1		;NO.
	SKIPN	$PNTTY		;SKIP IF MSG ALSO FORCED TO TTY
	JUMPG	1,$TOUTA	;RETURN IF LPT NOT HUNG, ELSE ALL TO TTY
	MOVE	1,$PNTYC
	JRST	$PNTY1

;TELETYPE TABS CONVERSION

$TABS:	SOS	1,$CARCT	;PUT CHAR CNT - 1 TAB INTO AC1.
	SUBI	1,10		;DIVIDE
	JUMPGE	1,.-1		;BY 10.
	MOVN	1,1		;C(AC1) NOW = NO. OF SPACES TO PNT.
	MOVEM	0,$PNTYC
	MOVEI	0,240
$TABS1:	JSR	$TYO		;SEND A SPACE.
	AOS	$CARCT		;INCREMENT CHAR CNTR.
	SOJG	1,$TABS1	;DECREMENT SPACES CNTR.
	MOVE	0,$PNTYC
	JRST	$TOUTA		;RETURN.
;TYPE OUT A CHARACTER IN AC 0

$TYO:	0
	SKIPE	KSFLG		;A KS?
	JRST	$TYO2		;YES
	SKIPG	KAILFL		;A KL?
	JRST	$TYO1		;NO
	ANDI	0,377
	ADDI	0,.DTMTO	;ADD COMMAND
	SETZM	DTEMTD
	MOVEM	0,DTECMD
	CONO	DTE,TO11DB	;WAKE THE 11
	SKIPN	DTEMTD		;WAIT UNTIL THE 11 GETS IT
	JRST	.-1
	JRST	@$TYO		;RETURN
$TYO1:	DATAO	TTY,0		;OUTPUT CHAR KA/KI STYLE
	CONSZ	TTY,20		;WAIT FOR DONE
	JRST	.-1
	JRST	@$TYO		;RETURN
$TYO2:	ANDI	0,377		;ONLY CHAR
	IORI	0,400		;SET CHAR VALID BIT
	MOVEM	0,CTYOWD	;PUT CHAR WHERE 8080 WANTS IT
	CONO	APR,12000	;INTERRUPT HIM
	SKIPE	CTYOWD		;DID HE TAKE IT?
	JRST	.-1		;NO--WAIT
	JRST	@$TYO		;RETURN

;INPUT A CHARACTER AND SKIP IF A CHARACTER IS AVAILABLE
; CHARACTER IN AC 0

$TYI:	0
	SKIPE	KSFLG		;A KS?
	JRST	$TYI3		;YES
	SKIPG	KAILFL		;A KL?
	JRST	$TYI1		;NO
	SKIPN	DTEMTI		;A CHARACTER AVAILABLE?
	JRST	@$TYI		;NO, NON-SKIP RETURN
	SETZM	DTEMTI		;CLEAR FLAG
	MOVE	0,DTEF11	;GET THE CHARACTER
	JRST	$TYI2		;AND RETURN
$TYI1:	CONSO	TTY,40		;A KEY STRUCK?
	JRST	@$TYI		;NO, NON-SKIP RETURN
	DATAI	TTY,0		;READ THE CHARACTER
$TYI2:	AOS	$TYI		;SKIP
	JRST	@$TYI		;RETURN>
$TYI3:	SKIPN	CTYIWD		;CHAR THERE YET?
	JRST	@$TYI		;NO--NON-SKIP RETURN
	MOVE	0,CTYIWD	;GET CHAR
	SETZM	CTYIWD		;FLAG WE GOT IT
	JRST	$TYI2		;GIVE SKIP RETURN

	XLIST
	IFDEF	USRASB,<LIST
;USER MODE TELETYPE OUTPUT

$TOUT2:	TLNE	0,PNTLPT	;IS LPT PRINT SWITCH UP ?
	JRST	$TOUT3		;YES, GO PRINT ON LOGICAL DEVICE
	DROPDV			;CLOSE DEV IF SWITCH CHANGED
	SKIPN	$TYOFF		;TTY BEEN INITED YET ?
	JSP	$USERM		;NO, GO DO IT
	AOS	@$OUTTY+1	;SETUP SO IT LOOKS FOR ONE WORD
	AOS	$OUTTY+1	;THIS POINTS TO WHERE CHAR IS PUT
	MOVE	0,$CARCT
	CAIN	0,1		;FIRST CHAR IN LINE ?
	JRST	$TOUT4		;YES
$TOUT5:	ROT	1,-7		;MAKE C(AC1) FIRST CHAR IN WORD
	MOVEM	1,@$OUTTY+1	;PUT CHAR IN BUFFER
	OUTPUT	$TTYCH,		;DO OUTPUT
	JRST	$TOUTA		;GO RESTORE AC0 AND RETURN

$TOUT4:	SKIPL	MONCTL		;SYSTEM EXERCISER
	JRST	$TOUT5		;NO
	MOVE	QUEST
	MOVEM	0,@$OUTTY+1	;PRECEDE LINE WITH ?
	OUTPUT	$TTYCH,
	AOS	@$OUTTY+1
	AOS	$OUTTY+1
	JRST	$TOUT5

;USER MODE LOGICAL DEVICE OUTPUT
$TOUT3:	SKIPN	$DVOFF		;DEVICE BEEN INITED YET ?
	JSP	$INTDV		;NO, GO DO IT
	JSP	$PUTCR		;GO OUTPUT CHAR
	IFDEF	DSKUPD,<
	SKIPN	$CARCT
	JSP	$ITDV1		;UPDATE, SETUP FOR INPUT/OUTPUT >
	SKIPN	$PNTTY		;SKIP IF MESSAGE ALSO FORCED TO TTY
	JRST	$TOUTA
	JRST	$TOUT2+3

;OUTPUT TO LOGICAL DEVICE

$PUTCR:	MOVEM	0,$PACC0#
	SOSG	$OBUF+2		;INCREMENT BYTE COUNT
	JRST	$PUTBF		;NO MORE ROOM, OR FIRST CALL AFTER INIT
$PTNXT:	IDPB	1,$OBUF+1	;STORE CHAR IN AC1
	JRST	@$PACC0		;RETURN
$PUTBF:	OUT	$DEVCH,		;CALL MONITOR TO EMPTY BUFFER
	JRST	$PTNXT
;TELETYPE INITIALIZATION, USER MODE

$USERM:	MOVEM	0,$ACC0#
	HLRZ	JOBSA
	CAIL	END
	JRST	.+4
	MOVE	[XWD END,BEGIN]
	MOVEM	JOBSA		;SETUP JOB DATA AREA
	HLRZM	JOBFF
	MOVEI	EXIT
	MOVEM	JOBREN		;SETUP REENTER TO CLOSE PRINT FILE
	INIT	$TTYCH,0	;TTY CHANNEL, ASCII MODE
	SIXBIT	/TTY/
	XWD	$OUTTY,0
	JRST	.-3
	OUTBUF	$TTYCH,1
	OUTPUT	$TTYCH,
	SETOM	$TYOFF		;SET TTY INITED FLAG
	JRST	@$ACC0

;LOGICAL DEVICE INITIALIZATION, PHY DEV ASSIGNED AT RUN TIME

$INTDV:	MOVEM	0,$PACD0#
	SETZM	$UPDTF#
	MOVE	0,PNTNAM	;SETUP LOGICAL OUTPUT FILE NAME
	MOVEM	0,$OUTNM
	IFDEF	DSKUPD,<
	MOVEM	$INNM		;SETUP LOGICAL FILE INPUT NAME >
	INIT	$DEVCH,0	;ASCII MODE, DEV CHANNEL
	SIXBIT	/DEV/		;LOGICAL DEVICE, LPT,DSK,DTAX
	XWD	$OBUF,		;OUTPUT ONLY
	JRST	$OERR1		;DEV NOT AVAIL, ERROR
	OUTBUF	$DEVCH,1	;SETUP OUTPUT BUFFER
	ENTER	$DEVCH,$OUTNM	;INIT OUTPUT FILE
	JRST	$OERR2		;NO DIR ROOM, ERROR
	SETOM	$DVOFF		;SET DEVICE INITED FLAG
	IFDEF	DSKUPD,<
	MOVE	0,[SIXBIT/DEV/]
	CALL	0,[SIXBIT/DEVCHR/]
	TLC	0,200007
	TLNE	0,776737	;IS DEVICE A DSK ?
	JRST	@$PACD0		;NO
	SETOM	$UPDTF		;YES	>
	JRST	@$PACD0
;USER MODE CLOSE FILE

$DRPDV:	MOVEM	0,$PACE0#
	SKIPN	$DVOFF		;DEVICE INITED?
	JRST	@$PACE0		;RETURN
	CLOSE	$DEVCH,		;CLOSE FILE
	STATZ	$DEVCH,740000	;RECHECK FINAL ERROR BITS
	TTCALL	3,[ASCIZ/
**********
ERROR DURING PRINT CLOSE FILE
**********
/]
	RELEAS	$DEVCH,		;RELINQUISH DEVICE, WRITE DIRECTORY
	SETZM	$DVOFF
	JRST	@$PACE0

$OUTER:	TTCALL	3,[ASCIZ/
**********
ERROR DURING PRINT OUTPUT
**********
/]
	CALL	1,[SIXBIT/EXIT/]	;ERROR, QUIT

$OERR1:	TTCALL	3,[ASCIZ/
LOGICAL DEVICE 'DEV' NOT ASSIGNED/]
	JRST	$OUTER

$OERR2:	TTCALL	3,[ASCIZ/
NO DIRECTORY ROOM/]
	JRST	$OUTER

	XLIST
	IFDEF	DSKUPD,<LIST
;UPDATE, REINIT FOR INPUT & OUTPUT (ONLY IF DSK)

$ITDV1:	MOVEM	0,$PACG0#
	SKIPN	$UPDTF
	JRST	@$PACG0
	DROPDV
	INIT	$DVCH1,0
	SIXBIT	/DEV/
	$IBUF
	JRST	$OERR1		;ERROR, DEV NOT ASSGND/AVAIL
	INBUF	$DVCH1,1
	LOOKUP	$DVCH1,$INNM
	JRST	$OERR3
	JSP	$INTDV		;REINIT OUTPUT FILE
	JSP	$GETCR		;INPUT/OUTPUT TILL EOF
	JSP	$PUTCR
	JRST	.-2		;CONT FROM HERE ON EOF
$INEOF:	SETOM	$DVOFF
	JRST	@$PACG0

$GETCR:	MOVEM	$PACF0#
$GETNX:	SOSLE	$IBUF+2		;DECREMENT BYTE COUNT
	JRST	$GETOK
	IN	$DVCH1,		;GET NEXT BUFFER
	JRST	$GETOK
	STATZ	$DVCH1,740000
	JRST	$OERR4		;ERROR
	JRST	$INEOF		;ASSUME END-OF-FILE

$GETOK:	ILDB	1,$IBUF+1	;GET CHARACTER FROM BUFFER
	JUMPN	1,@$PACF0	;RETURN IF NOT NULL
	JRST	$GETNX		;IGNORE NULL, GET NEXT CHAR

$OERR3:	TTCALL	3,[ASCIZ?
UPDATE LOOKUP/ENTER FAILURE?]
	JRST	$OUTER

$OERR4:	TTCALL	3,[ASCIZ/
UPDATE INPUT ERROR/]
	JRST	$OUTER
>>>
	LIST
SUBTTL	RESERVED STORAGE, X00R, DECEMBER 6, 1971

;END OF PROGRAM CONSTANTS
	LIT
	0

;END OF PROGRAM VARIABLES
	XLIST
	IFDEF	PRINT,<
	IFDEF	USRASB,< LIST
$OUTTY:	BLOCK	3		;TTY OUTPUT BUFFER HEADER
$OBUF:	BLOCK	3		;LOGICAL FILE OUTPUT BUFFER HEADER
$OUTNM:	SIXBIT	/PRINT/		;FILE NAME
	SIXBIT	/PNT/		;FILE NAME EXTENSION
	BLOCK	2
	IFDEF	DSKUPD,<
$IBUF:	BLOCK	3
$INNM:	SIXBIT	/PRINT/
	SIXBIT	/PNT/
	BLOCK	2	>>
	LIST
$PLST:	XWD	$PLST-$PLSTE,$PLST
	BLOCK	20
$PLSTE:	0	>

CNTLC:	BEGIN			;CONTROL C TERMINATION ADDRESS
ALTMGO:	BEGIN			;ALTMODE TERMINATION ADDRESS
MONSV:	BLOCK	540

	XLIST
	IFDEF	PSHLST,<LIST
PLIST:	XWD PLIST-PLISTE,PLIST
	BLOCK	PSHLST	;40 MIN
PLISTE:	0	>
	XLIST
	IFDEF	MEMMAP,<LIST
MEMSIZ:	BLOCK	400		;XXX7 INTERLV MAP STORAGE
MEMSZ1:	BLOCK	400		;XXX6 INTERLV MAP STORAGE
MEMSZ2:	BLOCK	400		;XXX5 INTERLV MAP STORAGE
MEMSZ3:	BLOCK	400		;XXX4 INTERLV MAP STORAGE
	0	>
	XLIST
	IFDEF	INTRPT,<LIST
POWER:	BLOCK	20	>
	XLIST
	IFDEF	DEBUG,<LIST
	BLOCK	DEBUG	>
	PURGE	DEBUG
	LIST
;PROGRAM VARIABLE WORDS
	VAR
	XLIST
	IFDEF	PGMEND,<LIST
END:	0
END	>
	LIST