Google
 

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

PGMNAM:	ASCIZ/
DECSYSTEM KL10 PAGING HARDWARE DIAGNOSTIC (DFKEA)
/
START:	MOVEI	.
	MOVEM	TESTPC
	SETOM	CSHFLG			;DON'T USE CACHE
	SETOM	PVPAGI			;MUST BE PAGED
	PGMINT				;INIT SUBROUTINES
	MOVEI	700000			;P0
	MOVEM	KLUBRX#
	DATAI	PAG,0			;READ PAGER STATUS
	LDB	AC,[POINT 3,0,8]	;GET AC BLK BYTE
	DPB	AC,[POINT 3,KLUBRX,26]	;DEPOSIT AC BLK INTO 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,17777
	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	^D13,<
;*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,17777
	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	^D13,<
;*LOAD AND CHECK EXEC BASE REGISTER WITH A FLOATING ZERO
;*TO CHECK BIT INTERACTION.
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVEI	COR,17777-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,[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,,417777]
	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	^D13,<
;*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,,417777]
	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	^D13,<
;*LOAD USER BASE REGISTER WITH A FLOATING ZERO
;*CHECK BIT INTERACTION.
	XX=XX+XX
	IFE	XX,<XX=1>
	MOVE	COR,[LLDUSB,,417777-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 ASSOCIATIVE MEMORY FOR CLEAR

SALL
T=	SIXBTZ	ASSOCIATIVE MEMORY TEST
LALL

;*CLEAR ASSOCIATIVE 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 ASSOCIATIVE 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	P0TRP0

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	P0TRP0

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	P0TRP0

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
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,

;*PERFORM 'MAP' OF ADDRESS 252525,
;*TEST ALTERNATE MEMORY ADDRESS ARE PAGED.
;*MAP READOUT SHOULD BE:
;*ACCESS, WRITABLE, SOFTWARE, PAGED REF

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

;*PERFORM 'MAP' OF ADDRESS 125252,
;*TEST ALTERNATE MEMORY ADDRESS ARE PAGED.
;*MAP READOUT SHOULD BE:
;*ACCESS, WRITABLE, SOFTWARE, PAGED REF

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

;*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, ASSOCIATIVE MEMORY NO MATCH.

MAPCK3:	MOVSI	COR,1000
	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, ASSOCIATIVE MEMORY NO MATCH.

MAPCK4:	MOVSI	COR,1000
	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, ASSOCIATIVE 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
	MOVSI	COR,1000
	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, ASSOCIATIVE 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
	MOVSI	COR,1000
	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 ASSOCIATIVE MEMORY

SALL
T=	SIXBTZ	ASSOCIATIVE 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 ASSOCIATIVE MEMORY THERFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND ASSOCIATIVE 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 ASSOCIATIVE MEMORY.
;*READOUT OF LOADED ASSOCIATIVE 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 ASSOCIATIVE MEMORY THERFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND ASSOCIATIVE 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 ASSOCIATIVE MEMORY.
;*READOUT OF LOADED ASSOCIATIVE 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 ASSOCIATIVE MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND ASSOCIATIVE 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 ASSOCIATIVE MEMORY.
;*READOUT OF THE LOADED ASSOCIATIVE 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 ASSOCIATIVE MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA FROM
;*PAGE MAP AND ASSOCIATIVE 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 ASSOCIATIVE MEMORY.
;*READOUT OF THE LOADED ASSOCIATIVE 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, ASSOCIATIVE MEMORY NO MATCH.

EPPM1:	MOVSI	COR,1000
	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, ASSOCIATIVE MEMORY NO MATCH.

EPPM2:	MOVSI	COR,1000
	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, ASSOCIATIVE MEMORY NO MATCH.

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

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

EPPM4:	MOVEI	AC,377777
	MOVEM	AC,417
	MOVSI	COR,1000
	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 ASSOCIATIVE MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA
;*FROM UPMP EXEC-PER-PROCESS MAP AND LOAD ASSOCIATIVE MEMORY
;*WITH PAGE ADDRESS 377.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT'
;*BY THE MAP INSTRUCTION.
;*READOUT OF THE LOADED ASSOCIATIVE 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,[165000,,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 = 17777.
;*'DATAO PAG' CLEARS ASSOCIATIVE MEMORY THEREFORE 'MAP'
;*SHOULD DO REFILL CYCLE AND LOAD SCRATCHPAD MEMORY WITH DATA
;*FROM UPMP EXEC-PER-PROCESS MAP AND LOAD ASSOCIATIVE MEMORY
;*WITH PAGE ADDRESS 340.
;*THE DATA FROM THE SCRATCHPAD MEMORY IS READ INTO 'ACT'
;*BY THE MAP INSTRUCTION.
;*READOUT OF THE LOADED ASSOCIATIVE MEMORY (BY 'CONI PAG')
;*SHOULD BE:
;*PAGE 340',EXEC MEMORY SPACE, RELOAD COUNTER.

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

	REPTLP	EPPM0+1
SUBTTL	TEST ASSOCIATIVE AND SCRATCHPAD MEMORIES

;*PAGE MAP IS SETUP FOR 42 PAGES WITH DATA THAT PRODUCES
;*FLOATING BIT PATTERNS IN BOTH THE ASSOCIATIVE 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 ASSOCIATIVE 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			;ASSOCIATIVE 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
	TLO	COR,1000		;SET PAGED REF BIT
	TLZE	COR,400			;ACCESS
	TLO	COR,100000
	TLZE	COR,200			;PUBLIC
	TLO	COR,4000
	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 ASSOCIATIVE 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	PFT1			;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,[067000,,400000!<PGW400&777>]
	MOVE	ACT,LEUPFW
	CAME	COR,ACT
	ERROR	PFT1,13,COR,ACT,PAGE FAIL WORD WRONG

	REPTLP	PFT0+1

	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,[135000,,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	RLPFT0

RLPFT2:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,LEUPFW
	ERROR1	13,COR,ACT,RELOCATION FAILED,PAGE FAIL TRAPPED TO PAGE 0
	JRST	RLPFT0			;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

	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	RLTRP0

RLTP3:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,RLTP3X]
	MOVE	ACT,RLTP3
	CAME	COR,ACT
	ERROR	RLTRP1,13,COR,ACT,TRAP 3 SAVED PC
;*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	RLTRP0

RLPDL:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,RLPDLX]
	MOVE	ACT,RLPDL
	CAME	COR,ACT
	ERROR	RLTRP1,13,COR,ACT,TRAP 2 SAVED PC
;*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	RLTRP0

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
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,LDPAER!LCPAER!LPICLR!LCHNOF!LPIOFF
	CONO	APR,LIOCLR

	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]
	SETZM	FLG157#			;ZERO FLAG
	APRID	0			;SEE IF MODEL A OR B
	MOVEM	APRIDF#			;SAVE IT
	LDB	1,[POINT 9,0,17]	;GET VERSION BITS
	CAIN	1,157			;157 MICROCODE?
	SETOM	FLG157#			;YES
	SKIPE	FLG157
	JRST	PFPY
	TRNN	1B21			;IF = 0 MUST BE MODEL A
	TLO	COR,10000		;SET WRREF BIT
PFPY:	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,,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:	SETOM	COR
	MOVE	ACT,75777
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DMOVEM DID NOT TRANSFER AC,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

;*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	TIPF0

;*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:	DATAI	APR,400000		;PERFORM I/O INST PAGE FAIL
	ERROR	PFIO1,13,0,0,DATAI 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
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.
;*A PAGE FAIL 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
INTPFB:	SOJGE	0,.
	CONO	PI,PICLR
	ERROR	INTPF0+1,13,0,0,NO INTERRUPT,FATAL
	JRST	INTPF3
;*IF PAGE FAIL HAPPENED, CHECK PROPER CONDITIONS

INTPF1:	CONO	MTR,0
	CONO	PI,PICLR
	MOVE	ACT,LEUPFW
	MOVE	COR,[11000,,400000]
	CAME	COR,ACT
	ERROR	INTPF0+1,13,COR,ACT,PAGE FAIL WORD WRONG

	MOVE	ACT,LPFWPC
	MOVE	COR,[300000,,INTPFB]
	CAME	COR,ACT
	ERROR	INTPF0+1,13,COR,ACT,PAGE FAIL PC WRONG
	REPTLP	INTPF0+1
	JRST	INTPF3

;*APR ERROR INTERRUPT,ERROR

INTPF2:	0
	CONO	MTR,0
	CONO	PI,PICLR
	CONI	APR,ACT
	MOVE	COR,INTPF2
	ERROR	INTPF0+1,13,COR,ACT,IO PAGE FAIL INTERRUPTED,<COR=INTERRUPT PC,ACT=CONI APR>

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	MAXQ
SUBTTL	ASSOCIATIVE 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	MAXIMUM PAGING AND BASE REGISTER RELOCATION TEST.

;*"OPRSEL" SWITCH SET ALLOWS THE FOLLOWING MAXIMUM TESTS
;*PERFORM TEST UNLESS INHIBITED BY "INHMAX" SWITCH.
;*ALLOW FOR REQUIRED OPERATOR ACTION ON FIRST PASS
;*TO RESELECT A MEMORY FOR MAXIMUM 4 MILLION ADDRESSING.
;*IF "INHMXQ" SWITCH IS SET, "INHMAX" CLEAR, ASSUME THAT
;*MEMORY IS CORRECTLY SETUP.

MAXQ:	SUBTST
	SWITCH
	TLNN	OPRSEL			;OPERATOR TEST SELECTION ?
	JRST	BEGEND			;NO, DON'T RUN MAXIMUM
	TRNE	INHMAX			;IS MAXIMUM TEST INHIBITED ?
	JRST	BEGEND			;YES

	SKIPE	PASCNT			;IS THIS FIRST PASS ?
	JRST	MAXQ1			;NO
	TRNE	INHMXQ			;RECONFIGURATION QUESTION INHIBITED ?
	JRST	MAXQ1-1			;YES
	MOVEI	[ASCIZ/
ALLOW MAXIMUM ADDRESS TESTING ?/]
	PNTALF
	TTIYES				;ASK QUESTION
	JRST	BEGEND			;NO
	MOVEI	[ASCIZ/
SELECT A MEMORY FOR ADDRESS 17740000 (4080K)
TYPE AN ALT-MODE WHEN READY.
/]
	PNTALF
	TTICHR
	JRST	.-1			;NO RESPONSE YET

	SETOM	MXFLG
MAXQ1:	SKIPN	MXFLG			;PERFORM TEST
	JRST	BEGEND			;NO
	SETZM	200
	MOVE	AC,[200,,201]
	BLT	AC,417			;CLEAR PAGE 0 PAGE MAP
	SETZM	PGRDTB
	MOVE	AC,[PGRDTB,,PGRDTB+1]
	BLT	AC,PGRDTB+437		;CLEAR PREVIOUS DATA AREA
	CONO	PAG,LTRPEN		;CLEAR MEMORIES, ETC.
	DATAO	PAG,[LLDUSB,,400000]
;*TEST MAXIMUM ADDRESS PAGING
;*PAGING ADDRESS 400000 RELOCATES TO 17740000
;*PAGING ADDRESS 777777 RELOCATES TO 17777777

SALL
T=SIXBTZ	MAXIMUM PAGING TEST
LALL

	SUBTST
MXPAG1:	MOVE	REPT,RPEAT
	MOVSI	AC,757740		;SETUP PAGE MAP FOR 4080K
	MOVEM	AC,200
	MOVEI	AC,757777		;SETUP PAGE MAP FOR 4096K-1
	MOVEM	AC,377

MXPAG2:	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVE	COR,[000017,,740000]
	MOVEM	COR,400000		;MAKE PAGED WRITE
	SETOM	ACT
	MOVE	ACT,400000		;PAGE REREAD VERIFY
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGING ADR 400000,RELOC ADR 17740000
	ERLOOP	MXPAG2

MXPAG3:	MOVE	COR,[000017,,777777]
	MOVEM	COR,777777		;MAKE PAGED WRITE
	SETOM	ACT
	MOVE	ACT,777777		;PAGED REREAD VERIFY
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGING ADR 777777,RELOC ADR 17777777
	ERLOOP	MXPAG3

	REPTLP	MXPAG1+1
;*TEST MAXIMUM ADDRESS PAGING.
;*USING PAGING ADDRESSES 340XXX THRU 777XXX
;*WRITE DATA INTO MAXIMUM MEMORY.
;*RELOCATION STARTS AT 17740000 AND GOES TO 17777740
;*IN INCREMENTS OF 40(8) ADDRESSES.

SALL
T=SIXBTZ	MAXIMUM RELOCATION PAGING TEST
LALL

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

MXADR1:	MOVE	AC2,ACT			;SETUP PAGE MAP
	LSH	AC2,-^D9		;RELOCATION 17740000
	ADDI	AC2,740000		;TO 17777740
	HRL	AC3,AC2			;IN INCREMENTS OF 40
	ADDI	ACT,40
	MOVE	AC2,ACT
	LSH	AC2,-^D9
	ADDI	AC2,740000
	HRR	AC3,AC2
	ADDI	ACT,40
	HRRZ	AC1,AC
	LSH	AC1,-1
	CAIGE	AC1,200
	ADDI	AC1,220
	MOVEM	AC3,(AC1)		;PUT RELOC DATA IN PAGE MAP
	ADDI	AC,2
	AOBJN	INDX,MXADR1

MXADR2:	CONO	PAG,LTRPEN		;CLEAR MEMORIES, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	MOVSI	INDX,-440
	MOVEI	AC,340
	SETZM	AC2
MXADR3:	MOVE	COR,AC			;SETUP DATA
	LSH	COR,^D9			;LOW ORDER ADR,,HIGH ORDER
	HRL	COR,AC2
	MOVE	AC1,AC2			;SETUP PAGING ADR
	ANDI	AC1,777
	ADDI	AC1,(COR)

	MOVEM	COR,(AC1)		;MAKE PAGED MEMORY WRITE
	SETZM	ACT
	MOVE	ACT,(AC1)		;PAGED READ VERIFY
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGED READ VERIFY,
	ERLOOP	MXADR3

	AOS	AC
	ADDI	AC2,40
	AOBJN	INDX,MXADR3

	REPTLP	MXADR0+2
SUBTTL	PAGING AND ADDRESSING TEST WITH 128K 'BLT'.

;*CHECKS THAT ADDRESSING FROM 400000 TO 777777 WORKS
;*ALSO CHECKS THAT 'BLT' OPERATES AND TERMINATES CORRECTLY.
;*CLEAR MAXIMUM MEMORY USING A PAGED 'BLT'.
;*PAGE MAP SHOULD STILL BE SETUP FROM PREVIOUS TEST.

SALL
T=SIXBTZ	PAGED BLT TEST
LALL

	SUBTST
MXBLT0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETOM	777776			;SETUP LAST TWO WORDS
	SETOM	777777
	SETZM	400000			;CLEAR FIRST WORD
	MOVE	AC,[400000,,400001]
	BLT	AC,777777		;DO 128K BLT

MXBLT1:	SETZM	COR
	MOVE	ACT,400000
	SKIPE	400000
	ERROR1	13,COR,ACT,ADR 400000,NOT CLEAR

	SETZM	COR
	MOVE	ACT,777776
	SKIPE	777776
	ERROR1	13,COR,ACT,ADR 777776,NOT CLEAR

	SETZM	COR
	MOVE	ACT,777777
	SKIPE	777777
	ERROR1	13,COR,ACT,ADR 777777,NOT CLEAR
	MOVSI	INDX,-400000
MXBLT2:	MOVEI	COR,400000(INDX)
	MOVE	ACT,400000(INDX)
	SKIPE	400000(INDX)
	ERROR1	13,COR,ACT,NOT CLEAR,<REF TO (CORRECT)>

	ERLOOP	MXBLT0+1
	AOBJN	INDX,MXBLT2

;*SET MAXIMUM MEMORY TO ALL ONES USING A PAGED 'BLT'.
;*PAGE MAP SETUP FROM PREVIOUS TEST.

MXBLT3:	CONO	PAG,LTRPEN		;CLEAR AM, ETC.
	DATAO	PAG,[LLDUSB,,400000]
	SETOM	400000			;SET FIRST WORD
	MOVE	AC,[400000,,400001]
	BLT	AC,777777		;DO 128K BLT

MXBLT4:	MOVSI	INDX,-400000
	MOVEI	COR,400000(INDX)
	MOVE	ACT,400000(INDX)
	SKIPN	400000(INDX)
	ERROR1	13,COR,ACT,NOT SET,<REF TO (CORRECT)>

	ERLOOP	MXBLT3
	AOBJN	INDX,MXBLT4+1

	REPTLP	MXBLT0+1
SUBTTL	TEST MAXIMUM BASE REGISTER RELOCATION

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

SALL
T=SIXBTZ	MAXIMUM BASE REGISTER RELOCATION TEST
LALL

	SUBTST
MXBAS0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	SETZM	200			;CLEAR PAGE 0 PAGE MAP
	MOVE	AC,[200,,201]
	BLT	AC,417
	MOVSI	AC,740000!17777
	MOVEM	AC,200			;SETUP FOR MAXIMUM PAGE
	MOVE	[540000,,540001]
	MOVEM	400000!600
	MOVSI	1,-157
	ADD	[2,,2]			;SETUP 0 TO 112K PAGE MAP
	MOVEM	400000!601(1)
	AOBJN	1,.-2
	MOVE	41
	MOVEM	400000!LUUOI		;SETUP LUUO
	MOVE	42
	MOVEM	400000!42		;SETUP INTERRUPT
	MOVE	LPGFTR
	MOVEM	400000!LPGFTR		;SETUP PAGE FAIL
	MOVE	[JFCL]
	MOVEM	400000!LAROVTP		;SETUP ARITH TRAP
	MOVE	LPDOVT
	MOVEM	400000!LPDOVTP		;SETUP PDL OV TRAP
	MOVE	LTRP3T
	MOVEM	400000!LTRP3TP		;SETUP TRAP 3 TRAP
	MOVE	MUUOER
	MOVEM	400000!LKNTRP		;SETUP MUUO AS ERROR
	MOVEM	400000!LKTRP
	MOVEM	400000!LSNTRP
	MOVEM	400000!LSTRP
	MOVEM	400000!LCNTRP
	MOVEM	400000!LCTRP
	MOVEM	400000!LPNTRP
	MOVEM	400000!LPTRP
;*TEST USER BASE REGISTER RELOCATION
;*BY USING AN MUUO OF 0.

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

MXBAS1:	MOVEI	AC,MXBMU1		;SETUP MUUO TO RETURN
	MOVEM	AC,LKNTRP		;FROM PAGE 0
	MOVEI	AC,MXBMU3
	MOVEM	AC,400000!LKNTRP	;FROM MAX PAGE

MXBAS2:	SETZM	COR
	MOVEI	ACT,.+3
	JRSTF	@.+1			;CLEAR FLAGS
		.+1
MXBMU0:	0				;DO AN MUUO OF 0
	ERROR1	13,COR,ACT,MUUO FAILED,<COR=MUUO, ACT=MUUO ADR>
	ERLOOP	MXBAS2

MXBMU1:	MOVEI	COR,0
	MOVE	ACT,LMUUO
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MUUO STORED WRONG,PAGE 0
	MOVEI	COR,MXBMU0+1
	MOVE	ACT,LMUUOPC
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MUUO PC STORED WRONG,PAGE 0
	ERLOOP	MXBAS2
;*TEST THAT WITH UPMP RELOCATED TO MAXIMUM PAGE
;*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.

MXBAS3:	DATAO	PAG,[LLDUSB,,417777]	;RELOCATE USER BASE REG
	SETZM	COR
	MOVEI	ACT,.+3
	JRSTF	@.+1
		.+1
MXBMU2:	0				;DO AN MUUO OF 0
	DATAO	PAG,[LLDUSB,,400000]
	ERROR1	13,COR,ACT,MUUO FAILED,<COR=MUUO, ACT=MUUO ADR>
	ERLOOP	MXBAS3

MXBMU3:	DATAO	PAG,[LLDUSB,,400000]
	MOVEI	COR,0
	MOVE	ACT,400000!LMUUO
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MUUO STORED WRONG,MAX PAGE
	MOVEI	COR,MXBMU2+1
	MOVE	ACT,400000!LMUUOPC
	CAME	COR,ACT
	ERROR1	13,COR,ACT,MUUO PC STORED WRONG,MAX PAGE
	ERLOOP	MXBAS3
;*TEST USER BASE REGISTER RELOCATION
;*BY USING EXEC PAGE FAIL WORD

MXBAS4:	MOVEI	AC,MUUOER
	MOVEM	AC,LKNTRP
	MOVEM	AC,400000!LKNTRP
	MOVEI	AC,MXPFL
	MOVEM	AC,400000!LPGFTR	;SETUP PAGE FAIL TRAP
MXPF1:	SETOM	400000!LEUPFW
	MOVEI	COR,777777
	SETOM	ACT
	DATAO	PAG,[LLDUSB,,417777]
	MOVE	ACT,777777		;SHOULD PAGE FAIL
	ERROR1	13,COR,ACT,PAGE FAIL FAILED,REF TO 777777
	ERLOOP	MXPF1
	JRST	MXBAS4

MXPFL:	SETOM	COR
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL STORED IN AC,REF TO 777777
	MOVE	COR,[1000,,777777]	;SETUP CORRECT WORD
	MOVE	ACT,400000!LEUPFW
	CAME	COR,ACT
	ERROR1	13,COR,ACT,PAGE FAIL WORD WRONG,REF TO 777777
	ERLOOP	MXPF1

MXBAS5:	DATAO	PAG,[LLDUSB,,400000]
	MOVE	AC,PGFAIL
	MOVEM	AC,LPGFTR

	REPTLP	MXBAS0+1
;*TEST MAXIMUM BASE REGISTER RELOCATION
;*BY USING EXEC-PER-PROCESS PAGING
;*AND PAGING REFILL DATA FROM MAXIMUM PAGE
;*WITH USER BASE REGISTER SET TO MAXIMUM.

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

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

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

MXWRT2:	SETZM	PGWRTB
	MOVE	AC,[PGWRTB,,PGWRTB+1]
	BLT	AC,PGWRTB+37		;CLEAR DATA AREA
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,417777]
	MOVSI	INDX,-40
	MOVEI	AC,340
MXWRT3:	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
	ERROR1	13,COR,ACT,DATA ERROR,PAGED REREAD
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DATA ERROR,DIRECT REREAD
	ERLOOP	MXWRT3
	AOS	AC
	AOBJN	INDX,MXWRT3

MXWRT4:	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
	ERROR1	13,COR,ACT,DATA ERROR,DIRECT READ
	ERLOOP	MXWRT2
	AOS	AC
	AOBJN	INDX,MXWRT4+4

	REPTLP	MXBAS6+2

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

SALL
T=SIXBTZ	EXEC BASE REGISTER MAX RELOCATION
LALL

	SUBTST
MXLUO0:	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]
	MOVSI	AC,740000!17777
	MOVEM	AC,200			;SETUP 400000 FOR MAX RELOCATION
	MOVE	AC,[JSR MXLUO1]
	MOVEM	AC,400000!LUUOI		;SETUP MAX PAGE LUUO INST
	MOVEI	AC,MXLUO2		;SETUP PAGE 0 LUUO
	MOVEM	AC,UUODIS+1

	CONO	PAG,LTRPEN!17777	;SETUP BASE REG
MXLUO3:	1B8				;DO AN LUUO
	CONO	PAG,LTRPEN
	ERROR1	13,COR,ACT,LUUO FAILED,FATAL
	JRST	MXLUO0

MXLUO2:	CONO	PAG,LTRPEN
	MOVE	COR,MXLUO3
	MOVE	ACT,LUUO
	ERROR1	13,COR,ACT,RELOCATION FAILED,LUUO TRAPPED TO PAGE 0
	ERLOOP	MXLUO3-1
	JRST	MXLUO0
MXLUO1:	0
	CONO	PAG,LTRPEN
	MOVE	COR,MXLUO3
	MOVE	ACT,400000!LUUO
	CAME	COR,ACT
	ERROR1	13,COR,ACT,RELOCATION SUCCEEDED,LUUO STORED WRONG
	ERLOOP	MXLUO3-1

	REPTLP	MXLUO3-1
>

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

	SUBTST
MXPFT0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	SETZM	200
	MOVE	AC,[200,,201]
	BLT	AC,417			;CLEAR PAGE TABLE
	MOVSI	AC,740000!17777
	MOVEM	AC,200			;SET FOR MAXIMUM PAGING
	SETZM	400000!400		;CLEAR EXEC PER PROCESS MAP
	MOVEI	AC,MXPFT1
	MOVEM	AC,400000!LPGFTR	;SETUP MAX PAGE PAGE FAULT
	MOVEI	AC,MXPFT2
	MOVEM	AC,LPGFTR		;SETUP PAGE 0 PAGE FAULT

	CONO	PAG,LTRPEN		;SETUP BASE REG
	DATAO	PAG,[LLDUSB,,417777]
MXPFT3:	MOVE	ACT,340000		;DO PAGING, SHOULD FAULT
	CONO	PAG,LTRPEN
	ERROR1	13,COR,ACT,PAGE FAULT FAILED,FATAL
	JRST	MXPFT0

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

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

	REPTLP	MXPFT0+1

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

	SUBTST
MXTRP0:	MOVE	REPT,RPEAT
	CONO	PAG,LTRPEN
	DATAO	PAG,[LLDUSB,,400000]
	MOVSI	AC,740000!17777
	MOVEM	AC,200

;*TEST RELOCATED TRAP 3

MXTRP1:	MOVE	AC,[JSR	MXTP3]
	MOVEM	AC,400000!LTRP3TP
	CONO	PAG,LTRPEN!17777
	JRSTF	@.+1
	TN0!TN1,,.+1
MXTP3X:	CONO	PAG,LTRPEN
	ERROR1	13,COR,ACT,TRAP 3 FAILED,FATAL
	JRST	MXTRP0

MXTP3:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,MXTP3X]
	MOVE	ACT,MXTP3
	CAME	COR,ACT
	ERROR	MXTRP1,13,COR,ACT,TRAP 3 SAVED PC
;*TEST RELOCATED TRAP 2

	MOVE	AC,[JSR MXPDL]
	MOVEM	AC,400000!LPDOVTP
	CONO	PAG,LTRPEN!17777
	JRSTF	@.+1
	TN0,,.+1
MXPDLX:	CONO	PAG,LTRPEN
	ERROR1	13,COR,ACT,TRAP 2 FAILED,FATAL
	JRST	MXTRP0

MXPDL:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,MXPDLX]
	MOVE	ACT,MXPDL
	CAME	COR,ACT
	ERROR	MXTRP1,13,COR,ACT,TRAP 2 SAVED PC

;*TEST RELOCATED TRAP 1

	MOVE	AC,[JSR MXAROV]
	MOVEM	AC,400000!LAROVTP
	CONO	PAG,LTRPEN!17777
	JRSTF	@.+1
	TN1,,.+1
MXAROX:	CONO	PAG,LTRPEN
	ERROR1	13,COR,ACT,TRAP 1 FAILED,FATAL
	JRST	MXTRP0

MXAROV:	0
	CONO	PAG,LTRPEN
	MOVE	COR,[0,,MXAROX]
	MOVE	ACT,MXAROV
	CAME	COR,ACT
	ERROR	MXTRP1,13,COR,ACT,TRAP 1 SAVED PC

	MOVE	AC,[JFCL]
	MOVEM	AC,400000!LAROVTP

	REPTLP	MXTRP0+1
SUBTTL	TEST MAXIMUM PAGE INTERRUPT RELOCATION

;*SET PAGE 0 INTERRUPT LOCATIONS AS ERRORS
;*SETUP MAX PAGE INTERRUPT LOCATION FOR TESTING
;*RELOCATE EXEC BASE REGISTER
;*TEST INTERRUPTS

SALL
T=SIXBTZ	MAXIMUM PAGE INTERRUPT TEST
LALL

	SUBTST
MXINT0:	MOVE	REPT,RPEAT
	IMULI	REPT,^D10		;FSTCYL=10 PASSES, REL =100 PASSES
	MOVE	[JSR MXITR1]		;SETUP MAX PAGE INTERRUPTS
	MOVEM	400000!42
	MOVE	[JSR MXITR2]
	MOVEM	400000!44
	MOVE	[JSR MXITR3]
	MOVEM	400000!46
	MOVE	[JSR MXITR4]
	MOVEM	400000!50
	MOVE	[JSR MXITR5]
	MOVEM	400000!52
	MOVE	[JSR MXITR6]
	MOVEM	400000!54
	MOVE	[JSR MXITR7]
	MOVEM	400000!56

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

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

MXIERR:	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	MXINT1

;*MAXIMUM INTERRUPT MACRO'S

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

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

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

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

	LALL
MXINT3:	MXITRX	(1,7)
MXITR7:	MXITRC	(7)

MXINT4:	MXITRX	(2,6)
MXITR6:	MXITRC	(6)

MXINT5:	MXITRX	(4,5)
MXITR5:	MXITRC	(5)

MXINT6:	MXITRX	(10,4)
MXITR4:	MXITRC	(4)

MXINT7:	MXITRX	(20,3)
MXITR3:	MXITRC	(3)

MXINT8:	MXITRX	(40,2)
MXITR2:	MXITRC	(2)

MXINT9:	MXITRX	(100,1)
MXITR1:	MXITRC	(1)

	REPTLP	MXINT1

MXINTA:	CONO	PAG,LTRPEN
	CONO	PI,LDPAER!LCPAER!LPICLR!LCHNOF!LPIOFF
	CONO	APR,LIOCLR
	MOVE	AC,[JSR ITRCH1]		;RESET INTERRUPTS
	MOVEM	AC,42
	CONO	APR,LAPRAL
	CONO	PI,LCHNON!LPION!LPICH1
SUBTTL	TEST MAXIMUM PAGE REFILL RELOCATION

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

SALL
T=SIXBTZ	MAXIMUM EPMP REFILL PAGING
LALL

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

MXEPM1:	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,400000(AC1)		;PUT MAPPING DATA IN MAX PAGE
	ADDI	AC,2
	AOS	INDX
	AOBJN	INDX,MXEPM1

MXEPM2:	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
MXEPM3:	CONO	PAG,LTRPEN!17777	;RELOC EXEC BASE REG
	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
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DATA ERROR,PAGED REREAD
	MOVE	ACT,PGWRTB(INDX)
	CAME	COR,ACT
	ERROR1	13,COR,ACT,DATA ERROR,DIRECT REREAD
	ERLOOP	MXEPM3
	AOS	AC
	AOBJN	INDX,MXEPM3

MXEPM4:	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
	ERROR1	13,COR,ACT,DATA ERROR,DIRECT READ
	ERLOOP	MXEPM2
	AOS	AC
	AOBJN	INDX,MXEPM4+3
	REPTLP	MXEPM0+2

	JRST	BEGEND			;TEST COMPLETED, RECYCLE !