//D0test.bcpl -- machine-dependent part of "Test" overlay
//	Last edited: 4 December 1979

manifest [ get "d0regmem.d" ]

external [
// MDATA
	@LowAddress; @HighAddress

// MCMD
	ErrorExit

// MTEST
	LastVal

// D0MEM
	KIMloMax; KIMhiMin

// D0VM
	SetVirtP

// D0TABLES
	@NREGS

// Defined here
	ValidateTest
]

//X = RegX, NREGS+MemX, or NREGS+NMEMS+OtherX
let ValidateTest(X) be
[	SetVirtP(false)
	LastVal = X
//Adjust address ranges to avoid KERNEL for IMX and RM
	test X eq NREGS+IMXx
	ifso
	[ if LowAddress!1 < KIMloMax then LowAddress!1 = KIMloMax+1
	  if HighAddress!1 ge KIMhiMin then HighAddress!1 = KIMhiMin-1
	  unless LowAddress!1 le HighAddress!1 do
	    ErrorExit("IMX address range overlaps KERNEL")
	]
	ifnot if X eq NREGS+RMx do
	  [ test LowAddress!1 < #300
	    ifso unless HighAddress!1 < #300 do
		HighAddress!1 = #277
	    ifnot ErrorExit("RM address range conflicts with KERNEL")
	  ]
]