//  ProcProms.bcpl		last updated January 17, 1978

external ProcProms
get "DoradoProms.defs"


let ProcProms(mem) be
	[ let DoHi, DoLo = 0, 0
	let buff = vec 300
	if StEq(mem,"LMASK") % StEq(mem,"RMASK") then [ DoHi = true; DoLo = true ]
	if StEq(mem,"ProcH") then DoHi = true
	if StEq(mem,"ProcL") then DoLo = true
	if StEq(mem,"Proc") then mem!0 = DoAll
	if StEq(mem,"LMASK") & ICtype eq MC10139 then  // define the write Prom
		[
		MakeLMask(buff)
		Header("LMASK",16,buff,32,0)  //command to enter the memory
		if DoHi then PromCommand("PrH-b08")// blow the high byte
		if DoLo then PromCommand("PrL-b08","8")// blow the low byte
		]
	if StEq(mem,"RMASK") & ICtype eq MC10139 then  // define the write Prom
		[
		MakeRMask(buff)
		Header("RMASK",16,buff,32,0)  //command to enter the memory
		if DoHi then PromCommand("PrH-b07")// blow the high byte
		if DoLo then PromCommand("PrL-b07","8")// blow the low byte
		]
	]


and MakeLMask(buff) be
	[
	Zero(buff,32); let Lbit = #100000; let Lmask = 0
	for address = 1 to 31 do		//address 0 should be zero
		[
		Lmask = Lmask % Lbit; Lbit = Lbit rshift 1; buff!address = Lmask
		]
	]

and MakeRMask(buff) be
	[
	Zero(buff,32); let Rbit = 1; let Rmask = 0 
	for address = 1 to 31 do		//address 0 should be zero
		[
		Rmask = Rmask % Rbit; Rbit = Rbit lshift 1; buff!address = Rmask
		]
	]