Google
 

Trailing-Edge - PDP-10 Archives - klad_sources - klad.sources/dskeam.mac
There are no other files named dskeam.mac in the archive.
SUBTTL	PROGRAM INITIALIZATION

PGMNAM:	ASCIZ/
DECSYSTEM 2020 PAGING HARDWARE DIAGNOSTIC (DSKEA)
/
START:	MOVEI	.
	MOVEM	TESTPC
	SETOM	CSHFLG		;DON'T USE CACHE
	SETOM	PVPAGI		;MUST BE PAGED
	PGMINT			;INIT SUBROUTINES
	MOVEI	500000
	MOVEM	KLUBRX#
	MOVE	LUUOI
	MOVEM	LUUOISV#
	MOVE	LPGFTR
	MOVEM	PGFAIL#
	MOVE	LKNTRP
	MOVEM	MUUOER
	MOVE	LTRP3T
	MOVEM	LTRP3SV#
	MOVE	LPDOVT
	MOVEM	LPDOVSV#
	MOVE	LAROVT
	MOVEM	LAROVSV#
	SETZM	MXFLG#		;CLEAR TEST MAX FLAG
STARTA:	SETZM	SCOPE		;PRESET ERROR REPEAT SWITCH
	SETZM	ERRPC		;PRESET ERROR PC STORAGE
	SWITCH
	MOVEI	AC,^D10		;SETUP REPEAT FOR 10 SUBLOOPS
	TLNN	RELIAB		;FAST CYCLE MODE ?
	MOVEI	AC,1		;YES, SUBLOOP JUST ONCE
	MOVEM	AC,RPEAT#
	JRST	EBRCK0-2

SFSRT1:	SETZM	PASCNT		;SPECIAL FEATURE START
	SETZM	ERRTLS
	JRST	BEGIN1		;CLEAR PASCNT FOR MAX ADR ?
SUBTTL	TEST EXEC BASE REGISTER

SALL
T=	SIXBTZ	BASE REGISTER TEST
LALL

;*LOAD EXEC BASE REGISTER WITH ALL ZERO'S WITH CONO
;*EXEC BASE REGISTER SHOULD THEN BE CLEAR.

	SUBTST
EBRCK0:	MOVE	REPT,RPEAT	;SETUP REPEAT COUNT
	MOVEI	COR,0
	CONO	PAG,(COR)		;LOAD EBR WITH 0'S
	CONI	PAG,ACT		;READ BACK
	CAME	COR,ACT		;COMPARE RESULTS
	ERROR	EBRCK0+1,13,COR,ACT,EBR,ALL  0'S

;*LOAD EXEC BASE REGISTER WITH ALL ONE'S
;*IF ANY BIT IS READ BACK THEN LOAD EBR SHOULD WORK.

	SUBTST
EBRCK1:	MOVEI	COR,3777
	CONO	PAG,(COR)	;LOAD EBR WITH ALL 1'S
	CONI	PAG,ACT		;READ BACK
	CONO	PAG,0
	SKIPN	ACT		;CHECK FOR ANY BIT SET
	ERROR	EBRCK1,13,COR,ACT,EBR,NO BITS SET

;*LOAD EXEC BASE REGISTER WITH TRAP ENABLE BIT

	SUBTST
EBRC1A:	MOVEI	COR,LTRPEN
	CONO	PAG,(COR)		;SET TRAP ENABLE
	CONI	PAG,ACT		;READ BACK
	CONO	PAG,LTRPEN
	CAME	COR,ACT
	ERROR	EBRC1A,13,COR,ACT,EBR,TRAP ENABLE BIT
	XX=0

	SUBTST
EBRCK2:	REPEAT	^D11,<
;*CHECK OUT EXEC BASE REGISTER ONE FLOP AT A TIME.
;*ON A FAILURE CHECK CORRESPONDING FLOP AND CONTROL SIGNALS.
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVEI	COR,XX
	CONO	PAG,(COR)		;LOAD EBR WITH A FLOATING ONE
	CONI	PAG,ACT		;READ BACK
	CONO	PAG,LTRPEN
	CAME	COR,ACT
	ERROR	.-6,13,COR,ACT,EBR,FLOATING 1>

;*LOAD EXEC BASE REGISTER WITH ALL ONE'S AS ADDITIONAL CHECK

EBRCK3:	MOVEI	COR,3777
	CONO	PAG,(COR)		;LOAD EBR WITH ALL 1'S
	CONI	PAG,ACT
	CONO	PAG,LTRPEN
	CAME	COR,ACT
	ERROR	EBRCK3,13,COR,ACT,EBR,ALL 1'S
	XX=0

	SUBTST
EBRCK4:	REPEAT	^D11,<
;*LOAD AND CHECK EXEC BASE REGISTER WITH A FLOATING ZERO
;*TO CHECK BIT INTERACTION.
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVEI	COR,3777-XX
	CONO	PAG,(COR)		;LOAD EBR WITH A FLOATING 0
	CONI	PAG,ACT
	CONO	PAG,LTRPEN
	CAME	COR,ACT
	ERROR	.-6,13,COR,ACT,EBR,FLOATING 0>
	REPTLP	EBRCK0+1
SUBTTL	TEST USER BASE REGISTER

;*LOAD USER BASE REGISTER WITH ALL ZERO'S.
;*USER BASE REGISTER SHOULD THEN BE CLEAR.

	SUBTST
UBRCK0:	MOVE	REPT,RPEAT
	MOVE	COR,[LLACBL!LLDUSB,,400000]
	DATAO	PAG,COR		;LOAD UBR WITH 0'S
	DATAI	PAG,ACT
	TRZ	COR,400000
	MOVSI	COR,@KLUBRX
	CAME	COR,ACT
	ERROR	UBRCK0+1,13,COR,ACT,UBR,ALL 0'S

;*LOAD USER BASE REGISTER WITH ALL ONE'S.
;*IF ANY BIT IS READ BACK THEN LOAD UBR SHOULD WORK.

UBRCK1:	MOVE	COR,[LLDUSB,,403777]
	DATAO	PAG,COR		;LOAD UBR WITH ALL ONES
	DATAI	PAG,ACT
	DATAO	PAG,[LLDUSB,,400000]
	TRZ	COR,400000
	HRLI	COR,@KLUBRX
	SKIPN	ACT		;CHECK FOR ANY BIT SET
	ERROR	UBRCK1,13,COR,ACT,UBR,NO BITS SET
	XX=0

	SUBTST
UBRCK2:	REPEAT	^D11,<
;*CHECK OUT USER BASE REGISTER ONE FLOP AT A TIME.
;*ON A FAILURE CHECK CORRESPONDING FLOP AND CONTROL SIGNALS
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVE	COR,[LLDUSB,,400000!XX]
	DATAO	PAG,COR		;LOAD UBR WITH A FLOATING 1
	DATAI	PAG,ACT
	DATAO	PAG,[LLDUSB,,400000]
	TRZ	COR,400000
	HRLI	COR,@KLUBRX
	CAME	COR,ACT
	ERROR	.-^D8,13,COR,ACT,UBR,FLOATING 1>
;*LOAD USER BASE REGISTER WITH ALL ONE'S AS ADDITIONAL CHECK.

UBRCK3:	MOVE	COR,[LLDUSB,,403777]
	DATAO	PAG,COR		;LOAD UBR WITH ALL ONES
	DATAI	PAG,ACT
	DATAO	PAG,[LLDUSB,,400000]
	TRZ	COR,400000
	HRLI	COR,@KLUBRX
	CAME	COR,ACT
	ERROR	UBRCK3,13,COR,ACT,UBR,ALL 1'S

	XX=0

UBRCK4:	REPEAT	^D11,<
;*LOAD USER BASE REGISTER WITH A FLOATING ZERO
;*CHECK BIT INTERACTION.
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVE	COR,[LLDUSB,,403777-XX]
	DATAO	PAG,COR		;LOAD UBR WITH A FLOATING 0
	DATAI	PAG,ACT
	DATAO	PAG,[LLDUSB,,400000]
	TRZ	COR,400000
	HRLI	COR,@KLUBRX
	CAME	COR,ACT
	ERROR	.-^D8,13,COR,ACT,UBR,FLOATING 0>
	REPTLP	UBRCK0+1

	XLIST
	REPEAT	0,<
SUBTTL	TEST BASE REGISTER MISCELLANEOUS

;*CLEAR EXEC AND USER BASE REGISTERS

	SUBTST
EUBRM0:	MOVE	REPT,RPEAT
	MOVE	COR,[LLDUSB,,LDEXCB]
	DATAO	PAG,COR		;MAKE SURE IT CLEARS OUT
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	COR,LDEXCB
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,FAILED TO CLEAR
	ERLOOP	EUBRM0+1

;*CHECK FAST MEMORY SELECTION FLIP-FLOPS

EUBRM1:	MOVSI	COR,LLDUSB!1B20
	DATAO	PAG,COR		;SELECT FM BLOCK 1
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	ACT,-1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,FM SELECT 1
	ERLOOP	.-7

EUBRM2:	MOVSI	COR,LLDUSB!2B20
	DATAO	PAG,COR		;SELECT FM BLOCK 2
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	ACT,-1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,FM SELECT 2
	ERLOOP	.-7

EUBRM3:	MOVSI	COR,LLDUSB!3B20
	DATAO	PAG,COR		;SELECT FM BLOCK 3
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	ACT,-1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,FM SELECT 3
	ERLOOP	.-7

;*CHECK USER ADDRESS COMPARE ENABLE FLIP-FLOP

EUBRM4:	MOVSI	COR,LLDUSB!1B22
	DATAO	PAG,COR		;SET USER ADR COMP ENABLE
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	ACT,-1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,USER ADR COMP
	ERLOOP	.-7

;*CHECK SMALL USER FLIP-FLOP

EUBRM5:	MOVSI	COR,LLDUSB!1B21
	DATAO	PAG,COR		;SET SMALL USER BIT
	DATAI	PAG,ACT
	TLZ	COR,LLDUSB
	TRZ	ACT,-1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,EUBR,SMALL USER
	ERLOOP	.-7

	REPTLP	EUBRM0+1
SUBTTL	TEST RELOAD COUNTER

SALL
T=	SIXBTZ	RELOAD COUNTER TEST
LALL

;*CLEAR RELOAD COUNTER

	SUBTST
RLDCT0:	MOVE	REPT,RPEAT
	SETZM	COR
	CONO	PAG,LTRPEN		;CLEAR RELOAD COUNTER
	CONI	PAG,ACT		;READ BACK
	TDZ	ACT,[-1,,777740] ;CLEAR OTHER BITS
	SKIPE	ACT		;RELOAD COUNTER SHOULD BE CLEAR
	ERROR1	13,COR,ACT,NOT CLEAR,
	ERLOOP	.-6

;*SET RELOAD COUNTER TO ALL ONES
;*CHECK FOR ANY BIT SET.

RLDCT1:	MOVEI	COR,37
	SKIPE	AM16RF		;ONLY 16 AM/SC ?
	MOVEI	COR,17		;YES
	CONO	PAG,37		;SET RELOAD COUNTER
	CONI	PAG,ACT
	TDZ	ACT,[-1,,777740] ;CLEAR OTHER BITS
	TRNN	ACT,37		;TEST FOR ANY BIT
	ERROR1	13,COR,ACT,NO BITS SET,
	ERLOOP	RLDCT1

;*CYCLE RELOAD COUNTER BY SETTING IT TO INCREASING VALUES.
;*TESTS ALL COMBINATIONS.

RLDCT2:	MOVEI	CNTR,^D64	;SETUP FOR 2 CYCLES
	SETZM	COR
	AOS	COR		;INC RELOAD CNTR SETTING
	ANDI	COR,37
	SKIPE	AM16RF		;ONLY 16 AM/SC ?
	ANDI	COR,17		;YES
	CONO	PAG,(COR)	;SET RELOAD COUNTER
	CONI	PAG,ACT
	TDZ	ACT,[-1,,777740]
	CAME	COR,ACT		;TEST FOR PROPER COUNT
	ERROR1	13,COR,ACT,COUNT PATTERN,
	ERLOOP	.-5		;IF ERROR, CYCLE ON SAME SETTING
	SOJLE	CNTR,RLDCT2+2

	REPTLP	RLDCT0+1
SUBTTL	TEST PAGING MEMORY FOR CLEAR

SALL
T=	SIXBTZ	PAGING MEMORY TEST
LALL

;*CLEAR PAGING MEMORY BY DOING 'DATAO PAG'
;*AM IS CLEAR IF WORD EMPTY BIT IS ON
;*IN 'CONI PAG' WORD FOR SELECTED AM REGISTER.
;*'DATAO PAG' WITH EITHER LOAD BASE REG BITS ON 
;*SHOULD WRITE THE WORD EMPTY BIT IN ALL AM REGS.

	SUBTST
AMCLR0:	MOVE	REPT,RPEAT
	MOVE	COR,[LLDUSB,,0]
	DATAO	PAG,COR		;CLEAR ASSOC MEMORY

;*SELECT PAGING MEMORY REGISTER BY 'CONO PAG'.
;*DO 'CONI PAG' TO READ SELECTED AM REGISTER.
;*TEST FOR WORD EMPTY BIT BEING ON.

AMCLR1:	MOVSI	CNTR,-^D32	;THERE ARE 32 AM REGS
	SKIPE	AM16RF		;UNLESS ONLY 16 ?
	MOVSI	CNTR,-^D16
	MOVEI	COR,777440(CNTR);CLR AM' AND RELOAD CNTR
	CONO	PAG,(CNTR)	;SET RELOAD COUNTER
	CONI	PAG,ACT		;READ BACK
	TRNN	ACT,AMCLRB	;IS WORD EMPTY BIT ON ?
	ERROR1	13,COR,ACT,CONO-CONI PAG,NOT CLEAR
	ERLOOP	.-5
	AOBJN	CNTR,AMCLR1+3	;LOOP FOR ALL AM REGS

	REPTLP	AMCLR0+1
>
	LIST
SUBTTL	TEST PROCESSOR TRAPS

SALL
T=SIXBTZ	PROCESSOR TRAP TEST
LALL

	SUBTST
P0TRP0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]

;*TEST TRAP 3 TRAP

P0TRP1:	MOVE	AC,[JSR	P0TP3]
	MOVEM	AC,LTRP3T
	CONO	PAG,LTRPEN
	JRSTF	@.+1
	TN0!TN1,,.+1
P0TP3X:	MOVE	LTRP3SV
	MOVEM	LTRP3T
	ERROR1	13,0,0,TRAP 3 FAILED,FATAL
	JRST	P0PDLX-5

P0TP3:	0
	CONO	PAG,LTRPEN
	MOVE	LTRP3SV
	MOVEM	LTRP3T
	MOVE	COR,[0,,P0TP3X]
	MOVE	ACT,P0TP3
	CAME	COR,ACT
	ERROR	P0TRP1,13,COR,ACT,TRAP 3 SAVED PC
;*TEST PUSHDOWN OVERFLOW TRAP

	MOVE	AC,[JSR P0PDL]
	MOVEM	AC,LPDOVT
	CONO	PAG,LTRPEN
	JRSTF	@.+1
	TN0,,.+1
P0PDLX:	MOVE	LPDOVSV
	MOVEM	LPDOVT
	ERROR1	13,0,0,TRAP 2 FAILED,FATAL
	JRST	P0AROX-5

P0PDL:	0
	CONO	PAG,LTRPEN
	MOVE	LPDOVSV
	MOVEM	LPDOVT
	MOVE	COR,[0,,P0PDLX]
	MOVE	ACT,P0PDL
	CAME	COR,ACT
	ERROR	P0TRP1,13,COR,ACT,TRAP 2 SAVED PC
;*TEST OVERFLOW TRAP

	MOVE	AC,[JSR P0AROV]
	MOVEM	AC,LAROVT
	CONO	PAG,LTRPEN
	JRSTF	@.+1
	TN1,,.+1
P0AROX:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR1	13,0,0,TRAP 1 FAILED,FATAL
	JRST	P0ARO1

P0AROV:	0
	CONO	PAG,LTRPEN
	MOVE	LAROVSV
	MOVEM	LAROVT
	MOVE	COR,[0,,P0AROX]
	MOVE	ACT,P0AROV
	CAME	COR,ACT
	ERROR	P0TRP1,13,COR,ACT,TRAP 1 SAVED PC

	REPTLP	P0TRP0+1
P0ARO1:
SUBTTL	PDL TRAPPING TESTS

;*THESE TEST FOR THE PUSHDOWN INSTRUCTIONS INSURE THAT THEY WILL
;*INDEED TRAP WHEN AN OVERFLOW OR UNDERFLOW CONDITION OCCURS.
;*THESE TEST ALSO VERIFY THE VALIDITY OF THE INFORMATION PROCESSED
;*BY THE INSTRUCTION, AS THEY SHOULD GIVE VALID RESULTS INDEPENDENT
;*OF WHETHER OR NOT THEY TRAP.

;*TEST PUSH INSTRUCTION

	SUBTST
PDT0:	MOVE	REPT,RPEAT

PDT1:	MOVSI	PDT2		;SHOULD TRAP HERE
	HRRI	PDT3		;AFTER TRAP
	GO	PDSET		;SETUP TRAPPING

	MOVE	1,[-1,,OVSTR1-1] ; SET PDL POINTER

	PUSH	1,TSTWD		;PUSH SHOULD TRAP

PDT2:	ERROR	PDT1,13,0,0,PUSH,PUSH DID NOT TRAP

	C=[0,,OVSTR1]
PDT3:	CAME	1,C		;PDL POINTER OK ?
	ERROR	PDT1,13,C,1,PUSH,DID NOT INCREMENT POINTER

	MOVE	1,OVSTR1	;GET C(STK)
	CAME	1,TSTWD		;VERIFY CORRECT DEPOSIT OF DATA
	ERROR	PDT1,13,TSTWD,1,PUSH,DID NOT STORE DATA
;*TEST PUSHJ INSTRUCTION

PDT4A:	MOVSI	PDT5		;SHOULD TRAP
	HRRI	PDT6		;RETURN TO AFTER TRAP
	GO	PDSET		;SETUP TRAPPING

	MOVE	1,[-1,,OVSTR1-1] ;SET PTR

	PUSHJ	1,PDT5		;PUSHJ SHOULD TRAP

PDT4:	ERROR	PDT4A,13,0,0,PUSHJ,DID NOT TRAP OR CALC EA

PDT5:	ERROR	PDT4A,13,0,0,PUSHJ,DID NOT TRAP

	C=[0,,OVSTR1]
PDT6:	CAME	1,C
	ERROR	PDT4A,13,C,1,PUSHJ,DID NOT INCREMENT POINTER

	MOVE	1,OVSTR1	;GET C(STK)
	MOVEI	2,PDT4		;GET ADR WHERE TRAPPED
	HRRZS	1		;CLEAR LH(AC1)
	CAME	1,2		;AC1=AC2 ?
	ERROR	PDT4A,13,2,1,PUSHJ,DID NOT SAVE RIGHT RET ADDR
;*TEST POP INSTRUCTION

PDT7:	MOVSI	PDT8		;SHOULD TRAP HERE
	HRRI	PDT9		;RETURN TO AFTER TRAP
	GO	PDSET		;SETUP TRAPPING

	MOVEI	1,OVSTR1	;SET PDL POINTER
	MOVE	TSTWD#		;GET TEST WORD
	MOVEM	OVSTR1#		;PUT IT ON STACK
	SETZ	2,		;CLEAR AC2

	POP	1,2		;POP SHOULD TRAP
PDT8:	ERROR	PDT7,13,0,0,POP,DID NOT TRAP

PDT9:	CAME	2,TSTWD		;AC2 RESTORED OK ?
	ERROR	PDT7,13,TSTWD,2,POP,DID NOT RESTORE DATA

	C=[-1,,OVSTR1-1]
	CAME	1,C		;PTR OK ?
	ERROR	PDT7,13,C,1,POP,DID NOT DECREMENT POINTER
;*TEST POPJ INSTRUCTION

PDT10:	MOVSI	PDT11A		;SHOULD TRAP TO HERE
	HRRI	PDT12		;RETURN HERE
	GO	PDSET		;SETUP TRAPPING

	MOVEI	1,OVSTR1	;SETUP PDL STACK
	MOVEI	PDT11A		;GET POPJ'S RETURN ADDRESS
	MOVEM	OVSTR1		;PUT ON STACK

	POPJ	1,		;POPJ SHOULD TRAP

PDT11:	ERROR	PDT10,13,0,0,POPJ,DID NOT TRAP OR GET RETURN ADR

PDT11A:	ERROR	PDT10,13,0,0,POPJ,DID NOT TRAP

	C=[-1,,OVSTR1-1]
PDT12:	CAME	1,C
	ERROR	PDT10,13,C,1,POPJ,DID NOT DECREMENT POINTER
;*TEST OVERFLOW TRAP WITH "ASH"

ASHTST:	MOVSI	ASHTRP		;TRAP TO HERE
	HRRI	ASHRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377777,,-1]

	ASH	2,1		;ASH SHOULD TRAP

ASHTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	ASHTST,13,0,0,ASH OVERFLOW,DID NOT TRAP

	C=[377777,,-2]
ASHRET:	MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	ASHTST,13,C,2,ASH OVERFLOW,AC WRONG
;*TEST OVERFLOW TRAP WITH "ASHC"

ASHCTST:MOVSI	ASHCTRP		;TRAP TO HERE
	HRRI	ASHCRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377777,,-1]
	MOVEI	3,0

	ASHC	2,1		;ASHC SHOULD TRAP

ASHCTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	ASHCTST,13,0,0,ASHC OVERFLOW,DID NOT TRAP

	C=[377777,,-2]
ASHCRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	ASHCTST,13,C,2,ASHC OVERFLOW,AC WRONG
;*TEST OVERFLOW TRAP WITH "MUL"

MULTST:	MOVSI	MULTRP		;TRAP TO HERE
	HRRI	MULRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[400000,,0]

	MUL	2,2		;MUL SHOULD TRAP

MULTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	MULTST,13,0,0,MUL OVERFLOW,DID NOT TRAP

	C=[400000,,0]
MULRET:	MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	MULTST,13,C,2,MUL OVERFLOW,AC MODIFIED
;*TEST OVERFLOW TRAP WITH "IMUL"

IMULTST:MOVSI	IMULTRP		;TRAP TO HERE
	HRRI	IMULRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[400000,,0]

	IMUL	2,2		;IMUL SHOULD TRAP

IMULTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	IMULTST,13,0,0,IMUL OVERFLOW,DID NOT TRAP

	C=[400000,,0]
IMULRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	IMULTST,13,C,2,IMUL OVERFLOW,AC MODIFIED
;*TEST OVERFLOW TRAP WITH "ADJBP"

ADJTST:	MOVSI	ADJTRP		;TRAP TO HERE
	HRRI	ADJRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[017700,,0]

	IBP	1,2		;ADJBP SHOULD TRAP

ADJTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	ADJTST,13,0,0,ADJBP OVERFLOW,DID NOT TRAP

ADJRET:	MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "FSC"

FSCTST:	MOVSI	FSCTRP		;TRAP TO HERE
	HRRI	FSCRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[-377400,,0]

	FSC	2,-400		;FSC SHOULD TRAP

FSCTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FSCTST,13,0,0,FSC OVERFLOW,DID NOT TRAP

FSCRET:	MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "FIX"

FIXTST:	MOVSI	FIXTRP		;TRAP TO HERE
	HRRI	FIXRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[244400,,0]

	FIX	2,2		;FIX SHOULD TRAP

FIXTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FIXTST,13,0,0,FIX OVERFLOW,DID NOT TRAP

	C=[244400,,0]
FIXRET:	MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	FIXTST,13,C,2,FIX OVERFLOW,AC MODIFIED
;*TEST OVERFLOW TRAP WITH "FIXR"

FIXRTST:MOVSI	FIXRTRP		;TRAP TO HERE
	HRRI	FIXRRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[244400,,0]

	FIXR	2,2		;FIXR SHOULD TRAP

FIXRTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FIXRTST,13,0,0,FIXR OVERFLOW,DID NOT TRAP

	C=[244400,,0]
FIXRRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS CHANGED
	ERROR	FIXRTST,13,C,2,FIXR OVERFLOW,AC MODIFIED
;*TEST OVERFLOW TRAP WITH "FAD"

FADTST:	MOVSI	FADTRP		;TRAP TO HERE
	HRRI	FADRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377400,,0]

	FAD	2,2		;FAD SHOULD TRAP

FADTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FADTST,13,0,0,FAD OVERFLOW,DID NOT TRAP

FADRET:	MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "DFAD"

DFADTST:MOVSI	DFADTRP		;TRAP TO HERE
	HRRI	DFADRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377400,,0]

	DFAD	2,2		;DFAD SHOULD TRAP

DFADTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	DFADTST,13,0,0,DFAD OVERFLOW,DID NOT TRAP

DFADRET:MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "FSB"

FSBTST:	MOVSI	FSBTRP		;TRAP TO HERE
	HRRI	FSBRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[400400,,0]
	MOVE	3,[377400,,0]

	FSB	2,3		;FSB SHOULD TRAP

FSBTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FSBTST,13,0,0,FSB OVERFLOW,DID NOT TRAP

FSBRET:	MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "DFSB"

DFSBTST:MOVSI	DFSBTRP		;TRAP TO HERE
	HRRI	DFSBRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[400400,,0]
	MOVE	4,[377400,,0]
	SETZB	3,5

	DFSB	2,4		;DFSB SHOULD TRAP

DFSBTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	DFSBTST,13,0,0,DFSB OVERFLOW,DID NOT TRAP

DFSBRET:MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "FMP"

FMPTST:	MOVSI	FMPTRP		;TRAP TO HERE
	HRRI	FMPRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377400,,0]

	FMP	2,2		;FMP SHOULD TRAP

FMPTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FMPTST,13,0,0,FMP OVERFLOW,DID NOT TRAP

FMPRET:	MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST OVERFLOW TRAP WITH "DFMP"

DFMPTST:MOVSI	DFMPTRP		;TRAP TO HERE
	HRRI	DFMPRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	MOVE	2,[377400,,0]

	DFMP	2,2		;DFMP SHOULD TRAP

DFMPTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	DFMPTST,13,0,0,DFMP OVERFLOW,DID NOT TRAP

DFMPRET:MOVE	LAROVSV
	MOVEM	LAROVT
;*TEST NO-DIVIDE TRAP WITH "DIV"

DIVTST:	MOVSI	DIVTRP		;TRAP TO HERE
	HRRI	DIVRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	SETZB	2,3		;CLEAR AC2 & AC3

	DIV	2,2		;DIV SHOULD TRAP

DIVTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	DIVTST,13,0,0,DIV NO DIVIDE,DID NOT TRAP

	C=[0]
DIVRET:	MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS NOT CHANGED
	ERROR	DIVTST,13,C,2,DIV NO DIVIDE,AC MODIFIED

	CAME	3,C
	ERROR	DIVTST,13,C,3,DIV NO DIVIDE,AC+1 MODIFIED
;*TEST NO-DIVIDE TRAP WITH "IDIV"

IDIVTST:MOVSI	IDIVTRP		;TRAP TO HERE
	HRRI	IDIVRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	SETZB	2,3		;CLEAR AC2 & AC3

	IDIV	2,2		;IDIV SHOULD TRAP

IDIVTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	IDIVTST,13,0,0,IDIV NO DIVIDE,DID NOT TRAP

	C=[0]
IDIVRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS NOT CHANGED
	ERROR	IDIVTST,13,C,2,IDIV NO DIVIDE,AC MODIFIED

	CAME	3,C
	ERROR	IDIVTST,13,C,3,IDIV NO DIVIDE,AC+1 MODIFIED
;*TEST NO-DIVIDE TRAP WITH "FDV"

FDVTST:	MOVSI	FDVTRP		;TRAP TO HERE
	HRRI	FDVRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	SETZB	2,3		;CLEAR AC2 & AC3

	FDV	2,2		;FDV SHOULD TRAP

FDVTRP:	MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FDVTST,13,0,0,FDV NO DIVIDE,DID NOT TRAP

	C=[0]
FDVRET:	MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS NOT CHANGED
	ERROR	FDVTST,13,C,2,FDV NO DIVIDE,AC MODIFIED

	CAME	3,C
	ERROR	FDVTST,13,C,3,FDV NO DIVIDE,AC+1 MODIFIED
;*TEST NO-DIVIDE TRAP WITH "FDVR"

FDVRTST:MOVSI	FDVRTRP		;TRAP TO HERE
	HRRI	FDVRRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	SETZB	2,3		;CLEAR AC2 & AC3

	FDVR	2,2		;FDVR SHOULD TRAP

FDVRTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	FDVRTST,13,0,0,FDVR NO DIVIDE,DID NOT TRAP

	C=[0]
FDVRRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS NOT CHANGED
	ERROR	FDVRTST,13,C,2,FDVR NO DIVIDE,AC MODIFIED

	CAME	3,C
	ERROR	FDVRTST,13,C,3,FDVR NO DIVIDE,AC+1 MODIFIED
;*TEST NO-DIVIDE TRAP WITH "DFDV"

DFDVTST:MOVSI	DFDVTRP		;TRAP TO HERE
	HRRI	DFDVRET		;RETURN TO HERE
	GO	ARSET		;SETUP TRAPPING

	SETZB	2,3		;CLEAR AC2 & AC3
	DFDV	2,2		;DFDV SHOULD TRAP

DFDVTRP:MOVE	LAROVSV
	MOVEM	LAROVT
	ERROR	DFDVTST,13,0,0,DFDV NO DIVIDE,DID NOT TRAP

	C=[0]
DFDVRET:MOVE	LAROVSV
	MOVEM	LAROVT
	CAME	2,C		;INSURE AC HAS NOT CHANGED
	ERROR	DFDVTST,13,C,2,DFDV NO DIVIDE,AC MODIFIED

	CAME	3,C
	ERROR	DFDVTST,13,C,3,DFDV NO DIVIDE,AC+1 MODIFIED

	REPTLP	PDT1		;REPEAT LOOP

	MOVE	LPDOVSV
	MOVEM	LPDOVT		;RESTORE TRAP
	JRST	MAPCK0-2
;*TRAPPING SUBROUTINES

ARSET:	SETZM	TRPTYP		;NOTE AR OVERFLOW
	JRST	.+2

PDSET:	SETOM	TRPTYP		;NOTE PDL OVERFLOW

	HRRZM	RETO		;SAVE TRAP RETURN ADDRESS
	HLRZM	SHTRP		;SAVE WHERE SHOULD TRAP

	MOVEI	LAROVT		;GET AR TRAP LOCATION
	SKIPE	TRPTYP
	MOVEI	LPDOVT		;GET PDL TRAP LOCATION
	MOVEM	TRPLOC		;SAVE ADR OF TRAP LOCATION

	MOVE	TRINST		;GET EXEC TRAP INSTRUCTION
	EXCH	@TRPLOC		;STORE NEW & GET OLD TRAP INST
	MOVEM	TRPSAV		;SAVE TO RESTORE LATER
	RTN

TRINST:	JSR	EXCTRP		;THIS WILL SAVE PC
EXCTRP:	0			;PC GOES HERE
	PUT	1
	MOVE	1,TRPSAV	;GET ORIGINAL TRAP INST
	MOVEM	1,@TRPLOC	;RESTORE IT

COMCHK:	MOVE	1,EXCTRP	;GET TRAP PC
	HRRZS	1		;CLEAR LH(AC0)
	CAME	1,SHTRP		;TRAP WHERE SHOULD ?
	ERROR	PDT0,13,SHTRP,1,BAD TRAP
	GET	1
	JRSTF	@RETO		;RETURN TO PROG AT SUPPLIED ADR

;*TRAP STORAGE

SHTRP:	0		;LOC WHERE SHOULD TRAP
RETO:	0		;RETURN TO ADDRESS
TRPSAV:	0		;ORIGINAL TRAP INST
TRPLOC:	0		;ADR OF TRAP LOCATION
TRPTYP:	0		;TRAP TYPE 0=AR, -1=PDL
TSTWD:	123456,,654321	;TEST WORD
OVSTR1:	0		;STACK FOR PDL TESTS
MTRZ:	0
MTRX:	0
SUBTTL	TEST MAP INSTRUCTION

SALL
T=	SIXBTZ	MAP INST TEST
LALL

;*PERFORM 'MAP' OF ADDRESS 0.
;*MAP READOUT SHOULD BE:
;*ACCESS, WRITEABLE, SOFTWARE, PAGED REF

	SUBTST
MAPCK0:	MOVE	REPT,RPEAT
	MOVE	COR,[161000,,0]
	MAP	ACT,0		;MAP FOR LOCATION 0
	CAME	COR,ACT
	ERROR	.-4,13,COR,ACT,MAP ADR 0,

;*PERFORM 'MAP' OF ADDRESS 337000,
;*HIGHEST EXEC PAGED MEMORY ADDRESS.
;*MAP READOUT SHOULD BE:
;*ACCESS, WRITABLE, SOFTWARE, PAGED REF

MAPCK1:	MOVE	COR,[161000,,337000]
	MAP	ACT,337000	;MAP FOR LOCATION 337000
	CAME	COR,ACT
	ERROR	.-4,13,COR,ACT,MAP ADR 337000,

;*CLEAR PAGE MAP

MAPCK2:	SETZM	200
	MOVE	AC,[200,,201]
	BLT	AC,417		;CLEAR ALL OF PAGE MAP
MAPCK9:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
;*PERFORM 'MAP' OF ADDRESS 400000,
;*LOWEST EPMP PAGING ADDRESS.
;*SINCE PAGE MAP IS CLEAR
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

MAPCK3:	MOVE	COR,[1000,,400000]
	MAP	ACT,400000
	CAME	COR,ACT
	ERROR	MAPCK9,13,COR,ACT,MAP ADR 400000,PAGE MAP CLEAR

;*PERFORM 'MAP' OF ADDRESS 777000,
;*HIGHEST EPMP PAGING ADDRESS.
;*SINCE PAGE MAP IS CLEAR
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

MAPCK4:	MOVE	COR,[1000,,777000]
	MAP	ACT,777000
	CAME	COR,ACT
	ERROR	MAPCK9,13,COR,ACT,MAP ADR 777000,PAGE MAP CLEAR
;*SETUP EPMP FOR ADDRESS 400000 WITH ALL BUT ACCESS.
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.
;*IF ACCESS IS CLEAR REST OF BITS IN PAGE MAP WORD
;*SHOULD HAVE NO EFFECT.

MAPCK5:	MOVSI	AC,377777
	MOVEM	AC,200		;SET PAGE MAP TO ALL BUT ACCESS
	MOVE	COR,[1000,,400000]
	MAP	ACT,400000
	CAME	COR,ACT
	ERROR	MAPCK9,13,COR,ACT,MAP ADR 400000,ALL BUT ACCESS

;*SETUP EPMP FOR ADDRESS 777000 WITH ALL BUT ACCESS.
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.
;*IF ACCESS IS CLEAR REST OF BITS IN PAGE MAP WORD
;*SHOULD HAVE NO EFFECT.

MAPCK6:	MOVEI	AC,377777
	MOVEM	AC,377		;SET PAGE MAP TO ALL BUT ACCESS
	MOVE	COR,[1000,,777000]
	MAP	ACT,777000
	CAME	COR,ACT
	ERROR	MAPCK9,13,COR,ACT,MAP ADR 777000,ALL BUT ACCESS

	REPTLP	MAPCK0+1

SUBTTL	TEST PAGE FAIL TRAPPING

SALL
T=	SIXBTZ	PAGE FAIL TRAP TEST
LALL

;*DO A 'MOVE' FROM LOCATION 400000.
;*SINCE PAGE MAP IS CLEAR THIS SHOULD PAGE FAIL.

	SUBTST
PFAIL0:	MOVE	REPT,RPEAT

	SETZM	200		;CLEAR EXEC PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,377

	CONO	PI,CHNOFF!PICHN2
	CONO	APR,LCNXER!LAPRP2
	SETOM	LEUPFW		;PRESET PAGE FAIL WORD
	SETOM	LPFWPC		;PRESET PAGE FAIL PC
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVEI	AC,PFAIL1
	MOVEM	AC,LPGFTR	;SETUP PAGE FAULT TRAP

	SETOB	0,ACT		;PRESET AC
	MOVE	ACT,400000	;MAKE PAGING REF, SHOULD FAULT
	ERROR	PFAIL0+1,13,0,ACT,TRAP FAILED,REF TO 400000
	JRST	PFAIL2		;NO NEED TO CHECK PAGE FAIL WORD
;*PAGE FAULT TRAP SHOULD RETURN HERE

PFAIL1:	SETOM	COR
	CAME	COR,ACT
	ERROR	PFAIL0+1,13,COR,ACT,PAGE FAIL STORED IN AC,REF TO 400000
	MOVE	ACT,0
	CAME	COR,ACT
	ERROR	PFAIL0+1,13,COR,ACT,PAGE FAIL STORED IN 0,REF TO 400000
	MOVE	COR,[1000,,400000]	;SETUP CORRECT WORD
	MOVE	ACT,LEUPFW	;GET PAGE FAIL WORD
	CAME	COR,ACT
	ERROR	PFAIL0+1,13,COR,ACT,PAGE FAIL WORD WRONG,REF TO 400000

;*PAGE FAULT TRAP SHOULD NOT CAUSE NON-X-MEMORY

PFAIL2:	CONSZ	APR,LNXMER
	ERROR	PFAIL0+1,13,COR,ACT,NON-X-MEM,REF TO 400000
;*CHECK PAGE FAIL WORD FOR MAXIMUM ADDRESS
;*DO A 'MOVE' FROM LOCATION 777777.

PFAIL3:	CONO	APR,LCNXER!LAPRP2
	SETZM	LEUPFW		;PRESET PAGE FAIL WORD
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVEI	AC,PFAIL4
	MOVEM	AC,LPGFTR	;SETUP PAGE FAULT TRAP
	SETZB	0,ACT		;PRESET AC
	MOVE	ACT,777777	;MAKE PAGING REF, SHOULD FAULT
	ERROR	PFAIL3,13,0,ACT,TRAP FAILED,REF TO 777777
	JRST	PFAIL5

;*PAGE FAULT TRAP SHOULD RETURN HERE

PFAIL4:	SETZM	COR
	CAME	COR,ACT
	ERROR	PFAIL3,13,COR,ACT,PAGE FAIL STORED IN AC,REF TO 777777
	MOVE	ACT,0
	CAME	COR,ACT
	ERROR	PFAIL3,13,COR,ACT,PAGE FAIL STORED IN 0,REF TO 777777
	MOVE	COR,[1000,,777777]	;SETUP CORRECT WORD
	MOVE	ACT,LEUPFW	;GET PAGE FAIL WORD
	CAME	COR,ACT
	ERROR	PFAIL3,13,COR,ACT,PAGE FAIL WORD WRONG,REF TO 777777

;*PAGE FAULT TRAP SHOULD NOT CAUSE NON-X-MEMORY

PFAIL5:	CONSZ	APR,LNXMER
	ERROR	PFAIL3,13,COR,ACT,NON-X-MEM,REF TO 777777

;*RESET PAGE FAULT TRAP

PFAIL6:	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR
	CONO	APR,LCNXER!LAPRP2
	CONO	PI,LCHNON!LPICH2	;RE-ENABLE INTERRUPTS

	REPTLP	PFAIL0+1
	XLIST
REPEAT	0,<
SUBTTL	TEST PAGING MEMORY

SALL
T=	SIXBTZ	PAGING MEMORY TEST
LALL

;*CLEAR AND SETUP PAGE MAP FOR PAGE 777.
;*PAGE 777 DATA IS:  PUBLIC, WRITABLE, SOFTWARE, ADR BITS 14-26=0.

	SUBTST
AMTST0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR EXEC PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,377
	DATAO	PAG,[LLDUSB,,400000]	;CLEAR AM
	MOVEI	AC,740000
	MOVEM	AC,377		;SETUP PAGE MAP FOR PAGE 777

	XX=-1

AMTST1:	REPEAT	^D16,
<;PAGE MAP IS SETUP FOR PAGE 777 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE, AND ADR BITS 14-26 = 0.
;*'DATAO PAG' CLEARS PAGING MEMORY THERFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND PAGING MEMORY WITH PAGE ADDRESS 777.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT' BY THE MAP INST.
;*THE RELOAD COUNTER SHOULD BE INCREMENTED BY LOADING THE PAGING MEMORY.
;*READOUT OF LOADED PAGING MEMORY SHOULD THEN GIVE
;*PAGE 777', EXEC MEMORY SPACE, RELOAD COUNTER.
	XX=XX+1
	DATAO	PAG,[LLDUSB,,400000]
	CONO	PAG,XX		;SET RELOAD COUNTER
	MOVEI	COR,340000	;SETUP FOR MAP READOUT
	MAP	ACT,777000	;'MAP'
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MAP READOUT FAILURE,SCRATCHPAD MEM 0
	MOVEI	COR,<<XX+1>&37>
	CONI	PAG,ACT		;READ RELOAD COUNTER
	ANDI	ACT,37
	CAME	COR,ACT		;TEST FOR RELOAD INC
	ERROR1	13,COR,ACT,RELOAD CNTR INC FAILURE,
	MOVEI	COR,EXCMEM!XX
	CONO	PAG,XX		;RESET RELOAD CNTR
	CONI	PAG,ACT		;READOUT ASSOC MEMORY
	TLZ	ACT,-1
	CAME	COR,ACT		;SHOULD BE: ADR 777XXX',EXCMEM,R.C.
	ERROR1	13,COR,ACT,ASSOC MEM READOUT FAILURE,
	ERLOOP	.-^D30
>
AMTT1A:	SKIPE	AM16RF		;ONLY 16 AM/SC REGS ?
	JRST	AMTST2		;YES

	REPEAT	^D16,
<;PAGE MAP IS SETUP FOR PAGE 777 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE, AND ADR BITS 14-26 = 0.
;*'DATAO PAG' CLEARS PAGING MEMORY THERFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND PAGING MEMORY WITH PAGE ADDRESS 777.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT' BY THE MAP INST.
;*THE RELOAD COUNTER SHOULD BE INCREMENTED BY LOADING THE PAGING MEMORY.
;*READOUT OF LOADED PAGING MEMORY SHOULD THEN GIVE
;*PAGE 777', EXEC MEMORY SPACE, RELOAD COUNTER.
	XX=XX+1
	DATAO	PAG,[LLDUSB,,400000]
	CONO	PAG,XX		;SET RELOAD COUNTER
	MOVEI	COR,340000	;SETUP FOR MAP READOUT
	MAP	ACT,777000	;'MAP'
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MAP READOUT FAILURE,SCRATCHPAD MEM 0
	MOVEI	COR,<<XX+1>&37>
	CONI	PAG,ACT		;READ RELOAD COUNTER
	ANDI	ACT,37
	CAME	COR,ACT		;TEST FOR RELOAD INC
	ERROR1	13,COR,ACT,RELOAD CNTR INC FAILURE,
	MOVEI	COR,EXCMEM!XX
	CONO	PAG,XX		;RESET RELOAD CNTR
	CONI	PAG,ACT		;READOUT ASSOC MEMORY
	TLZ	ACT,-1
	CAME	COR,ACT		;SHOULD BE: ADR 777XXX',EXCMEM,R.C.
	ERROR1	13,COR,ACT,ASSOC MEM READOUT FAILURE,
	ERLOOP	.-^D30
>
;*SETUP PAGE MAP FOR PAGE 400.
;*PAGE 400 DATA IS:  PUBLIC, WRITABLE, SOFTWARE, ADR BITS 14-26 = 17777.

AMTST2:	MOVSI	AC,757777	;SETUP PAGE MAP FOR PAGE 400
	MOVEM	AC,200

	XX=-1
AMTST3:	REPEAT	^D16,
<;PAGE MAP IS SETUP FOR PAGE 400 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE, AND ADR BITS 14-26 = 17777.
;*'DATAO PAG' CLEARS PAGING MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND PAGING MEMORY WITH PAGE ADDRESS 400.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT' BY THE MAP INST.
;*THE RELOAD COUNTER SHOULD BE INCREMENTED BY LOADING THE PAGING MEMORY.
;*READOUT OF THE LOADED PAGING MEMORY SHOULD THEN GIVE
;*PAGE 400', EXEC MEMORY SPACE, RELOAD COUNTER.
	XX=XX+1
	DATAO	PAG,[LLDUSB,,400000]
	CONO	PAG,XX		;SET RELOAD CNTR
	MOVEI	COR,357777	;SETUP MAP READOUT
	MAP	ACT,400000	;'MAP'
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MAP READOUT FAILURE,SCRATCHPAD MEM ALL 1'S
	MOVEI	COR,<<XX+1>&37>
	CONI	PAG,ACT		;READ RELOAD COUNTER
	ANDI	ACT,37
	CAME	COR,ACT		;TEST THAT R.C. INCREMENTED
	ERROR1	13,COR,ACT,RELOAD CNTR INC FAILURE,
	MOVEI	COR,377000!EXCMEM!XX
	CONO	PAG,XX		;RESET RELOAD CNTR
	CONI	PAG,ACT		;READOUT ASSOC MEMORY
	TLZ	ACT,-1
	CAME	COR,ACT		;SHOULD BE: ADR 400XXX',EXCMEM,R.C.
	ERROR1	13,COR,ACT,ASSOC MEM READOUT FAILURE,
	ERLOOP	.-^D30
>
AMTT3A:	SKIPE	AM16RF		;ONLY 16 AM/SC REGS ?
	JRST	AMTT3B		;YES
	REPEAT	^D16,
<;PAGE MAP IS SETUP FOR PAGE 400 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE, AND ADR BITS 14-26 = 17777.
;*'DATAO PAG' CLEARS PAGING MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND PAGING MEMORY WITH PAGE ADDRESS 400.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT' BY THE MAP INST.
;*THE RELOAD COUNTER SHOULD BE INCREMENTED BY LOADING THE PAGING MEMORY.
;*READOUT OF THE LOADED PAGING MEMORY SHOULD THEN GIVE
;*PAGE 400', EXEC MEMORY SPACE, RELOAD COUNTER.
	XX=XX+1
	DATAO	PAG,[LLDUSB,,400000]
	CONO	PAG,XX		;SET RELOAD CNTR
	MOVEI	COR,357777	;SETUP MAP READOUT
	MAP	ACT,400000	;'MAP'
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MAP READOUT FAILURE,SCRATCHPAD MEM ALL 1'S
	MOVEI	COR,<<XX+1>&37>
	CONI	PAG,ACT		;READ RELOAD COUNTER
	ANDI	ACT,37
	CAME	COR,ACT		;TEST THAT R.C. INCREMENTED
	ERROR1	13,COR,ACT,RELOAD CNTR INC FAILURE,
	MOVEI	COR,377000!EXCMEM!XX
	CONO	PAG,XX		;RESET RELOAD CNTR
	CONI	PAG,ACT		;READOUT ASSOC MEMORY
	TLZ	ACT,-1
	CAME	COR,ACT		;SHOULD BE: ADR 400XXX',EXCMEM,R.C.
	ERROR1	13,COR,ACT,ASSOC MEM READOUT FAILURE,
	ERLOOP	.-^D30
>
AMTT3B:	REPTLP	AMTST0+1
>
LIST
SUBTTL	TEST EXEC-PER-PROCESS MAPPING

SALL
T=	SIXBTZ	EXEC-PER-PROCESS MAP TEST
LALL

	SUBTST
EPPM0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR ALL OF PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
EPPM9:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]

;*PERFORM 'MAP' OF ADDRESS 340000
;*LOWEST UPMP EXEC-PER-PROCESS ADDRESS.
;*SINCE PAGE MAP IS CLEAR
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

EPPM1:	MOVE	COR,[1000,,340000]
	MAP	ACT,340000
	CAME	COR,ACT
	ERROR	EPPM9,13,COR,ACT,MAP ADR 340000,PAGE MAP CLEAR

;*PERFORM 'MAP' OF ADDRESS 377000
;*HIGHEST UPMP EXEC-PER-PROCESS ADDRESS.
;*SINCE PAGE MAP IS CLEAR
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

EPPM2:	MOVE	COR,[1000,,377000]
	MAP	ACT,377000
	CAME	COR,ACT
	ERROR	EPPM9,13,COR,ACT,MAP ADR 377000,PAGE MAP CLEAR
;*SETUP UPMP FOR ADDRESS 340000 WITH ALL BUT ACCESS.
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

EPPM3:	MOVSI	AC,377777
	MOVEM	AC,400
	MOVE	COR,[1000,,340000]
	MAP	ACT,340000
	CAME	COR,ACT
	ERROR	EPPM9,13,COR,ACT,MAP ADR 340000,ALL BUT ACCESS

;*SETUP UPMP FOR ADDRESS 377000 WITH ALL BUT ACCESS
;*MAP READOUT SHOULD BE:
;*PAGE FAIL, PAGING MEMORY NO MATCH.

EPPM4:	MOVEI	AC,377777
	MOVEM	AC,417
	MOVE	COR,[1000,,377000]
	MAP	ACT,377000
	CAME	COR,ACT
	ERROR	EPPM9,13,COR,ACT,MAP ADR 377000,ALL BUT ACCESS
EPPM5:	MOVEI	AC,740000
	MOVEM	AC,417		;SETUP P-P MAP FOR PAGE 377
	MOVSI	AC,757777
	MOVEM	AC,400		;SETUP P-P MAP FOR PAGE 340

;*UPMP EXEC-PER-PROCESS MAP IS SETUP FOR PAGE 377 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE AND ADR BITS 14-26 = 0.
;*'DATAO PAG' CLEARS PAGING MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA
;*FROM UPMP EXEC-PER-PROCESS MAP AND LOAD PAGING MEMORY
;*WITH PAGE ADDRESS 377.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT'
;*BY THE MAP INSTRUCTION.
;*READOUT OF THE LOADED PAGING MEMORY (BY 'CONI PAG')
;*SHOULD BE:
;*PAGE 377',EXEC MEMORY SPACE, RELOAD COUNTER.

EPPM6:	CONO	PAG,LTRPEN		;CLEAR RELOAD CNTR
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,[161000,,0]
	MAP	ACT,377000	;'MAP'
	CAME	COR,ACT
	ERROR	EPPM6,13,COR,ACT,MAP READOUT FAILURE,MAP ADR 377000
;*UPMP EXEC-PER-PROCESS MAP IS SETUP FOR PAGE 340 WITH
;*ACCESS, PUBLIC, WRITABLE, SOFTWARE AND ADR BITS 14-26 = 03777.
;*'DATAO PAG' CLEARS PAGING MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA
;*FROM UPMP EXEC-PER-PROCESS MAP AND LOAD PAGING MEMORY
;*WITH PAGE ADDRESS 340.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT'
;*BY THE MAP INSTRUCTION.
;*READOUT OF THE LOADED PAGING MEMORY (BY 'CONI PAG')
;*SHOULD BE:
;*PAGE 340',EXEC MEMORY SPACE, RELOAD COUNTER.

EPPM7:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,[161003,,777000]
	MAP	ACT,340000	;'MAP'
	CAME	COR,ACT
	ERROR	EPPM7,13,COR,ACT,MAP READOUT FAILURE,MAP ADR 340000

	REPTLP	EPPM0+1
SUBTTL	TEST PAGING AND SCRATCHPAD MEMORIES

;*PAGE MAP IS SETUP FOR 42 PAGES WITH DATA THAT PRODUCES
;*FLOATING BIT PATTERNS IN BOTH THE PAGING MEMORY
;*AND THE SCRATCHPAD MEMORY TO CHECK REGISTER AND BIT INTERACTION.
;*ALL PAGING ADDRESSES ARE SETUP SO PAGING MUST REFILL ON EVERY
;*OPERATION.  THIS SHOULD VERIFY THAT THE PAGING REFILL OPERATION
;*AND THE PAGING AND SCRATCHPAD REGISTERS ARE OPERATIONAL.

SALL
T=	SIXBTZ	FLOATING BIT TEST
LALL

	SUBTST
AMTST4:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417

AMTST5:	MOVSI	INDX,-^D42	;SETUP PAGE MAP FOR
	MOVE	AC,AMTAB1(INDX)	;42 PAGES WITH DATA
	HRRZ	AC1,AC		;THAT PRODUCES FLOATING
	LSH	AC1,-1		;BIT PATTERNS TO TEST
	CAIGE	AC1,200		;PAGING AND SCRATCHPAD
	ADDI	AC1,220		;MEMORIES.
	TRNN	AC,1
	HLLM	AC,(AC1)
	TRNE	AC,1
	HLRM	AC,(AC1)
	AOBJN	INDX,AMTST5+1

	MOVEI	CNTR,^D100	;CYCLE FLT BITS FOR 100 PASSES
	MOVSI	INDX,-^D42	;SETUP FOR 42 PAGING REF'S
	MOVEI	AC2,^D32
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
AMTST6:	HLRZ	COR,AMTAB1(INDX)	;SETUP FOR MAP READOUT
	LSH	COR,^D9
	TLZ	COR,14		;ONLY 11 BITS OF RELOCATION
	TLO	COR,1000	;SET PAGED REF BIT
	TLZE	COR,400		;ACCESS
	TLO	COR,100000
	TLZ	COR,200		;NO PUBLIC
	TLZE	COR,100		;WRITABLE
	TLO	COR,40000
	TLZE	COR,40		;SOFTWARE
	TLO	COR,20000
	TLZE	COR,20		;CACHE
	TLO	COR,2000
	HRRZ	AC,AMTAB1(INDX)	;SETUP MAPPING ADDRESS
	LSH	AC,^D9
	MAP	ACT,(AC)	;'MAP'
	CAME	COR,ACT
	ERROR	AMTST6-2,13,COR,ACT,MAP READOUT FAILURE,,AMTSTX

	AOBJN	INDX,AMTST6	;DO 42 DIF REF

	SOJGE	CNTR,AMTST6-4	;CYCLE MEMORIES, ETC.

	REPTLP	AMTST4+1
	JRST	AMTST7-2

AMTSTX:	PSIXM	SIXBTZ	<REF TO >
	MOVE	AC
	PNT6
	PCRL
	RTN
;*CLEAR PAGING MEMORY AND PAGE MAP
;*CHECK THAT ALL PREVIOUS REFERENCES TRAP
;*SHOULD IF AM IS REALLY CLEAR

SALL
T=	SIXBTZ	TRAP TEST
LALL

	SUBTST
AMTST7:	MOVEI	REPT,1
	SETZM	200		;DO ONCE ONLY
	MOVE	AC,[200,,201]
	BLT	AC,417		;CLEAR PAGE MAP
	MOVE	AC,ITRCNT
	TRNE	AC,1		;ALTERNATE CLEARING AM
	CONO	PAG,LTRPEN
	TRNN	AC,1
	DATAO	PAG,[LLDUSB,,400000]
	MOVSI	INDX,-^D42
	MOVEI	AC,AMTST9
	MOVEM	AC,LPGFTR		;SETUP FOR PAGE TRAP

AMTST8:	HRRZ	COR,AMTAB1(INDX)	;SETUP REFERANCE ADDRESS
	LSH	COR,^D9
	SETOB	0,ACT
	MOVE	ACT,(COR)		;SHOULD FAIL
	ERROR	AMTST8,13,COR,ACT,TRAP FAILED,<REF TO (CORRECT)>
	JRST	AMTSTA
AMTST9:	SETOM	COR
	CAME	COR,ACT
	ERROR	AMTST7,13,COR,ACT,PAGE FAIL STORED IN AC,
	MOVE	ACT,0
	CAME	COR,ACT
	ERROR	AMTST7,13,COR,ACT,PAGE FAIL STORED IN 0,
	HRRZ	COR,AMTAB1(INDX)	;SETUP CORRECT PAGE FAIL WORD
	LSH	COR,^D9
	TLO	COR,1000		;SET PAGED REF BIT
	MOVE	ACT,LEUPFW		;GET PAGE FAIL WORD
	CAME	COR,ACT
	ERROR	AMTST7,13,COR,ACT,PAGE FAIL WORD WRONG,

AMTSTA:	AOBJN	INDX,AMTST8

	REPTLP	AMTST7+1

	MOVE	AC,PGFAIL		;RESET PAGE FAULT TRAP
	MOVEM	AC,LPGFTR
SUBTTL	TEST PAGED DATA READ

;*USING PAGING ADDRESSES 400XXX AND 777XXX

SALL
T=	SIXBTZ	PAGED DATA READ TEST
LALL

	SUBTST
PAGRDA:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR AND SETUP PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVSI	AC,740000!<PGR400_-^D9>
	MOVEM	AC,200
	MOVEI	AC,740000!<PGR777_-^D9>
	MOVEM	AC,377

;*TEST A 'MOVE' USING AN 'E' ADDRESS THAT CAUSES PAGING.
;*'E' = PAGE 400 (HIGH ORDER 9 BITS),
;*LOW ORDER 9 BITS ARE LOW ORDER 9 BITS OF 'PGR400' ADDRESS.
;*PAGE MAP RELOCATION BITS SETUP FOR
;*HIGH ORDER 9 BITS OF 'PGR400' ADDRESS.
;*THEREFORE ACTUAL ADDRESS FOR 'MOVE' IS:
;*HIGH ORDER 9 BITS FROM PAGE MAP AND
;*LOW ORDER 9 BITS OF 'PGR400' ADDRESS.

PAGRDB:	CONO	PAG,LTRPEN		;CLEAR MEMORIES, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,PGR400
	MOVE	ACT,400000!<PGR400&777>	;MAKE PAGED READ
	CAME	COR,ACT
	ERROR	PAGRDB,13,COR,ACT,DATA ERROR,ADR 400XXX
;*TEST A 'MOVE' USING AN 'E' ADDRESS THAT CAUSES PAGING.
;*'E' = PAGE 777 (HIGH ORDER 9 BITS),
;*LOW ORDER 9 BITS ARE LOW ORDER 9 BITS OF 'PGR777' ADDRESS.
;*PAGE MAP RELOCATION BITS SETUP FOR
;*HIGH ORDER 9 BITS OF 'PGR777' ADDRESS.
;*THEREFORE ACTUAL ADDRESS FOR 'MOVE' IS:
;*HIGH ORDER 9 BITS FROM PAGE MAP AND
;*LOW ORDER 9 BITS OF 'PGR777' ADDRESS.

PAGRDC:	MOVE	COR,PGR777
	MOVE	ACT,400000!<PGR777&777>	;MAKE PAGED READ
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DATA ERROR,ADR 777XXX
	ERLOOP	.-4

	REPTLP	PAGRDA+1

	JRST	PAGRD0-2

PGR400:	377777,,400000		;DATA FOR PAGE 400
PGR777:	000777,,777000		;DATA FOR PAGE 777
;*TEST READ OF DATA FROM A DATA BLOCK
;*USING PAGED REFERENCES THAT POINT TO
;*CONSECUTIVE DATA WORDS IN AN EXEC UNPAGED
;*MEMORY AREA.
;*DATA CONSISTS OF COMPLEMENT OF AND
;*PAGING REFERENCE ADDRESS.

	SUBTST
PAGRD0:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10		;FSTCYL=10 PASSES, REL=100 PASSES
	MOVSI	INDX,-440		;340-777=440 PAGES
	MOVEI	AC,340			;SETUP FOR FIRST PAGING ADDRESS

PAGRD1:	MOVE	AC1,AC		;SETUP DATA WORD
	LSH	AC1,^D9		;COMPL ADR,,PAGED ADR
	TLO	AC1,-1
	TLZ	AC1,(AC1)
	MOVEM	AC1,PGRDTB(INDX)
	TRNE	AC,1
	JRST	PAGRD2
	MOVEI	AC2,PGRDTB(INDX)
	LSH	AC2,-^D9	;SETUP PAGE MAP FOR EVEN HI-ORDER
	ADDI	AC2,740000	;INCLUDE ACCESS, ETC.
	HRL	AC3,AC2
	MOVEI	AC2,PGRDTB+1(INDX)
	LSH	AC2,-^D9	;SETUP PAGE MAP FOR ODD HI-ORDER
	ADDI	AC2,740000	;INCLUDE ACCESS, ETC.
	HRR	AC3,AC2
	HRRZ	AC1,AC		;SETUP PAGE MAP
	LSH	AC1,-1
	CAIGE	AC1,200
	ADDI	AC1,220
	MOVEM	AC3,(AC1)	;MOVE RELOCATION DATA TO PAGE MAP
PAGRD2:	AOS	AC
	AOBJN	INDX,PAGRD1

PAGRD3:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVSI	INDX,-440
	MOVEI	AC,340
PAGRD4:	MOVE	COR,AC		;SETUP CORRECT RESULTS
	LSH	COR,^D9
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGRDTB(INDX)	;SETUP PAGING ADDRESS
	ANDI	AC1,777
	ADDI	AC1,(COR)
	MOVE	ACT,(AC1)	;MAKE PAGED MEMORY READ
	CAME	COR,ACT		;ADDRESSES GO FROM 340XXX TO 777XXX
	ERROR	PAGRD4,13,COR,ACT,DATA ERROR,INC PAGING ADR'S,PAGRDX
	AOS	AC		;INCREMENT PAGING ADDRESS
	AOBJN	INDX,PAGRD4

PAGRD5:	MOVSI	INDX,-440
	MOVEI	AC,777

	MOVE	COR,AC		;MAKE REVERSE PAGED MEMORY READ
	LSH	COR,^D9		;ADDRESSES GO FROM 777XXX TO 340XXX
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGRDTB+437
	SUBI	AC1,(INDX)
	ANDI	AC1,777
	ADDI	AC1,(COR)
	MOVE	ACT,(AC1)
	CAME	COR,ACT
	ERROR	PAGRD5+2,13,COR,ACT,DATA ERROR,REVERSE READ,PAGRDX
	SOS	AC
	AOBJN	INDX,PAGRD5+2

	REPTLP	PAGRD3
	JRST	PGWRTA-2

PAGRDX:	PSIXM	SIXBTZ	<REF TO >
	MOVE	AC1
	PNT6
	PCRL
	RTN
SUBTTL	TEST PAGED DATA WRITE

;*USING PAGING ADDRESS 400XXX AND 777XXX
;*PAGING REFERENCES POINT TO EXEC UNPAGED ADDRESSES.

SALL
T=	SIXBTZ	PAGED DATA WRITE TEST
LALL

	SUBTST
PGWRTA:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR AND SETUP PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVSI	AC,740000!<PGW400_-^D9>
	MOVEM	AC,200
	MOVEI	AC,740000!<PGW777_-^D9>
	MOVEM	AC,377

;*TEST A 'MOVEM' USING AN 'E' ADDRESS THAT CAUSES PAGING.
;*'E' = PAGE 400 (HIGH ORDER 9 BITS),
;*LOW ORDER 9 BITS ARE LOW ORDER 9 BITS OF 'PGW400' ADDRESS.
;*PAGE MAP RELOCATION BITS SETUP FOR
;*HIGH ORDER 9 BITS OF 'PGW400' ADDRESS.
;*THEREFORE ACTUAL ADDRESS FOR 'MOVEM' IS:
;*HIGH ORDER 9 BITS FROM PAGE MAP AND
;*LOW ORDER 9 BITS OF 'PGW400' ADDRESS.

PGWTBB:	CONO	PAG,LTRPEN		;CLEAR MEMORIES, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	PGW400
	MOVE	COR,[377000,,400777]
	MOVEM	COR,400000!<PGW400&777>	;MAKE PAGED WRITE
	SETOM	ACT
	MOVE	ACT,400000!<PGW400&777>	;PAGED REREAD VERIFY
	CAME	COR,ACT
	ERROR	PGWTBB,13,COR,ACT,PAGED REREAD,ADR 400XXX
	MOVE	ACT,PGW400		;DIRECT REREAD VERIFY
	CAME	COR,ACT
	ERROR	PGWTBB,13,COR,ACT,DIRECT REREAD,ADR 400XXX
;*TEST A 'MOVEM' USING AN 'E' ADDRESS THAT CAUSES PAGING.
;*'E' = PAGE 777 (HIGH ORDER 9 BITS),
;*LOW ORDER 9 BITS ARE LOW ORDER 9 BITS OF 'PGW777' ADDRESS.
;*PAGE MAP RELOCATION BITS SETUP FOR
;*HIGH ORDER 9 BITS OF 'PGW777' ADDRESS.
;*THEREFORE ACTUAL ADDRESS FOR 'MOVEM' IS:
;*HIGH ORDER 9 BITS FROM PAGE MAP AND
;*LOW ORDER 9 BITS OF 'PGW777' ADDRESS.

PGWRTC:	SETZM	PGW777
	MOVE	COR,[000777,,777000]
	MOVEM	COR,777000!<PGW777&777>	;MAKE PAGED WRITE
	SETOM	ACT
	MOVE	ACT,777000!<PGW777&777>	;PAGED REREAD VERIFY
	CAME	COR,ACT
	ERROR	PGWRTC,13,COR,ACT,PAGED REREAD,ADR 777XXX
	MOVE	ACT,PGW777		;DIRECT REREAD VERIFY
	CAME	COR,ACT
	ERROR	PGWRTC,13,COR,ACT,DIRECT REREAD,ADR 777XXX

	REPTLP	PGWRTA+1

	JRST	PGWRT0-2

PGW400:	0			;PAGE 400 STORAGE LOCATION
PGW777:	0			;PAGE 777 STORAGE LOCATION
;*TEST WRITE OF DATA USING PAGED ADDRESS.
;*DATA IS WRITTEN INTO CONSECUTIVE DATA WORDS
;*IN AN EXEC UNPAGED DATA AREA.
;*DATA CONSISTS OF PAGED ADR AND COMPLEMENT OF PAGED ADDRESS.

	SUBTST
PGWRT0:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10	;FSTCYL=10 PASSES, REL=100 PASSES
	MOVSI	INDX,-440/2
	MOVEI	AC,340

PGWRT1:	MOVEI	AC2,PGWRTB(INDX)
	LSH	AC2,-^D9
	ADDI	AC2,740000
	HRL	AC3,AC2
	MOVEI	AC2,PGWRTB+1(INDX)
	LSH	AC2,-^D9
	ADDI	AC2,740000
	HRR	AC3,AC2
	HRRZ	AC1,AC		;SETUP PAGE MAP
	LSH	AC1,-1
	CAIGE	AC1,200
	ADDI	AC1,220
	MOVEM	AC3,(AC1)
	ADDI	AC,2
	AOS	INDX
	AOBJN	INDX,PGWRT1

PGWRT2:	CONO	PAG,LTRPEN		;CLEAR AM, ETC
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	PGWRTB		;CLEAR DATA AREA
	MOVE	AC,[PGWRTB,,PGWRTB+1]
	BLT	AC,PGWRTB+440
	MOVSI	INDX,-440
	MOVEI	AC,340

PGWRT3:	MOVE	COR,AC
	LSH	COR,^D9
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGWRTB(INDX)
	ANDI	AC1,777
	ADDI	AC1,(COR)

	MOVEM	COR,(AC1)	;MAKE PAGED MEMORY WRITE
	SETOM	ACT
	MOVE	ACT,(AC1)	;PAGED READ VERIFY
	CAME	COR,ACT
	ERROR	PGWRT3,13,COR,ACT,DATA ERROR,PAGED REREAD,PGWRTX
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	PGWRT3,13,COR,ACT,DATA ERROR,DIRECT REREAD,PGWRTX
	AOS	AC
	AOBJN	INDX,PGWRT3

PGWRT4:	MOVSI	INDX,-440	;CHECK DATA WRITE BLOCK
	MOVEI	AC,340		;USING DIRECT ADDRESSING

	MOVE	COR,AC
	LSH	COR,^D9		;SETUP COMPARE WORD
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	PGWRT2,13,COR,ACT,DATA ERROR,DIRECT READ,PGWRTY
	AOS	AC
	AOBJN	INDX,PGWRT4+2

PGWRT5:	SETZM	PGWRTB		;CLEAR DATA AREA
	MOVE	AC,[PGWRTB,,PGWRTB+1]
	BLT	AC,PGWRTB+437
	MOVSI	INDX,-440
	MOVEI	AC,777

PGWRT6:	MOVE	COR,AC		;MAKE REVERSE PAGED MEMORY WRITE
	LSH	COR,^D9
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGWRTB+437
	SUBI	AC1,(INDX)
	ANDI	AC1,777
	ADDI	AC1,(COR)
	MOVEM	COR,(AC1)	;PERFORM PAGED WRITE
	SETOM	ACT
	MOVE	ACT,(AC1)	;PAGED REREAD VERIFY
	CAME	COR,ACT
	ERROR	PGWRT6,13,COR,ACT,DATA ERROR,REVERSE PAGED REREAD,PGWRTX
	MOVEI	AC2,PGWRTB+437
	SUBI	AC2,(INDX)
	MOVE	ACT,(AC2)
	CAME	COR,ACT
	ERROR	PGWRT6,13,COR,ACT,DATA ERROR,REVERSE DIRECT REREAD,PGWRTZ
	SOS	AC
	AOBJN	INDX,PGWRT6
PGWRT7:	MOVSI	INDX,-440
	MOVEI	AC,340

	MOVE	COR,AC		;CHECK DATA WRITE BLOCK
	LSH	COR,^D9		;USING DIRECT ADDRESSING
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	PGWRT5,13,COR,ACT,DATA ERROR,DIRECT READ,PGWRTY
	AOS	AC
	AOBJN	INDX,PGWRT7+2

	REPTLP	PGWRT0+2	;CYCLE
	JRST	PFT0-2

PGWRTX:	PSIXM	SIXBTZ	<REF TO >
	MOVE	AC1
	PNT6
	PCRL
	RTN

PGWRTY:	PSIXM	SIXBTZ	<REF TO >
	MOVEI	PGWRTB(INDX)
	PNT6
	PCRL
	RTN

PGWRTZ:	PSIXM	SIXBTZ	<REF TO >
	MOVE	AC2
	PNT6
	PCRL
	RTN
SUBTTL	TEST PAGE FAIL WORD

SALL
T=	SIXBTZ	PAGE FAIL WORD TEST
LALL

;*VERIFY THAT THE PROPER PAGE FAIL CODE OCCURS ON A PAGED READ
;*TO AN AREA WITHOUT THE ACCESS BIT BUT WITH THE PUBLIC,
;*WRITEABLE,SOFTWARE & CACHE BIT.

	SUBTST
PFT0:	MOVE	REPT,RPEAT
	SETZM	200
	MOVE	[200,201]
	BLT	417		;CLEAR PAGE MAP

	MOVSI	360000!<PGW400_-^D9>
	MOVEM	200		;SETUP PAGE MAP WORD

	MOVEI	PFT2
	MOVEM	LPGFTR		;SETUP FOR PAGE FAIL

PFT1:	SETOM	PGW400
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	COR
	SETZB	0,ACT

	MOVE	ACT,400000!<PGW400&777>	;MAKE PAGED READ

	MOVE	ACT,PGW400
	ERROR	PFT1,13,COR,ACT,TRAP FAILED,FATAL
	JRST	PFT3			;FATAL
PFT2:	CAME	COR,ACT
	ERROR	PFT1,13,COR,ACT,PAGE FAIL STORED IN AC

	MOVE	ACT,0
	CAME	COR,ACT
	ERROR	PFT1,13,COR,ACT,PAGE FAIL STORED IN 0

	MOVE	COR,[001000,,400000!<PGW400&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	PFT1,13,COR,ACT,PAGE FAIL WORD WRONG

	REPTLP	PFT0+1

PFT3:	MOVE	PGFAIL		;RESTORE PAGE FAIL
	MOVEM	LPGFTR
SUBTTL	TEST WRITE PROTECTED PAGING

;*TRYING TO WRITE INTO A WRITE PROTECTED AREA
;*SHOULD CAUSE A PAGE FAILURE

SALL
T=	SIXBTZ	WRITE PROTECT TEST
LALL

	SUBTST
WRTP0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR AND SETUP PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVSI	AC,640000!<PGW400_-^D9>
	MOVEM	AC,200
	MOVEI	AC,400000!<PGW777_-^D9>
	MOVEM	AC,377
	MOVEI	AC,WRTPF
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL

WRTP1:	SETZM	PGW400
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	COR
	SETZB	0,ACT
	SETOM	400000!<PGW400&777>	;MAKE PAGED WRITE
	MOVE	ACT,PGW400
	ERROR	WRTP1,13,COR,ACT,TRAP FAILED,ADR 400XXX
	JRST	WRTP1

WRTPF:	SETZM	COR
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,PAGE FAIL STORED IN AC,ADR 400XXX
	MOVE	ACT,0
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,PAGE FAIL STORED IN 0,ADR 400XXX
	MOVE	COR,[131000,,400000!<PGW400&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,PAGE FAIL WORD WRONG,ADR 400XXX
WRTP2:	SETZM	COR
	MOVE	ACT,PGW400
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,DATA WORD WRONG,ADR 400XXX

WRTP3:	MOVEI	AC,WRTPF1
	MOVEM	AC,LPGFTR
	SETOM	PGW777
	SETOM	COR
	SETOM	ACT
	SETZM	777000!<PGW777&777>	;MAKE PAGED WRITE
	MOVE	ACT,PGW777
	ERROR1	13,COR,ACT,TRAP FAILED,ADR 777XXX
	JRST	WRTP3
WRTPF1:	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,PAGE FAIL STORED IN AC,ADR 777XXX
	MOVE	COR,[111000,,777000!<PGW777&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,PAGE FAIL WORD WRONG,ADR 777XXX

WRTP4:	SETOM	COR
	MOVE	ACT,PGW777
	CAME	COR,ACT
	ERROR	WRTP1,13,COR,ACT,DATA WORD WRONG,ADR 777XXX

	REPTLP	WRTP0+1

	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR	;RESET PAGE FAIL TRAP
SUBTTL	PAGED BLT PAGING AND ADDRESSING TEST

;*CHECKS THAT ADDRESSING FROM 340000 TO 777777 WORKS.
;*ALL PAGING REFERENCES RELOCATE INTO ACTUAL ADDRESSES 76000 TO 76777.
;*BLT USES ALL ADDRESS FROM 340000 TO 777777.

SALL
T=	SIXBTZ	PAGED BLT TEST
LALL

	SUBTST
BLT0:	MOVE	REPT,RPEAT
	MOVSI	INDX,-440/2	;SETUP PAGE MAP SO ALL ADDRESSES
	MOVEI	AC,340		;POINT TO 76XXX.
	MOVE	AC2,[740076,,740076]
BLT1:	HRRZ	AC1,AC
	LSH	AC1,-1
	CAIGE	AC1,200
	ADDI	AC1,220
	MOVEM	AC2,(AC1)
	ADDI	AC,2
	AOBJN	INDX,BLT1

BLT2:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	340000		;SET FIRST ADDRESS TO ALL ZEROS
	MOVE	AC,[340000,,340001]
	BLT	AC,777777	;BLT TO MAXIMUM

BLT3:	MOVSI	INDX,-1000	;CHECK DATA AREA WITH DIRECT ADDRESSING
	MOVEI	COR,76000(INDX)
	MOVE	ACT,76000(INDX)
	CAME	ACT,[0]
	ERROR	BLT1,13,COR,ACT,NOT ALL ZEROS,<REF TO (CORRECT)>
	AOBJN	INDX,BLT3+1
BLT4:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETOM	340000		;SET FIRST ADDRESS TO ALL ONES
	MOVE	AC,[340000,,340001]
	BLT	AC,777777	;BLT TO MAXIMUM

BLT5:	MOVSI	INDX,-1000	;CHECK DATA AREA WITH DIRECT ADDRESSING
	MOVEI	COR,76000(INDX)
	MOVE	ACT,76000(INDX)
	CAME	ACT,[-1]
	ERROR	BLT4,13,COR,ACT,NOT ALL ONES,<REF TO (CORRECT)>
	AOBJN	INDX,BLT5+1

BLT6:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	ACT,[525252,,525252]
	MOVEM	ACT,340000	;SET FIRST ADDRESS TO ALT BITS
	MOVE	AC,[340000,,340001]
	BLT	AC,777777	;BLT TO MAXIMUM
BLT7:	MOVSI	INDX,-1000	;CHECK DATA AREA WITH DIRECT ADDRESSING
	MOVEI	COR,76000(INDX)
	MOVE	ACT,76000(INDX)
	CAME	ACT,[525252,,525252]
	ERROR	BLT6,13,COR,ACT,NOT ALT BITS,<REF TO (CORRECT)>
	AOBJN	INDX,BLT7+1

BLT8:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	ACT,[252525,,252525]
	MOVEM	ACT,340000	;SET FIRST ADDRESS TO ALT BITS
	MOVE	AC,[340000,,340001]
	BLT	AC,777777	;BLT TO MAXIMUM

BLT9:	MOVSI	INDX,-1000	;CHECK DATA AREA WITH DIRECT ADDRESSING
	MOVEI	COR,76000(INDX)
	MOVE	ACT,76000(INDX)
	CAME	ACT,[252525,,252525]
	ERROR	BLT8,13,COR,ACT,NOT ALT BITS,<REF TO (CORRECT)>
	AOBJN	INDX,BLT9+1

	REPTLP	BLT0+1
SUBTTL	TEST BASE REGISTER RELOCATION

;*SETUP PAGE MAP PAGES AS PAGE 76
;*SETUP PAGE 0 PAGE MAP FOR ERRORS
;*SETUP BASE REGISTERS
;*TEST MUUO FOR PAGE 0 AND FOR PAGE 76
;*TEST THAT EXEC PAGE FAIL WORD STORES CORRECTLY
;*IN PAGE 76 USING USER BASE REGISTER RELOCATION.

SALL
T=	SIXBTZ	BASE REGISTER RELOCATION TEST
LALL

	SUBTST
RLBAS0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	200		;CLEAR PAGE 0 PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	SETZM	76200		;CLEAR RELOC PAGE PAGE MAP
	MOVE	AC,[76200,,76201]
	BLT	AC,76417
	MOVE	[540000,,540001]
	MOVEM	76600		;SETUP LOWER EXEC PAGING
	MOVSI	1,-157
	ADD	[2,,2]
	MOVEM	76601(1)
	AOBJN	1,.-2
	MOVE	41
	MOVEM	76000!LUUOI	;SETUP LUUO
	MOVE	42
	MOVEM	76000!42	;SETUP INTERRUPT
	MOVE	LPGFTR
	MOVEM	76000!LPGFTR	;SETUP PAGE FAIL
	MOVE	[JFCL]
	MOVEM	76000!LAROVT	;SETUP ARITH TRAP
	MOVE	LPDOVT
	MOVEM	76000!LPDOVT	;SETUP PDL OV TRAP
	MOVE	LTRP3T
	MOVEM	76000!LTRP3T	;SETUP TRAP 3 TRAP
	MOVE	LKNTRP
	MOVEM	76000!LKNTRP	;SETUP MUUO AS ERROR
	MOVEM	76000!LKTRP
	MOVEM	76000!LSNTRP
	MOVEM	76000!LSTRP
	MOVEM	76000!LCNTRP
	MOVEM	76000!LCTRP
	MOVEM	76000!LPNTRP
	MOVEM	76000!LPTRP
;*TEST USER BASE REGISTER RELOCATION
;*BY USING AN MUUO OF 0,,654321.

;*TEST MUUO FIRST WITH EPMP & UPMP AS PAGE 0.

RLBAS1:	MOVEI	AC,RLBMU1	;SETUP MUUO TO RETURN
	MOVEM	AC,LKNTRP	;FROM PAGE 0
	MOVEI	AC,RLBMU3
	MOVEM	AC,76000!LKNTRP	;FROM RELOCATED PAGE

RLBAS2:	SETZM	COR
	MOVEI	ACT,.+3
	JRSTF	@.+1		;CLEAR FLAGS
		.+1
RLBMU0:	0,,654321		;DO AN MUUO OF 0,,654321
	ERROR	RLBAS2,13,COR,ACT,MUUO FAILED,<COR=MUUO, ACT=MUUO ADR>

RLBMU1:	MOVEI	COR,654321
	MOVE	ACT,LMUUO
	CAME	COR,ACT
	ERROR	RLBAS2,13,COR,ACT,MUUO STORED WRONG,PAGE 0
	MOVEI	COR,RLBMU0+1
	MOVE	ACT,LMUUOP
	CAME	COR,ACT
	ERROR	RLBAS2,13,COR,ACT,MUUO PC STORED WRONG,PAGE 0
;*TEST THAT WITH UPMP RELOCATED TO PAGE 76
;*AN MUUO TRAPS CORRECTLY AND RETRIEVES NEW PC
;*FROM RELOCATED USER PAGE MAP PAGE.
;*ALSO TEST THAT MUUO AND TRAPPED PC GET STORED CORRECTLY
;*IN RELOCATED UPMP.

RLBAS3:	DATAO	PAG,[LLDUSB,,400076]	;RELOCATE USER BASE REG
	SETZM	COR
	MOVEI	ACT,.+3
	JRSTF	@.+1
		.+1
RLBMU2:	0,,123456		;DO AN MUUO OF 0,,123456
	DATAO	PAG,[LLDUSB,,400000]
	ERROR	RLBAS3,13,COR,ACT,MUUO FAILED,<COR=MUUO, ACT=MUUO ADR>

RLBMU3:	DATAO	PAG,[LLDUSB,,400000]
	MOVEI	COR,123456
	MOVE	ACT,76000!LMUUO
	CAME	COR,ACT
	ERROR	RLBAS3,13,COR,ACT,MUUO STORED WRONG,RELOCATED PAGE
	MOVEI	COR,RLBMU2+1
	MOVE	ACT,76000!LMUUOP
	CAME	COR,ACT
	ERROR	RLBAS3,13,COR,ACT,MUUO PC STORED WRONG,RELOCATED PAGE
;*TEST USER BASE REGISTER RELOCATION
;*BY USING EXEC PAGE FAIL WORD

RLBAS4:	MOVE	AC,MUUOER#
	MOVEM	AC,LKNTRP
	MOVEM	AC,76000!LKNTRP
	MOVEI	AC,RLPFL
	MOVEM	AC,76000!LPGFTR	;SETUP PAGE FAIL TRAP
RLPF1:	SETOM	76000!LEUPFW
	MOVEI	COR,777777
	SETOM	ACT
	DATAO	PAG,[LLDUSB,,400076]
	MOVE	ACT,777777		;SHOULD PAGE FAIL
	ERROR	RLPF1,13,COR,ACT,PAGE FAIL FAILED,REF TO 777777

RLPFL:	SETOM	COR
	CAME	COR,ACT
	ERROR	RLPF1,13,COR,ACT,PAGE FAIL STORED IN AC,REF TO 777777
	MOVE	COR,[1000,,777777]	;SETUP CORRECT WORD
	MOVE	ACT,76000!LEUPFW
	CAME	COR,ACT
	ERROR	RLPF1,13,COR,ACT,PAGE FAIL WORD WRONG,REF TO 777777

RLBAS5:	DATAO	PAG,[LLDUSB,,400000]
	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR
	REPTLP	RLBAS0+1
;*TEST BASE REGISTER RELOCATION
;*BY USING EXEC-PER-PROCESS PAGING
;*AND PAGING REFILL DATA FROM RELOCATED PAGE
;*WITH USER BASE REGISTER SET TO PAGE 76.

SALL
T=	SIXBTZ	RELOCATED EXEC-PER-PROCESS PAGING
LALL

	SUBTST
RLBAS6:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10	;FSTCYL=10 PASSES, REL=100 PASSES
	MOVSI	INDX,-40/2
	MOVEI	AC,340

RLWRT1:	MOVEI	AC2,PGWRTB(INDX)
	LSH	AC2,-^D9	;SETUP RELOCATED PAGE PAGE MAP
	ADDI	AC2,540000	;FOR RELOCATION OF PAGES
	HRL	AC3,AC2		;340-377 TO EXEC DATA AREA
	MOVEI	AC2,PGWRTB+1(INDX)
	LSH	AC2,-^D9
	ADDI	AC2,540000
	HRR	AC3,AC2
	HRRZ	AC1,AC
	LSH	AC1,-1
	ADDI	AC1,220
	MOVEM	AC3,76000(AC1)	;WRITE PAGING DATA
	ADDI	AC,2
	AOS	INDX
	AOBJN	INDX,RLWRT1

RLWRT2:	SETZM	PGWRTB
	MOVE	AC,[PGWRTB,,PGWRTB+1]
	BLT	AC,PGWRTB+37	;CLEAR DATA AREA
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400076]
	MOVSI	INDX,-40
	MOVEI	AC,340
RLWRT3:	MOVE	COR,AC		;SETUP DATA
	LSH	COR,^D9		;AND PAGING ADDRESS
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGWRTB(INDX)
	ANDI	AC1,777
	ADDI	AC1,(COR)

	MOVEM	COR,(AC1)	;MAKE PAGED MEMORY WRITE
	MOVE	ACT,(AC1)	;PAGED READ VERIFY
	CAME	COR,ACT
	ERROR	RLWRT2,13,COR,ACT,DATA ERROR,PAGED REREAD,PGWRTX
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	RLWRT2,13,COR,ACT,DATA ERROR,DIRECT REREAD,PGWRTY
	AOS	AC
	AOBJN	INDX,RLWRT3

RLWRT4:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVSI	INDX,-40	;CHECK DATA BLOCK USING
	MOVEI	AC,340		;DIRECT ADDRESSING

	MOVE	COR,AC
	LSH	COR,^D9
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	RLWRT2,13,COR,ACT,DATA ERROR,DIRECT READ,PGWRTY
	AOS	AC
	AOBJN	INDX,RLWRT4+4
;*TEST THAT A TRAP FROM THE EXEC-PER-PROCESS AREA
;*USES THE CORRECT BASE REGISTER

EPPT0:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400076]

	MOVE	[JRST 1,340001]	;PORTAL
	MOVEM	340000
	MOVE	[JRSTF @340002]	;SET FLAGS
	MOVEM	340001
	MOVE	[TN0!TN1,,340003] ;TO CAUSE TRAP 3
	MOVEM	340002
	MOVE	[JRST 340003]	;IF NO TRAP, HANG
	MOVEM	340003

	MOVE	[JSR EPPT2]	;SHOULD TRAP USING EBR
	MOVEM	LTRP3T
	MOVE	[JSR EPPT1]	;ERROR IF USED UBR
	MOVEM	76000!LTRP3T

	JRST	340000		;TO PER-PROCESS AREA

EPPT1:	0
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	ERROR	RLBAS6+2,13,0,0,EPP ADR TRAP ERROR,TRAPPED USING UBR
	JRST	EPPT3
EPPT2:	0
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	LTRP3SV
	MOVEM	LTRP3T
	MOVE	COR,[0,,340003]
	MOVE	ACT,EPPT2
	CAME	COR,ACT
	ERROR	RLBAS6+2,13,COR,ACT,EPP ADR TRAP ERROR,SAVED PC WRONG

EPPT3:	REPTLP	RLBAS6+2

XLIST
REPEAT	0,<
;*TEST EXEC BASE REGISTER RELOCATION
;*BY USING AN LUUO
;*LUUO SERVICE INSTRUCTION IN PAGE 76.
;*AND EXEC BASE REGISTER SET TO PAGE 76.

SALL
T=	SIXBTZ	EXEC BASE REGISTER RELOCATION
LALL

	SUBTST
RLLUO0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR PAGE  0 PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	CONO	PAG,LTRPEN		;CLEAR MEMORIES, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	AC,[JSR RLLUO1]
	MOVEM	AC,76000!LUUOI	;SETUP RELOCATED PAGE LUUO INST
	MOVE	AC,[JSR RLLUO2]	;SETUP PAGE 0 LUUO
	MOVEM	AC,LUUOI

	CONO	PAG,LTRPEN!76	;SETUP BASE REG
RLLUO3:	1B8			;DO AN LUUO
	CONO	PAG,LTRPEN
	MOVE	LUUOISV
	MOVEM	LUUOI
	ERROR1	13,COR,ACT,LUUO FAILED,FATAL
	JRST	RLLUO0

RLLUO2:	0
	CONO	PAG,LTRPEN
	MOVE	LUUOISV
	MOVEM	LUUOI
	MOVE	COR,RLLUO3
	MOVE	ACT,LUUO
	ERROR1	13,COR,ACT,RELOCATION FAILED,LUUO TRAPPED TO PAGE 0
	ERLOOP	RLLUO3-1
	JRST	RLLUO0
RLLUO1:	0
	CONO	PAG,LTRPEN
	MOVE	LUUOISV
	MOVEM	LUUOI
	MOVE	COR,RLLUO3
	MOVE	ACT,76000!LUUO
	CAME	COR,ACT
	ERROR1	13,COR,ACT,RELOCATION SUCCEEDED,LUUO STORED WRONG
	ERLOOP	RLLUO3-1

	REPTLP	RLLUO3-1

>
LIST
;*TEST BASE REGISTER RELOCATION
;*BY USING PAGE FAULT TRAP

	SUBTST
RLPFT0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVEI	AC,RLPFT1
	MOVEM	AC,76000!LPGFTR	;SETUP PAGE PAGE FAULT
	MOVEI	AC,RLPFT2
	MOVEM	AC,LPGFTR		;SETUP PAGE 0 PAGE FAULT

	SETZM	76400
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400076]	;SETUP BASE REG
RLPFT3:	MOVE	ACT,340000	;DO PAGING, SHOULD FAULT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	ERROR1	13,COR,ACT,PAGE FAULT FAILED,FATAL
	JRST	RLPFT4

RLPFT2:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,LEUPFW
	ERROR1	13,COR,ACT,RELOCATION FAILED,PAGE FAIL TRAPPED TO PAGE 0
	JRST	RLPFT4			;FATAL

RLPFT1:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,[1000,,340000]
	MOVE	ACT,76000!LEUPFW
	CAME	COR,ACT
	ERROR1	13,COR,ACT,RELOCATION SUCCEEDED,PAGE FAIL WORD WRONG
	ERLOOP	RLPFT3-2

	REPTLP	RLPFT0+1

RLPFT4:	MOVE	PGFAIL
	MOVEM	LPGFTR
;*TEST BASE REGISTER RELOCATION
;*BY USING TRAPPING

	SUBTST
RLTRP0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]

;*TEST RELOCATED TRAP 3

RLTRP1:	MOVE	AC,[JSR	RLTP3]
	MOVEM	AC,76000!LTRP3T
	CONO	PAG,LTRPEN!76
	JRSTF	@.+1
	TN0!TN1,,.+1
RLTP3X:	CONO	PAG,LTRPEN
	ERROR1	13,0,0,TRAP 3 FAILED,FATAL
	JRST	RLTP4

RLTP3:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,RLTP3X]
	MOVE	ACT,RLTP3
	CAME	COR,ACT
	ERROR	RLTRP1,13,COR,ACT,TRAP 3 SAVED PC
RLTP4:
;*TEST RELOCATED TRAP 2

	MOVE	AC,[JSR RLPDL]
	MOVEM	AC,76000!LPDOVT
	CONO	PAG,LTRPEN!76
	JRSTF	@.+1
	TN0,,.+1
RLPDLX:	CONO	PAG,LTRPEN
	ERROR1	13,0,0,TRAP 2 FAILED,FATAL
	JRST	RLPDL1

RLPDL:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,RLPDLX]
	MOVE	ACT,RLPDL
	CAME	COR,ACT
	ERROR	RLTRP1,13,COR,ACT,TRAP 2 SAVED PC
RLPDL1:
;*TEST RELOCATED TRAP 1

	MOVE	AC,[JSR RLAROV]
	MOVEM	AC,76000!LAROVT
	CONO	PAG,LTRPEN!76
	JRSTF	@.+1
	TN1,,.+1
RLAROX:	CONO	PAG,LTRPEN
	ERROR1	13,0,0,TRAP 1 FAILED,FATAL
	JRST	RLARO1

RLAROV:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,RLAROX]
	MOVE	ACT,RLAROV
	CAME	COR,ACT
	ERROR	RLTRP1,13,COR,ACT,TRAP 1 SAVED PC

	MOVE	AC,[JFCL]
	MOVEM	AC,76000!LAROVT

	REPTLP	RLTRP0+1
RLARO1:
SUBTTL	TEST INTERRUPT RELOCATION

;*SET PAGE 0 INTERRUPT LOCATIONS AS ERROR
;*SETUP RELOCATED PAGE INTERRUPT LOCATIONS FOR TESTING
;*RELOCATE EXEC BASE REGISTER
;*TEST INTERRUPTS

SALL
T=SIXBTZ	RELOCATED INTERRUPT TEST
LALL

	SUBTST
RLINT0:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10	;FSTCYL=10 PASSES, REL =100 PASSES
	MOVE	[JSR RLITR1]	;SETUP RELOC PAGE INTERRUPTS
	MOVEM	76000!42
	MOVE	[JSR RLITR2]
	MOVEM	76000!44
	MOVE	[JSR RLITR3]
	MOVEM	76000!46
	MOVE	[JSR RLITR4]
	MOVEM	76000!50
	MOVE	[JSR RLITR5]
	MOVEM	76000!52
	MOVE	[JSR RLITR6]
	MOVEM	76000!54
	MOVE	[JSR RLITR7]
	MOVEM	76000!56

	MOVE	[JSR RLIERR]	;SETUP PAGE 0 FOR ERROR
	MOVEM	56
	MOVEM	54
	MOVEM	52
	MOVEM	50
	MOVEM	46
	MOVEM	44
	MOVEM	42

RLINT1:	CONO	PI,LPICLR!LCHNOF!LPIOFF
	CONO	APR,LIOCLR
	JRST	RLINT2
;*PAGE 0 INTERRUPT ERROR HANDLER

RLIERR:	0
	CONO	PAG,LTRPEN
	CONI	APR,COR
	CONI	PI,ACT
	CONO	APR,LIOCLR
	CONO	PI,LPICLR!LCHNOF!LPIOFF
	ERROR1	13,COR,ACT,PAGE 0 INTERRUPT ERROR,<COR=APR, ACT=PI>
	JRST	RLINT1

;*RELOCATED INTERRUPT MACRO'S

DEFINE	RLITRX	(PICHN,APRCHN)<
;*SETUP PI AND APR SO CLOCK INTERRUPTS ON PROPER CHANNEL.
;*INTERRUPT SHOULD PERFORM JSR INSTRUCTION FROM
;*PAGE MAP RELOCATED TO PAGE 76.
;*INTERRUPT CHANNEL = APRCHN.

	CONO	PI,LCHNON!LPION!PICHN
	CONO	APR,LSPAER!LEPAER!APRCHN
	MOVEI	AC,1000
	SOJG	AC,.
	HALT	.		;IF NO INTERRUPT, FATAL
>

DEFINE	RLITRC	(ITRCHN)<
;*INTERRUPT RETURNED PROPERLY, INTERRUPT CHANNEL = ITRCHN

	0			;RETURN, CHANNEL ITRCHN
	CONO	APR,LDPAER!LCPAER
	CONO	PI,LPICLR!LCHNOF!LPIOFF
>
RLINT2:	CONO	PAG,LTRPEN!76

	LALL
RLINT3:	RLITRX	(1,7)
RLITR7:	RLITRC	(7)

RLINT4:	RLITRX	(2,6)
RLITR6:	RLITRC	(6)

RLINT5:	RLITRX	(4,5)
RLITR5:	RLITRC	(5)

RLINT6:	RLITRX	(10,4)
RLITR4:	RLITRC	(4)

RLINT7:	RLITRX	(20,3)
RLITR3:	RLITRC	(3)

RLINT8:	RLITRX	(40,2)
RLITR2:	RLITRC	(2)

RLINT9:	RLITRX	(100,1)
RLITR1:	RLITRC	(1)

	REPTLP	RLINT1

RLINTA:	CONO	PAG,LTRPEN
	CONO	PI,LPICLR!LCHNOF!LPIOFF
	CONO	APR,LIOCLR!LDPAER!LCPAER

	MOVE	AC,[JSR ITRCH1]	;RESET INTERRUPTS
	MOVEM	AC,42
	CONO	APR,LAPRAL
	CONO	PI,LCHNON!LPION!LPICH1
SUBTTL	TEST PAGE REFILL RELOCATION

;*BY PUTTING REFILL DATA IN PAGE 76.
;*AND RELOCATING EXEC BASE REGISTER

SALL
T=SIXBTZ	RELOCATED EPMP REFILL PAGING
LALL

	SUBTST
RLEPM0:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10	;FSTCYL=10 PASSES, REL=100 PASSES
	MOVSI	INDX,-400/2
	MOVEI	AC,400

RLEPM1:	MOVEI	AC2,PGWRTB(INDX)	;SETUP RELOCATION DATA
	LSH	AC2,-^D9
	ADDI	AC2,740000
	HRL	AC3,AC2
	MOVEI	AC2,PGWRTB+1(INDX)
	LSH	AC2,-^D9
	ADDI	AC2,740000
	HRR	AC3,AC2
	HRRZ	AC1,AC		;SETUP PAGE MAP ADDRESS
	LSH	AC1,-1
	MOVEM	AC3,76000(AC1)	;PUT MAPPING DATA IN PAGE 76.
	ADDI	AC,2
	AOS	INDX
	AOBJN	INDX,RLEPM1

RLEPM2:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	PGWRTB		;CLEAR DATA AREA
	MOVE	AC,[PGWRTB,,PGWRTB+1]
	BLT	AC,PGWRTB+400
	MOVSI	INDX,-400
	MOVEI	AC,400
	CONO	PAG,LTRPEN!76	;RELOC EXEC BASE REG
	DATAO	PAG,[LLDUSB,,400076]
RLEPM3:	MOVE	COR,AC		;SETUP DATA
	LSH	COR,^D9
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVEI	AC1,PGWRTB(INDX)	;SETUP PAGING ADDRESS
	ANDI	AC1,777
	ADDI	AC1,(COR)
	MOVEM	COR,(AC1)	;MAKE PAGED MEMORY WRITE
	MOVE	ACT,(AC1)	;PAGED READ VERIFY
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	CAME	COR,ACT
	ERROR	RLEPM3-2,13,COR,ACT,DATA ERROR,PAGED REREAD,PGWRTX
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	RLEPM3-2,13,COR,ACT,DATA ERROR,DIRECT REREAD,PGWRTY
	AOS	AC
	AOBJN	INDX,RLEPM3-2

RLEPM4:	CONO	PAG,LTRPEN
	MOVSI	INDX,-400	;CHECK DATA BLOCK
	MOVEI	AC,400		;USING DIRECT ADDRESSING
	MOVE	COR,AC
	LSH	COR,^D9		;SETUP COMPARE WORD
	TLO	COR,-1
	TLZ	COR,(COR)
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR	RLEPM2,13,COR,ACT,DATA ERROR,DIRECT READ,PGWRTY
	AOS	AC
	AOBJN	INDX,RLEPM4+3

	REPTLP	RLEPM0+2
SUBTTL	INSTRUCTION PAGE FAIL TESTING

;*TEST BLOCK TRANSFER PAGE FAIL
;*SETUP 5 WORD BLT ACROSS PAGE BOUNDRY
;*FIRST PAGE DATA RELOCATION DATA IN PAGE MAP
;*SECOND PAGE DATA RELOCATION DATA NOT IN PAGE MAP
;*PERFORM BLT
;*SHOULD PAGE FAIL AFTER TRANSFERING 3 WORDS.
;*TEST PAGE FAIL, BLT AC, ETC.
;*REDO BLT, ON PAGE FAIL SETUP 2ND PAGE RELOCATION DATA AND CONTINUE BLT.
;*TEST FOR PROPER COMPLETION.

SALL
T=SIXBTZ	BLT PAGE FAIL
LALL

	SUBTST
PFBLT0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR AND SETUP PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVSI	AC,740000!75
	MOVEM	AC,200		;ADDRESSES 400XXX RELOCATE TO PAGE 75.
	MOVEI	AC,PFBLT3
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL

PFBLT1:	SETZB	COR,75775	;CLEAR BLT DATA AREA
	SETZM	75776
	SETZM	75777
	SETZM	76000
	SETZM	76001
	SETZM	76002
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1
	SETOM	400775		;SET FIRST BLT ADDRESS
	MOVE	ACT,[400775,,400776]

PFBLT2:	BLT	ACT,401001	;DO PAGED BLT
	ERROR1	13,COR,ACT,TRAP FAILED,<ACT=BLT AC>
	JRST	PFBLT1		;FATAL
;*BLT PAGE FAIL RETURN

PFBLT3:	MOVE	COR,[400777,,401000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT AC WRONG,

	MOVE	ACT,LEUPFW
	MOVE	COR,[011000,,401000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFBLT2]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	SETOM	COR
	MOVE	ACT,75775
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400775

	MOVE	ACT,75776
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400776
	MOVE	ACT,75777
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400777

	SETZM	COR
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 401000

	MOVE	ACT,76001
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 401001

	MOVE	ACT,76002
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 401002

	ERLOOP	PFBLT1
;*TEST BLT PAGE FAIL CONTINUE

PFBLT4:	MOVEI	AC,PFBLT5
	MOVEM	AC,LPGFTR	;SETUP PAGE FAIL TRAP
	SETZM	75775		;CLEAR DATA AREA
	SETZM	75776
	SETZM	75777
	SETZM	76000
	SETZM	76001
	SETZM	76002
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1
	SETOM	400775		;SET FIRST BLT ADDRESS
	MOVE	AC,[400775,,400776]

	BLT	AC,401001	;PERFORM PAGED BLT

;*BLT SHOULD PAGE FAIL
;*PAGE MAP IS THEN SETUP
;*AND BLT CONTINUED

	SETOM	COR
	MOVE	ACT,75775
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400775

	MOVE	ACT,75776
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400776

	MOVE	ACT,75777
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 400777
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 401000

	MOVE	ACT,76001
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT DATA WRONG,ADR 401001

	SETZM	COR
	MOVE	ACT,76002
	CAME	COR,ACT
	ERROR1	13,COR,ACT,BLT WENT TOO FAR,ADR 401002

	ERLOOP	PFBLT3

	REPTLP	PFBLT0+1

	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR	;RESET PAGE FAIL TRAP
	JRST	PFBYT0-2

;*ON PAGE FAIL, SETUP NEXT PAGE FOR BLT

PFBLT5:	MOVE	AC1,[740000!75,,740000!76]
	MOVEM	AC1,200		;SETUP PAGE MAP
	CONO	PAG,LTRPEN
	JRSTF	@LPFWPC		;RETURN
;*TEST BYTE PAGE FAIL
;*FIRST TEST WITH BYTE DATA IN UNMAPPED PAGE
;*THEN TEST WITH BYTE POINTER IN UNMAPPED PAGE.

SALL
T=SIXBTZ	BYTE PAGE FAIL
LALL

	SUBTST
PFBYT0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVEI	AC,PFBYT3
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL

PFBYT1:	SETZM	COR		;SETUP DATA AREA AND AC
	SETOM	76000
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1
	MOVE	ACT,[POINT 6,400000]

PFBYT2:	ILDB	COR,ACT		;PERFORM BYTE INSTRUCTION
	ERROR1	13,COR,ACT,ILDB TRAP FAILED,<ACT=POINTER, COR=BYTE AC>
	JRST	PFBYT1		;FATAL
;*ILDB PAGE FAIL RETURN
;*BYTE POINTER SHOULD HAVE BEEN INCREMENTED
;*PAGE FAIL SHOULD HAVE OCCURRED WHEN DATA WAS FETCHED.

PFBYT3:	SKIPE	COR
	ERROR1	13,COR,ACT,ILDB CHANGED BYTE AC,<ACT=POINTER, COR=BYTE AC>
	MOVE	COR,[POINT 6,400000,5]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,ILDB POINTER WRONG,
	SETOM	COR
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,ILDB MODIFIED BYTE SOURCE,ADR 400000
	MOVE	ACT,LEUPFW
	MOVE	COR,[1000,,400000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,
	MOVE	ACT,LPFWPC
	MOVE	COR,[BIS,,PFBYT2]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFBYT1
;*TEST DEPOSIT BYTE PAGE FAIL

PFBYT4:	MOVEI	AC,PFBYT6
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL
	SETZM	COR
	SETOM	76000		;SETUP DATA
	SETOM	LEUPFW
	JRSTF	@.+1
	0,,.+1
	MOVE	ACT,[POINT 6,400000]

PFBYT5:	IDPB	COR,ACT		;PERFORM DEPOSIT BYTE
	ERROR1	13,COR,ACT,IDPB TRAP FAILED,<ACT=POINTER, COR=BYTE AC>
	JRST	PFBYT4		;FATAL

;*IDPB PAGE FAIL RETURN

PFBYT6:	SKIPE	COR
	ERROR1	13,COR,ACT,IDPB CHANGED BYTE AC,<ACT=POINTER, COR=BYTE AC>

	MOVE	COR,[POINT 6,400000,5]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,IDPB POINTER WRONG,

	SETOM	COR
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,IDPB MODIFIED BYTE DESTINATION,ADR 400000

	MOVE	ACT,LEUPFW
	MOVE	COR,[1000,,400000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[BIS,,PFBYT5]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFBYT4
;*TEST BYTE POINTER FETCH PAGE FAIL
;*BYTE POINTER IN PAGED AREA WITH PAGE MAP CLEARED
;*THEREFORE PAGE FAIL SHOULD OCCUR ON POINTER FETCH
;*AND POINTER SHOULD NOT BE INCREMENTED.

PFBYT7:	MOVEI	AC,PFBYT9
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL
	SETZM	COR
	MOVE	ACT,[POINT 6,COR]
	MOVEM	ACT,76000	;SETUP POINTER
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFBYT8:	ILDB	COR,400000	;PERFORM BYTE INSTRUCTION
	ERROR1	13,COR,ACT,POINTER FETCH TRAP FAILED,ADR 400000
	JRST	PFBYT7		;FATAL

;*POINTER FETCH PAGE FAIL RETURN

PFBYT9:	SKIPE	COR
	ERROR1	13,COR,ACT,POINTER FETCH MODIFIED BYTE AC,

	MOVE	COR,[POINT 6,COR]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,AC 'ACT' MODIFIED,

	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,POINTER WRONG,ADR 400000
	MOVE	ACT,LEUPFW
	MOVE	COR,[011000,,400000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFBYT8]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFBYT7

	REPTLP	PFBYT0+1

	MOVE	AC,PGFAIL
	MOVEM	LPGFTR		;RESET PAGE FAIL
;*TEST DOUBLE MOVE PAGE FAIL
;*FIRST PAGE FAIL ON FIRST OPERAND FETCH
;*OPERANDS FETCHED FROM PAGED AREA WITH PAGE MAP CLEAR.

SALL
T=SIXBTZ	DOUBLE MOVE PAGE FAIL
LALL

	SUBTST
PFDMV0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVEI	AC,PFDMV3
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL
PFDMV1:	SETZB	ACT,76000
	SETZB	COR,76001
	SETOB	AC,AC1		;SETUP OPERANDS
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFDMV2:	DMOVE	AC,400000	;PERFORM DOUBLE MOVE
	ERROR1	13,COR,ACT,TRAP FAILED,ADR 400000
	JRST	PFDMV1		;FATAL

;*PAGE FAIL RETURN

PFDMV3:	SETOM	COR
	MOVE	ACT,AC
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVE MODIFIED AC,FETCH FROM 400000
	MOVE	ACT,AC1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVE MODIFIED AC1,FETCH FROM 400001
	MOVE	ACT,LEUPFW
	MOVE	COR,[1000,,400000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFDMV2]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFDMV1
;*PAGE FAIL DOUBLE MOVE ON SECOND WORD
;*DATA FOR FIRST OPERAND IN PAGE WITH RELOCATION DATA IN PAGE MAP.
;*DATA FOR SECOND OPERAND ACROSS PAGE BOUNDRY
;*PAGE MAP CLEAR FOR THAT PAGE.

PFDMV4:	MOVEI	AC,PFDMV6
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL
	MOVSI	AC,740000!75
	MOVEM	AC,200		;SETUP 1ST WORD PAGE MAP
	SETZB	COR,ACT
	SETZM	75777		;SETUP OPERANDS
	SETZM	76000
	SETOB	AC,AC1
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFDMV5:	DMOVE	AC,400777	;PERFORM DOUBLE MOVE
	ERROR1	13,COR,ACT,TRAP FAILED,
	JRST	PFDMV4		;FATAL

;*PAGE FAIL RETURN

PFDMV6:	SETOM	COR
	MOVE	ACT,AC
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVE MODIFIED AC,FETCH FROM 400777

	MOVE	ACT,AC1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVE MODIFIED AC1,FETCH FROM 401000
	MOVE	ACT,LEUPFW
	MOVE	COR,[1000,,401000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFDMV5]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFDMV4

	REPTLP	PFDMV0+1
;*TEST DOUBLE MOVE TO MEMORY PAGE FAIL
;*FIRST TEST WITH DATA DESTINATION ADDRESSES IN A PAGED AREA
;*WITH THE PAGE MAP CLEAR.

SALL
T=SIXBTZ	DBL MOVE TO MEM PAGE FAIL
LALL

	SUBTST
PFDMM0:	MOVE	REPT,RPEAT
	SETZM	200		;CLEAR PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVEI	AC,PFDMM3
	MOVEM	AC,LPGFTR	;SETUP FOR PAGE FAIL

PFDMM1:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETZB	ACT,76000
	SETZB	COR,76001	;SETUP OPERANDS
	SETOB	AC,AC1
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFDMM2:	DMOVEM	AC,400000	;PERFORM DOUBLE MOVE
	ERROR1	13,COR,ACT,TRAP FAILED,ADR 400000
	JRST	PFDMM1		;FATAL

;*PAGE FAIL RETURN

PFDMM3:	SETZM	COR
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC DESTINATION,ADR 400000

	MOVE	ACT,76001
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC1 DESTINATION,ADR 400001

	SETOM	COR
	MOVE	ACT,AC
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC,

	MOVE	ACT,AC1
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC1,

	MOVE	ACT,LEUPFW
	MOVE	COR,[011000,,400001]	;KS-10 DIFF FROM KL, KL =011000,,400000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFDMM2]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFDMM1
;*TEST DOUBLE MOVE TO MEMORY PAGE FAIL
;*PAGE FAIL ON SECOND WORD.
;*PAGE MAP SETUP SO FIRST OPERAND IS STORED IN PAGE
;*WITH RELOCATION DATA IN PAGE MAP.
;*SECOND OPERAND STORE IS ACROSS PAGE BOUNDRY WITH
;*PAGE MAP CLEAR FOR THAT PAGE.

PFDMM4:	MOVEI	AC,PFDMM6
	MOVEM	AC,LPGFTR
	MOVSI	AC,740000!75
	MOVEM	AC,200		;SETUP 1ST WORD PAGE MAP
	SETZM	75777
	SETZM	76000
	SETOB	AC,AC1
	SETOM	LEUPFW
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFDMM5:	DMOVEM	AC,400777	;PERFORM DOUBLE MOVE
	ERROR1	13,COR,ACT,TRAP FAILED,2ND WORD DMOVEM
	JRST	PFDMM4		;FATAL

;*PAGE FAIL RETURN

PFDMM6:	SETZM	COR
	MOVE	ACT,75777
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC DESTINATION,ADR 400777

	SETZM	COR
	MOVE	ACT,76000
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM MODIFIED AC1 DESTINATION,ADR 401000
	MOVE	ACT,LEUPFW
	MOVE	COR,[011000,,401000]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFDMM5]
	CAME	COR,ACT
	ERROR1	13,COR,ACT,<SAVED FLAGS,,PC WRONG>,

	ERLOOP	PFDMM4

	REPTLP	PFDMM0+1

	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR		;RESET PAGE FAIL
SUBTTL	TRAP INSTRUCTION PAGE FAIL TEST

;*CAUSE A TRAP, THE TRAP "JSR" IS TO A PAGED ADDRESS THAT PAGE FAILS
;*PAGE FAIL ROUTINE VERIFIES PAGE FAIL INFO & CORRECT PC WORD
;*PAGE TABLE THEN SETUP AND TRAP CONTINUED
;*TRAP SHOULD THEN COMPLETE
;*TRAP HANDLER THEN VERIFIES CORRECT PC WORD

SALL
T=	SIXBTZ	TRAP INSTRUCTION PAGE FAIL
LALL

	SUBTST
TIPF0:	MOVE	REPT,RPEAT
	SETZM	200			;CLEAR PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417

	MOVEI	AC,TIPF2		;SETUP PAGE FAIL TRANSFER
	MOVEM	AC,LPGFTR
	MOVE	AC,[JSR	400000!<TIPF4&777>]
	MOVEM	AC,LTRP3T		;SETUP TRAP 3 TRANSFER

	SETOM	LEUPFW			;PRESET PAGE FAIL WORDS
	SETOM	LPFWPC

	CONO	PAG,LTRPEN		;ENABLE TRAPPING
	DATAO	PAG,[LLDUSB,,400000]

	JRSTF	@.+1			;CAUSE TRAP 3
	TN0!TN1,,TIPFX

TIPF1:	CONO	PAG,LTRPEN		;IF GET HERE, TRAP DID NOT HAPPEN
	ERROR1	13,0,0,TRAP FAILED,FATAL
	JRST	TIPF0

TIPFX:	CONO	PAG,LTRPEN
	ERROR1	13,0,0,JRSTF HAPPENED,NO TRAP
	JRST	TIPF0
;*HERE IF PAGE FAIL TRAP HAPPENED

TIPF2:	MOVE	PGFAIL			;RESTORE PAGE FAIL TRAP
	MOVEM	LPGFTR

	MOVE	COR,[011000,,400000!<TIPF4&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	TIPF0+1,13,COR,ACT,PAGE FAIL WORD WRONG

	MOVE	COR,[TN0!TN1,,TIPFX]
	MOVE	ACT,LPFWPC
	CAME	COR,ACT
	ERROR	TIPF0+1,13,COR,ACT,<SAVED FLAGS,,PC WRONG>,PAGE FAIL

	CAME	COR,ACT
	JRST	TIPF3+4			;IF SAVED PC WRONG, CAN'T CONT
;*SETUP FOR PAGE FAIL TRAP CONTINUE

TIPF3:	MOVSI	AC,540000!<TIPFX_-^D9>
	MOVEM	AC,200			;SETUP PAGE MAP
	CONO	PAG,LTRPEN		;***CAUSE REFILL***

	JRSTF	@LPFWPC			;CONTINUE TRAP

	ERROR1	13,0,0,PAGE FAIL CONTINUE FAILED,FATAL
	JRST	TIPF10-2

;*HERE IF TRAP CONTINUED PROPERLY

TIPF4:	0				;JSR SHOULD COME HERE
	MOVE	LTRP3SV
	MOVEM	LTRP3T			;RESET TRAP
	JSP	ACT,TIPF5		;GET CURRENT RELOCATED PC
TIPF5:	MOVE	COR,[0,,400000!<TIPF5&777>]
	CAME 	COR,ACT
	ERROR	TIPF0+1,13,COR,ACT,RELOCATION INCORRECT,PF CONTINUE
	MOVE	COR,[0,,TIPFX]
	MOVE	ACT,TIPF4
	CAME	COR,ACT
	ERROR	TIPF0+1,13,COR,ACT,TRAP SAVED PC WRONG,PF CONTINUE

	REPTLP	TIPF0+1
;*CAUSE A TRAP TO A PAGE FAIL PAGE
;*TRAP HANDLER THEN VERIFIES CORRECT PC WORD

SALL
T=SIXBTZ	TRAP PAGE FAIL
LALL

	SUBTST
TIPF10:	MOVE	REPT,RPEAT
	SETZM	200
	MOVE	AC,[200,,201]
	BLT	AC,417		;CLEAR PAGE MAP

	MOVEI	AC,TIPF12	;SETUP PAGE FAIL TRANSFER
	MOVEM	AC,LPGFTR
	MOVE	AC,[JSR TIPF14]
	MOVEM	AC,LTRP3T	;SETUP TRAP 3 TRANSFER

	SETOM	LEUPFW		;PRESET PAGE FAIL WORD
	SETOM	LPFWPC	

	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]

	JRSTF	@.+1		;CAUSE TRAP 3
	TN0!TN1,,400000!<TIPF1X&777>

TIPF11:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	PGFAIL
	MOVEM	LPGFTRP
	ERROR	TIPF10,13,0,0,TRAP FAILED,FATAL
	JRST	TIPF10

TIPF1X:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	PGFAIL
	MOVEM	LPGFTR
	ERROR	TIPF10,13,0,0,JRSTF HAPPENED,NO TRAP
	JRST	TIPF10
;*HERE IF TRAP HAPPENED WITHOUT PAGE FAIL

TIPF14:	0
	MOVE	PGFAIL
	MOVEM	LPGFTR
	ERROR	TIPF10,13,0,0,TRAP 3 HAPPENED,NO PAGE FAIL
	JRST	TIPF10

;*HERE IF PAGE FAIL TRAP HAPPENED

TIPF12:	MOVE	PGFAIL
	MOVEM	LPGFTR

	MOVE	COR,[001000,,400000!<TIPF1X&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	TIPF10+1,13,COR,ACT,PAGE FAIL WORD WRONG

	MOVE	COR,[TN0!TN1,,400000!<TIPF1X&777>]
	MOVE	ACT,LPFWPC
	CAME	COR,ACT
	ERROR	TIPF10+1,13,COR,ACT,<SAVED FLAGS,,PC WRONG>,PAGE FAIL

	REPTLP	TIPF10+1
;*TEST I/O INSTRUCTION PAGE FAIL

SALL
T=SIXBTZ	<I/O INST PAGE FAIL>
LALL

	SUBTST
PFIO0:	MOVE	REPT,RPEAT
	SETZM	200
	MOVE	[200,,201]
	BLT	417		;CLEAR PAGE MAP

	MOVEI	PFIO3
	MOVEM	LPGFTR		;SETUP FOR PAGE FAIL

PFIO1:	SETOM	LEUPFW		;SETUP PAGING
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	JRSTF	@.+1
	0,,.+1

PFIO2:	CONI	APR,400000	;PERFORM I/O INST PAGE FAIL
	ERROR	PFIO1,13,0,0,CONI TRAP FAILED,FATAL
	JRST	PFIO1
PFIO3:	MOVE	ACT,LEUPFW
	MOVE	COR,[011000,,400000]
	CAME	COR,ACT
	ERROR	PFIO1,13,COR,ACT,PAGE FAIL WORD WRONG,DATAI

	MOVE	ACT,LPFWPC
	MOVE	COR,[0,,PFIO2]
	CAME	COR,ACT
	ERROR	PFIO1,13,COR,ACT,<SAVED FLAGS,,PC WRONG>,DATAI

	REPTLP	PFIO0+1

	MOVE	PGFAIL
	MOVEM	LPGFTR

	JRST	STMUUO

REPEAT	0,<

AN I/O PAGE FAILURE CAUSES THE KS-10 TO HALT, THEREFORE THE
FOLLOWING TEST IS NOT PERFORMED.
SUBTTL	INTERRUPT INSTRUCTION PAGE FAIL

SALL
T=SIXBTZ	INTERRUPT INST PAGE FAIL
LALL

;*CAUSE AN INTERRUPT THAT HAS FOR ITS INTERRUPT HANDLING
;*INSTRUCTION A "JSR" TO A PAGE FAIL ADDRESS.
;*AN I/O PAGE FAIL INTERRUPT SHOULD OCCUR.

	SUBTST
INTPF0:	MOVE	REPT,RPEAT

;*FIRST VERIFY THAT THE METER CAN CAUSE AN INTERRUPT

	CONO	PI,LPICLR
	CONO	APR,LAPRAL!LAPRP1
	CONO	PI,LCHNON!LPION!LPICHA
	MOVE	[JSR INTPFA]
	MOVEM	514		;SETUP METER VECTOR

	MOVSI	0,77
	CONO	TIM,63203
	CONO	MTR,7		;ASSIGN METER CHAN 7
	SOJGE	0,.		;WAIT FOR METER INTERRUPT
	CONO	PI,PICLR
	ERROR	INTPF0+1,13,0,0,NO METER INTERRUPT,FATAL
	JRST	INTPF3
;*NOW USE IT TO CAUSE I/O PAGE FAIL

INTPFA:	0			;METER CAUSED INTERRUPT
	CONO	MTR,0		;GO AHEAD AND USE IT
	CONO	PI,LPICLR
	CONO	APR,LAPRAL!LAPRP1
	CONO	PI,LCHNON!LPION!LPICHA

	SETZM	200
	MOVE	[200,,201]
	BLT	417		;CLEAR PAGE MAP

	MOVEI	INTPF1
	MOVEM	LPGFTR		;SETUP PAGE FAIL TRAP

	MOVE	[JSR 400000]
	MOVEM	514		;SETUP METER INTERRUPT

	MOVE	[JSR INTPF2]
	MOVEM	42		;SETUP I/O PAGE FAIL ERROR INTERRUPT

	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]

	MOVSI	0,77		;WAIT FOR METER INTERRUPT
	CONO	TIM,63203
	CONO	MTR,7
	SOJGE	0,.
	CONO	PI,PICLR
	ERROR	INTPF0+1,13,0,0,NO INTERRUPT,FATAL
	JRST	INTPF3
;*IF PAGE FAIL HAPPENED, ERROR

INTPF1:	CONO	MTR,0
	CONO	PI,PICLR
	ERROR	INTPF0+1,13,LEUPFW,LPFWPC,PAGE FAILURE,<COR=PAGE FAIL WORD,ACT=PAGE FAIL PC>
	JRST	INTPF3

;*APR ERROR INTERRUPT, CHECK PROPER CONDITIONS

INTPF2:	0
	CONO	MTR,0
	CONO	PI,PICLR
	CONI	APR,ACT
	MOVE	COR,[LIOPFE]
	TRNN	ACT,LIOPFE
	ERROR	INTPF0+1,13,COR,ACT,IO PAGE FAIL NOT SET

	REPTLP	INTPF0+1

INTPF3:	CONO	MTR,0
	CONO	PI,LPICLR
	CONO	PI,LCHNON!LPION!LPICHA
	CONO	APR,LAPRAL!LAPRP1
	MOVE	[JSR ITRCH1]
	MOVEM	42		;RESET INTERRUPT SYSTEM

	JRST	BEGEND
>
SUBTTL	PAGING MEMORY FLOATING BIT TEST TABLE

;*LH = SCRATCHPAD DATA
;*RH = PAGING ADDRESS

AMTAB1:	777777,,400
	757776,,600
	737775,,500
	577773,,440
	517767,,420
	777757,,410
	577737,,404
	737677,,402
	757577,,401
	660000,,340
	757377,,777
	736777,,577
	575777,,677
	773777,,737
	567777,,757
	730000,,767
	744000,,773
	762000,,775
	501000,,776
	677777,,501
	500400,,640
	760200,,700
	720100,,740
	440000,,760
	720040,,770
	540020,,774
	720010,,772
	417777,,341
	760004,,342
	660000,,345
	500002,,352
	500001,,525
	777777,,376
	517777,,463
	620000,,632
	552525,,505
	637777,,362
	545252,,623
	400000,,551
	772525,,624
	417777,,353
	760000,,603
	0
	0
	0
	0

SUBTTL	MONITOR UUO TRAP TESTING

;*TEST MUUO TRAPPING TO 424(KERNAL NO TRAP)

SALL
T=SIXBTZ MONITOR UUO TEST - TRAPPING IN KERNAL MODE
LALL
A=MUUO			;DATA STORED
C=AXMUUO		;CORRECT DATA

STMUUO:	SETZM	SCOPE#		;CLEAR SCOPE
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]	;CLEAR BASE REGISTER
AXMBEG:	MOVEI	40		;SET UP TEST
	MOVEM	COUNT#		;COUNTER
	TNSET
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	AXMUUO		;FOR EXECUTION
AXMST:	MOVEI	AXMUPC		;SET UP UUO TRAP PC
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
	SETZM	MUUO		;CLEAR UUO TRAP
	SETZM	MUUO+1		;LOCATIONS
AXMUUO:	0			;THIS IS THE UUO
	ERROR1	13,C,0,MUUO DID NOT TRAP IN KERNAL MODE,C(CORRECT)=MONITOR UUO
	ERLP2	AXMST
AXMUPC:	SKIPN	COUNT		;DONE 40 UUOS
	JRST	AYMBEG		;YES DO NEXT SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	AXMUUO		;ADD IN FOR NEXT UUO
	SOS	COUNT		;FIX UP COUNTER
	JRST	AXMST		;LOOP
C=MUUOXA			;CORRECT DATA
MUU100:	MOVEI	10		;TEST COUNT
	MOVEM	COUNT
	TNSET
	MOVSI	1B20		;FIRST MUUO (100)
	MOVEM	MUUOXA		;STORE UUO TO EXECUTE
MUUSTA:	MOVEI	MUXPCA		;SET UP UUO TRAP PC
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
	SETZM	MUUO		;CLEAR UUO
	SETZM	MUUO+1		;AND NEXT
MUUOXA:	0			;THIS LOC HAS MUUO
	ERROR1	13,C,0,MUUO DID NOT TRAP IN KERNAL MODE,C(CORRECT)=MUUO 
	ERLP2	MUUSTA
MUXPCA:	SKIPN	COUNT		;FINISHED
	JRST	MUU114		;DO NEXT TEST SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	MUUOXA		;AND ADD IN TO OLD UUO
	SOS	COUNT		;FIX UP COUNT
	JRST	MUUSTA		;AND LOOP TEST
C=MUUOXB			;CORRECT DATA
MUU114:	MOVEI	4		;TEST COUNT
	MOVEM	COUNT
	TNSET
	MOVSI	114000		;FIRST MUUO (114)
	MOVEM	MUUOXB		;STORE UUO TO EXECUTE
MUUSTB:	MOVEI	MUXPCB		;SET UP UUO TRAP PC
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
	SETZM	MUUO		;CLEAR UUO
	SETZM	MUUO+1		;AND NEXT
MUUOXB:	0			;THIS LOC HAS MUUO
	ERROR1	13,C,0,MUUO DID NOT TRAP IN KERNAL MODE,C(CORRECT)=MUUO 
	ERLP2	MUUSTB
MUXPCB:	SKIPN	COUNT		;FINISHED
	JRST	MUU114		;DO NEXT TEST SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	MUUOXA		;AND ADD IN TO OLD UUO
	SOS	COUNT		;FIX UP COUNT
	JRST	MUUSTB		;AND LOOP TEST
;*MONITOR UUO TEST - UUO STORE INTO 424

SALL
T=SIXBTZ MONITOR UUO TEST - UUO STORE INTO 424
LALL
A=MUUO			;ACTUAL DATA STORED
C=AYMUUO		;CORRECT DATA LOCATION

AYMBEG:	MOVEI	40		;SET UP TEST COUNTER
	MOVEM	COUNT
	TNSET
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	AYMUUO		;FOR EXECUTION
AYMST:	MOVEI	AYMUPC		;SET UP UUO TRAP
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
	SETZM	MUUO		;CLEAR MUUO TRAP
	SETZM	MUUO+1		;LOCATIONS
AYMUUO:	0			;EXECUTE THIS UUO
	HALT	.		;UUO DID NOT TRAP
AYMUPC:	MOVE	MUUO		;GET WRITTEN UUO
	CAME	AYMUUO		;STORED CORRECTLY?
	ERROR1	13,C,A,CONTENTS OF 424 IS NOT EQUAL TO EXECUTED UUO,
	ERLP2	AYMST
	SKIPN	COUNT		;DONE 40 UUO'S
	JRST	AZMBEG		;DO NEXT SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	AYMUUO		;ADD IN FOR NEXT UUO
	SOS	COUNT		;FIX UUO COUNTER
	JRST	AYMST		;LOOP
;*MONITOR UUO - STORE CORRECT PC

SALL
T=SIXBTZ MONITOR UUO - STORE CORRECT PC
LALL
C=[AZMUUO+1]		;CORRECT DATA
A=1			;ACTUAL DATA

AZMBEG:	SETZM	MUUO		;CLEAR MONITOR UUO
	SETZM	MUUO+1		;TRAP LOCATIONS
	TNSET
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	AZMUUO		;TO BE EXECUTED
AZMST:	MOVEI	AZMUPC		;SET UP TRAP INSTRUCTION
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
AZMUUO:	0			;EXECUTABLE UUO
	HALT	.		;SHOULDN'T  UUO DID NOT TRAP
AZMUPC:	HRRZ	1,MUUO+1	;GET THE PC OF THE UUO
	CAIE	1,AZMUUO+1	;PC+1 OF THE UUO SHOULD BE STORED
	ERROR1	13,C,A,MUUO DID NOT STORE THE CORRECT PC,C(425) HAS PC STORED
	ERLP2	AZMST
;*TEST STORING ALL POSSIBLE VALUES OF THE E FIELD WHEN EXECUTING
;*A MONITOR UUO

SALL
T=SIXBTZ MONITOR UUO - STORE E CORRECTLY
LALL
A=1			;ACTUAL DATA
C=7			;CORRECT DATA

AWMBEG:	MOVEI	7,1000		;FIRST E FIELD TO TEST
AWMST:	MOVEI	AWMUPC		;SET UP MUUO TRAP INSTUCTION
	MOVEM	KNTRP		;INTO KERNAL NO TRAP
	TNSET
	SETZM	MUUO		;CLEAR MUUO TRAP LOCATIONS
	SETZM	MUUO+1
	MOVSI	1B21		;SET UP UUO TO EXECUTE
	MOVEM	AWMUUO		;AND STORE IT
	HRRM	7,AWMUUO	;AN A NEW PC
AWMUUO:	0			;THIS IS THE UUO
	HALT	.		;SHOULD NOT HALT
AWMUPC:	HRRZ	1,MUUO
	CAME	1,7		;CORRECT E STORED
	ERROR1	13,C,A,MUUO DID NOT STORE E CORRECTLY,C(424) HAS E VALUE STORED
	ERLP2	AWMST
	ADDI	7,1000		;NEXT E FIELD
	TLNE	7,1		;DONE 2^18TH TESTS?
	JRST	BXMBEG		;NEXT SET OF TESTS
	JRST	AWMST		;LOOP TEST
SUBTTL	TEST MUUO'S IN CONCEALED MODE

;*MONITOR UUO TEST - TRAPPING IN CONCEALED MODE

SALL
T=SIXBTZ MONITOR UUO TEST - TRAPPING IN CONCEALED MODE
LALL
A=UPMP+MUUO		;DATA STORED
C=BXMUUO		;CORRECT DATA

BXMBEG:	TNSET
	PAGECN
	MOVEI	40		;SET UP TEST
	MOVEM	COUNT#		;COUNTER
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	BXMUUO		;FOR EXECUTION
BXMST:	GO	PAGE1
	MOVEI	BXMUPC		;SET UP UUO TRAP PC
	MOVEM	UPMP+CNTRP	;INTO CONCEALED NO TRAP
	MOVEI	BXERR		;SET WRONG TRAP ERROR
	MOVEM	UPMP+KNTRP
	MOVEM	UPMP+PNTRP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+KTRP
	MOVEM	UPMP+STRP
	MOVEM	UPMP+PTRP
	MOVEM	UPMP+CTRP
	SETZM	UPMP+MUUO	;CLEAR UUO TRAP
	SETZM	UPMP+MUUO+1	;LOCATIONS
BXMUUO:	0			;THIS IS THE UUO
	ERROR1	13,C,A,MUUO DID NOT TRAP IN CONCEALED MODE,C(CORRECT)=MONITOR UUO
	ERLP2	BXMST
BXMUPC:	SKIPN	COUNT		;DONE 40 UUOS
	JRST	BYMBEG		;YES DO NEXT SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	BXMUUO		;ADD IN FOR NEXT UUO
	SOS	COUNT		;FIX UP COUNTER
	JRST	BXMST		;LOOP
BXERR:	ERROR1	13,C,A,MUUO TRAPPED TO INCORRECT TRAP LOCATION,
	ERLP2	BXMST
;*MONITOR UUO TEST - UUO STORE INTO 424

SALL
T=SIXBTZ MONITOR UUO TEST - UUO STORE INTO 424
LALL
A=UPMP+MUUO		;ACTUAL DATA STORED
C=BYMUUO		;CORRECT DATA LOCATION

BYMBEG:	PAGECN
	MOVEI	40		;SET UP TEST COUNTER
	MOVEM	COUNT
	TNSET
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	BYMUUO		;FOR EXECUTION
BYMST:	GO	PAGE1
	MOVEI	BYMUPC		;SET UP UUO TRAP
	MOVEM	UPMP+CNTRP	;INTO CONCEALED NO TRAP
	MOVEI	BYERR		;IN CASE WE GO TO THE WRONG TRAP
	MOVEM	UPMP+KNTRP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+PNTRP	;SET UP THE OTHER TRAP LOCATIONS
	SETZM	UPMP+MUUO	;CLEAR MUUO TRAP
	SETZM	UPMP+MUUO+1	;LOCATIONS
BYMUUO:	0			;EXECUTE THIS UUO
	ERROR1	13,C,A,MUUO DID NOT TRAP,
	ERLP2	BYMST
BYMUPC:	MOVE	UPMP+MUUO	;GET WRITTEN UUO
	CAME	BYMUUO		;STORED CORRECTLY?
	ERROR1	13,C,A,CONTENTS OF 424 IS NOT EQUAL TO EXECUTED UUO,
	ERLP2	BYMST
	SKIPN	COUNT		;DONE 40 UUO'S
	JRST	BZMBEG		;DO NEXT SET
	MOVSI	1B26		;SET UP FOR NEXT UUO
	ADDM	BYMUUO		;ADD IN FOR NEXT UUO
	SOS	COUNT		;FIX UUO COUNTER
	JRST	BYMST		;LOOP
BYERR:	ERROR1	13,C,A,MUUO TRAPED TO INCORRECT TRAP LOCATION,
	ERLP2	BYMST
;*MONITOR UUO - STORING THE CORRECT PC

SALL
T=SIXBTZ MONITOR UUO - STORING THE CORRECT PC
LALL
C=[BZMUUO+1]		;CORRECT DATA
A=1			;ACTUAL DATA

BZMBEG:	TNSET
	PAGECN
	SETZM	UPMP+MUUO	;CLEAR MONITOR UUO
	SETZM	UPMP+MUUO+1	;TRAP LOCATIONS
	MOVSI	1B21		;SET UP FIRST UUO
	MOVEM	BZMUUO		;TO BE EXECUTED
BZMST:	GO	PAGE1
	MOVEI	BZMUPC		;SET UP TRAP INSTRUCTION
	MOVEM	UPMP+CNTRP	;INTO CONCEALED NO TRAP
	MOVEI	BZERR		;SET UP TRAP FOR INCORRECT TRAP
	MOVEM	UPMP+KNTRP	;INTO KERNAL NO TRAP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+PNTRP
BZMUUO:	0			;EXECUTABLE UUO
	HALT	.		;SHOULDN'T  UUO DID NOT TRAP
BZMUPC:	HRRZ	1,UPMP+MUUO+1	;GET THE PC OF THE UUO
	CAIE	1,BZMUUO+1	;PC+1 OF THE UUO SHOULD BE STORED
	ERROR1	13,C,A,MUUO DID NOT STORE THE CORRECT PC,
	ERLP2	BZMST
	JRST	BWMBEG		;GO TO NEXT SET
BZERR:	ERROR1	13,C,A,MUUO DID NOT TRAP TO CORRECT TRAP,
	ERLP2	BZMST
;*MUUO STORING THE CORRECT E FIELD

SALL
T=SIXBTZ MUUO STORING THE CORRECT E FIELD
LALL
A=1			;ACTUAL DATA
C=7			;CORRECT DATA

BWMBEG:	PAGECN
	TNSET
	MOVEI	7,1000		;FIRST E FEILD TO TEST
BWMST:	GO	PAGE1
	MOVEI	BWMUPC		;SET UP MUUO TRAP INSTUCTION
	MOVEM	UPMP+CNTRP	;INTO CONCEALED NO TRAP
	MOVEI	BWERR		;SET UP FOR INCORRECT TRAP
	MOVEM	UPMP+PNTRP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+KNTRP
	SETZM	UPMP+MUUO	;CLEAR MUUO TRAP LOCATIONS
	SETZM	UPMP+MUUO+1
	MOVSI	1B21		;SET UP UUO TO EXECUTE
	MOVEM	BWMUUO		;AND STORE IT
	HRRM	7,BWMUUO	;AN A NEW PC
BWMUUO:	0			;THIS IS THE UUO
	ERROR1	13,C,A,MUUO DID NOT TRAP IN CONCEALED,
	ERLP2	BWMST
BWMUPC:	HRRZ	1,UPMP+MUUO
	CAME	1,7		;CORRECT E STORED
	ERROR1	13,C,A,MUUO DID NOT STORE E CORRECTLY,
	ERLP2	BWMST
	ADDI	7,1000		;NEXT E FIELD
	TLNE	7,1		;DONE 2^18TH TESTS?
	JRST	TRAP0		;NEXT SET
	JRST	BWMST		;LOOP TEST
	JRST	TRAP0		;GO TO NEXT SET
BWERR:	ERROR1	13,C,A,MUUO DID NOT TRAP TO CORRECT TRAP,
	ERLP2	BWMST
SUBTTL TRAP TESTING

;*CAUSE TRAPS VIA JRSTF INSTRUCTION
;*TRAP WILL CAUSE A MOVEI TO BE EXECUTED PUTING THE TRAP ADDRESS INTO
;*AC0 WHICH IS THEN CHECKED FOR BEING THE CORRECT TRAP
;*TRAP RETURN WILL CHECK FOR CORRECT PC STORED IN IN 0

SALL
T=SIXBTZ AROV TRAP TEST
LALL
C=[AROVTP]		;CORRECT DATA
A=0			;ACTUAL DATA
TRAP0:	SETZ			;CLEAR AC0
	TNSET
	RESET
	TRPSET
TRAP0A:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]	 ;SET UP FOR ALLOWING TRAPS
	MOVE	[XWD TN1,.+2]	;TRAP PC WORD FOR JRSTF
	JRSTF	@		;CAUSE TRAP VIA JRSTF
	CAIE	0,AROVTP	;TRAP DID NOT OCCUR
	ERROR1	13,C,A,AROV DID NOT TRAP TO 421,
	ERLP2	TRAP0A

;*TEST PUSHDOWN LIST OVERFLOW TRAP TO 422
SALL
T=SIXBTZ PDLOV TRAP TEST
LALL
C=[PDOVTP]		;CORRECT DATA
A=0			;ACTUAL DATA

TRAP1:	SETZ			;CLEAR AC0
	TNSET
	RESET
	TRPSET
TRAP1A:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]	 ;SET UP FOR ALLOWING TRAPS
	MOVE	[XWD TN0,.+2]	;TRAP PC WORD FOR JRSTF
	JRSTF	@		;CAUSE TRAP VIA JRSTF
	CAIE	0,PDOVTP	;TRAP DID NOT OCCUR
	ERROR1	13,C,A,PDOVTP DID NOT TRAP TO 422,
	ERLP2	TRAP1A
;*TRAP3 TRAP TEST TRAPPING TO 423

SALL
T=SIXBTZ TRAP3 TRAP TEST
LALL
C=[TRP3TP]		;CORRECT DATA
A=0			;ACTUAL DATA
TRP02:	SETZ			;CLEAR AC0
	TNSET
	RESET
	TRPSET
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]	 ;SET UP FOR ALLOWING TRAPS
TRAP2A:	MOVE	[XWD TN0!TN1,.+2]	;PC FOR JRSTF
	JRSTF	@		;CAUSE TRAP VIA JRSTF
	CAIE	0,TRP3TP	;TRAP DID NOT OCCUR
	ERROR1	13,C,A,TRAP3 TRAP DID NOT TRAP TO 423,
	ERLP2	TRAP2A
SUBTTL FLAG SETTING
	MODE=1

	FLGTST	USERF,<MUUO DID NOT RE-ENTER USER-MODE>
;*THIS ROUTINE TO BRING US BACK TO KERNAL MODE FROM USER
;*MODE RESTORE VIA MUUO

USRRTN:	MOVE	[UEXT]		;PC FOR RETURN
	MOVEM	UPMP+KNTRP
	MOVEM	UPMP+PNTRP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+CNTRP
	MOVEM	UPMP+STRP
	MOVEM	UPMP+KTRP
	MOVEM	UPMP+CTRP
	MOVEM	UPMP+PTRP
	MOVSI	1B21
	MOVEM	.+1		;UUO TO GET US OUT
USREXT:	0			;DO THIS UUO TO EXIT TO KERNAL
	HALT	.		;FATAL ERROR (DID NOT ENTER KERNAL
UEXT:	JSP	.+1		;GET FLAGS
	TLNE	USERF		;STILL IN USER MODE
	HALT	.+1		;FATAL - TRAPPED FROM UUO BUT STILL
	JRST	.+1		;IN USER MODE
	MODE=1
	FLGTST	EXIOT,<MMUO DID NOT SET EXIOT FLAG>
PAGE
	MODE=0
	FLGTST	AROV,<MUUO DID NOT SET ARITHMETIC OVERFLOW FLAG>
PAGE
	FLGTST	CRY0,<MUUO DID NOT SET CRY0 FLAG>
PAGE
	FLGTST	CRY1,<MUUO DID NOT SET CRY1 FLAG>
PAGE
	FLGTST	FOV,<MUUO DID NOT SET FOV FLAG>
PAGE
	FLGTST	BIS,<MUUO DID NOT SET BIS FLAG>
PAGE
	FLGTST	FXU,<MUUO DID NOT SET FXU FLAG>
PAGE
	FLGTST	DCK,<MUUO DID NOT SET DCK FLAG>
PAGE
	FLGTST	CRY0+CRY1+AROV+FOV+FXU+DCK+BIS,<MUUO DID NOT SET CRY0+CRY1+AROV+FOV+FXU+DCK+BIS FLAGS>
SUBTTL	TEST IOT'S IN CONCEALED MODE

SALL
T=SIXBTZ	IOT MUUO^CONCEALED MODE
LALL
A=UPMP+MUUO
C=IOTCM1

IOTCM:	TNSET
	PAGECN

	SETZM	10		;INIT COUNTER

IOTCM0:	MOVE	IOTTAB(10)	;SETUP IOT FOR EXECUTION
	MOVEM	IOTCM1

	GO	PAGE1
	MOVEI	IOTCM3		;SETUP MUUO TRAP PC
	MOVEM	UPMP+CNTRP
	MOVEI	IOTCM2		;SETUP FOR INCORRECT TRAP
	MOVEM	UPMP+KNTRP
	MOVEM	UPMP+PNTRP
	MOVEM	UPMP+SNTRP
	MOVEM	UPMP+KTRP
	MOVEM	UPMP+STRP
	MOVEM	UPMP+PTRP
	MOVEM	UPMP+CTRP

	SETZM	UPMP+MUUO	;CLEAR MUUO LOCATIONS
	SETZB	0,UPMP+MUUO+1

IOTCM1:	0			;DO "IOT"

	ERROR1	13,C,A,IOT DID NOT TRAP,C=IOT
	ERLP2	IOTCM0
	JRST	IOTCM3
IOTCM2:	ERROR1	13,C,A,IOT DID NOT TRAP TO PROPER TRAP
	ERLP2	IOTCM0

IOTCM3:	MOVE	UPMP+MUUO	;GET SAVED MUUO
	CAME	IOTCM1
	ERROR1	13,C,A,CONTENTS OF 424 NOT EXECUTED IOT
	ERLP2	IOTCM0

C=[IOTCM1+1]
A=1

	HRRZ	1,UPMP+MUUO+1	;GET SAVED PC
	CAIE	1,IOTCM1+1
	ERROR1	13,C,A,IOT MUUO DID NOT STORE CORRECT PC,,IOTCMX
	ERLP2	IOTCM0

	AOS	10
	CAIE	10,^D11		;DONE ALL ILLEGAL IOT'S ?
	JRST	IOTCM0		;NOT YET
	JRST	UBLT		;YES, TO NEXT TEST

IOTCMX:	PMSG	<IOT = >
	MOVE	IOTCM1
	PNTHW
	PCRL
	RTN
;*ILLEGAL USER MODE IOT TABLE

IOTTAB:	CONO
	CONI
	DATAO
	DATAI
	CONSZ
	CONSO
	BLKO
	BLKI
	HALT
	JEN
	JRST	10,
	HALT
SUBTTL	TEST USER MODE ADDRESSING

;*USER MODE CONCEALED - MAXIMUM BLOCK TRANSFER

SALL
T=SIXBTZ	USER MODE CONCEALED^MAXIMUM BLOCK TRANSFER
LALL

A=UPMP+MUUO
C=[HALT 13]

UBLT:
UBLT3:	TNSET
UBLT4:	MOVEI	<<UPMP+1000>_-^D9>!540000
	HRL				;SETUP PAGE TABLE ENTRY
	MOVSI	1,-1000/2	;SO ALL PAGES POINT TO SAME 512 WORDS
	MOVEM	UPMP(1)
	AOBJN	1,.-1

	MOVE	10,[JRST 1,11]	;PORTAL
	MOVE	11,[SETOM 20]	;SET FIRST LOC
	MOVE	12,[BLT 7,777777] ;MAX BLT
	MOVE	13,[HALT 13]	;MUUO TO GET BACK TO EXEC
	MOVE	7,[20,,21]	;BLT START ADDRESSES

	MOVEI	UBLT5		;SETUP FOR TERMINATION MUUO
	MOVEM	UPMP+CNTRP
	MOVEI	UBLT6		;SETUP FOR ERROR TERMINATION MUUO
	MOVEM	UPMP+CTRP
	MOVEM	UPMP+PNTRP
	MOVEM	UPMP+PTRP

	SETZM	UPMP+MUUO	;CLEAR MUUO LOCATIONS
	SETZM	UPMP+MUUO+1

	MOVE	[0,,UPMP+LPGFTRP]	;SETUP FOR PAGE FAIL
	MOVEM	UPMP+LPGFTRP		;HANDLE VIA MUUO

	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000!<UPMP_-^D9>]

	JRSTF	@.+1		;GO TO USER MODE
	USERF,,10		;IN THE AC'S
	HALT	.
UBLT5:	MOVE	UPMP+MUUO	;COMPLETED, CHECK RESULTS
	CAME	[HALT 13]
	ERROR1	13,C,A,INCORRECT TERMINATION MUUO
	ERLP2	UBLT4

A=UPMP+MUUO+1
C=[USERF,,14]

	MOVE	UPMP+MUUO+1
	CAME	[USERF,,14]
	ERROR1	13,C,A,INCORRECT TERMINATION PC
	ERLP2	UBLT4
	JRST	UBLT7

C=5
A=6

UBLT6:	MOVE	5,UPMP+LEUPFW
	MOVE	6,UPMP+MUUO+1
	ERROR1	13,C,A,PAGE FAILURE,<CORRECT=PF WORD, ACTUAL=PF PC>
	ERLP2	UBLT4

UBLT7:	JRST	LAST

LAST:	JRST	BEGEND
SUBTTL	SPECIAL PROGRAM SUBROUTINES

IFNDEF	PAGSIZ,<PAGSIZ=24>

TRAPST:	0			;FOR JSR
	MOVEM	XAC0#		;SAVE AC0
	MOVE	[TPLST,,421]	;BLT POINTER
	BLT	423		;FILL LOCATIONS
	MOVE	XAC0		;RESTORE AC0
	JRST	@TRAPST		;RETURN

TPLST:	MOVEI	421
	MOVEI	422
	MOVEI	423

;*PAGE TABLE SETUP

PAGSET:	MOVSI	1,-PAGSIZ	;SET UP PAGE COUNT
	MOVE	[737776,,737777]	;ADDRESS
	SKIPE	CNSFLG#		;IF CONCEALED DONT SET PUBLIC
	MOVE	[537776,,537777]
	ADD	[2,,2]		;NEW ADRESS
	MOVEM	UPMP(1)		;STORE PAGE MAP
	AOBJN	1,.-2		;LOOP TILL DONE
PAGE1:	JSP	1,.+1
	TLNE	1,USERF		;IF IN USER MODE FORGET PAGE RESET
	POPJ	P,		;EXIT DIRECTLY
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000!<UPMP_-^D9>]
	JRSTF	@.+1		;ENTER USER MODE
	USERF,,.+1		;ENTRY FLAG
	JRST	1,.+1		;ENTRY
	JSP	.+1		;GET FLAGS
	TLNN	USERF		;DID WE GET INTO USER MODE?
	ERROR1	13,C,A,ENTRY TO USER MODE UNSUCESSFUL,JRSTF FAILED
	ERLP2	PAGSET
	POPJ	P,		;RETURN TO CALLING SEQUENCE