// D1Simini.bcpl--initialization procedures for SimTest	and SimGo
//	19 May 1983

get "mcommon.d"

external [
// OS
	Zero

// MASM
	ResetsCSS; @WssCSS

// MDATA
	@LoopCount; GoVec

// MRGN
	AddToEveryTimeList

// MCMD
	SetAbortPure

// MGO
	@QuitF; @CantContinue

// MPATTERN
	@PATTERN

// D1ASM
	ReadDMux

// D1MEM
	TurnOffRefresh

// D1GO
	SetupIMA

// D1SIMRES
	SimGo; SimTestAbort; SimGoAbort; SimLp

// D1SIMT
	LoadandDoInst; LoadSimGo

// Defined here
	SimTest; StartSim; SimAborted
]

static [ SimAborted ]


//SimGo action gets here--call from StartBigOvlWithAddr in MGO.BCPL
let StartSim(MB,AVec,MemX; numargs NA) = valof
[ //Setup like regular single-step
	SetupIMA(false,AVec,MemX,NA,(NA ge 3 ? "SimGo ","SimContinue "),MB)
	SimSetup(lv SimGoAbort,SimGo)
	ReadDMux()
	Zero(LoopCount,2)
	SimAborted = false
	resultis lv LoadSimGo
]


and SimSetup(lvAbortProc,EveryTimeProc) be
[	SetAbortPure(lvAbortProc,0)
	QuitF = AddToEveryTimeList(EveryTimeProc,GoVec)
//RunRefresh off to check memory stuff
	TurnOffRefresh()
]


//SimTest action gets here--call from StartLargeOverlay in MCMD.BCPL
and SimTest(nil,nil) = valof
[	PATTERN = 4	//Random pattern
	CantContinue = CantContinue % didTest
	Zero(LoopCount,2)
	ResetsCSS()
	WssCSS("Testing DMux signals with random instructions...")
	SimSetup(lv SimTestAbort,SimLp)
	resultis lv LoadandDoInst
]