//D1brkp.bcpl -- Error print routine called from PrintErrors in D1go.
//	Last edited: 20 November 1979

get "d1.d"
manifest [ get "d1regmem.d" ]

external [
// MIDAS
	MidasSwat

// MASM
	@WssCSS

// MCMD
	ErrorAbort

// D1ASM
	stNotIMA; stNotInVM

// D1MEM
	MPutMemData; MGetMemData

// D1RES
	UnBreakDefault

// D1GO
	PrCCV

// Defined here
	BreakIML
]


//AVec is 0 to default the break address (to BreakTPC).
//BPflag is true to insert a break, false to remove one
let BreakIML(AVec,MemX,BPflag,String) be
[	let DVec,T = vec 2,vec 1
	test AVec eq 0
	ifso
	[ AVec,MemX = T,IMXx; AVec!1 = UnBreakDefault; AVec!0 = 0
	]
	ifnot if (MemX ne IMx) & (MemX ne IMXx) do
	[ ErrorAbort(stNotIMA); return
	]
//**Interim DVec!3 arrangement until MicroD fixed
	test MGetMemData(MemX,DVec,AVec)
	ifso
	[ if (MemX eq IMx) & ((DVec!3 & 20000B) ne 0) then
		ErrorAbort(stNotInVM)
	  DVec!2 = (DVec!2 & 147777B)+(BPflag & 30000B)
	  MPutMemData(MemX,DVec,AVec)
	  WssCSS(String); WssCSS(" break at "); PrCCV(AVec,MemX)
	  UnBreakDefault = AVec!1
	]
	ifnot MidasSwat(BadIMAVec)
]