//D1Prin3w.bcpl	Procedures to prettyprint DMux addresses < 20B
//	Called from D1Prin3.bcpl
//	Last edited: 4 May 1980

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

external [
// MIDAS
	MidasSwat

// MASM
	@WssCSS; WssCS1; PutsCS1; PutsCSS

// MSYM
	SearchBlocks

// MIOC
	DWns

// MCMD
	WnsCSS; WnsCSSD; WnsCS1D; CmdCommentStream

// MPRINS
	PrinV0; NWss; PrinV1; NWss1

// MPATTERN
	@PATTERN

// D1VM
	LookUpAA; @VirtualP

// D1GO
	PrCCV

// Defined here
	PrintDMXw; PrintTIOA; PrintMEMBASE; PrintTASK
]


let PrintIandS(MemX,Value) be
[	let AVec1 = vec 1; AVec1!0 = 0
	AVec1!1 = Value
	if SearchBlocks(CmdCommentStream,MemX,AVec1,-1,false) do
	[ WssCSS(" = "); DWns(CmdCommentStream,AVec1)
	]
]


and PrintTIOA(X,DVec,AVec,ExtRadix) be PrintIandS(DEVICEx,DVec>>lh)
and PrintMEMBASE(X,DVec,AVec,ExtRadix) be PrintIandS(BRx,DVec!0 rshift 11)
and PrintTASK(X,DVec,AVec,ExtRadix) be PrintIandS(TASKNx,DVec!0 rshift 12)

and PrintDMXw(Addr) be
[	let T,DVec = nil,vec 1
	DVec!0 = 0; DVec!1 = PATTERN
	switchon Addr into
	[
case dCJNK0:		//Random control status bits
	NWss("Stop ",#100000)
	NWss("preStartCyclea ")
	NWss("dStartCycle ")
	NWss("Phase0 ")
	NWss("Phase4 ")
	NWss("RWTPCorRWIM ")
	NWss1("BigBDispatch ")
	NWss1("Dispatch ")
	NWss1("WIM ")
	NWss1("RIM ")
	NWss1("WTPC ")
	NWss1("RTPC "); return
case dCIA:	//Registers containing IM addresses
case dCIAINC:
case dTNIA:
case dBNPC:
case dOLDCIA:	//This one for call from D1Prin3V.Bcpl
	PrCCV(DVec,(VirtualP ? IMx,IMXx))
	if VirtualP & (DVec!0 ge 0) do
	[ WssCSS(" = abs. ")
	  WnsCSS(LookUpAA(DVec!0))
	]
	return
case dBNT:
case dPENC:
case dNEXT:
case dCTD:
case dCTASK:
	PrintIandS(TASKNx,PATTERN); return
case dRA:
	NWss("CS0BDb ",#100000)
	NWss("CS1BDb ")
	NWss("CS2BDb ")
	NWss("CS3BDb ")
	PrinV0("RAQuad[0:1]",(PATTERN rshift 10) & 3)
	PrinV0(" RA[1:10]b",PATTERN & 1777B); return
case dTOPE:
	Prin16("ToPE."); return
case dCJNK1:
	NWss("Call ",#100000)
	NWss("bSWd ")
	NWss("GND ")
	NWss("LocalBra ")
	NWss("IFUNexta ")
	NWss("LongJumpa ")
	NWss("Returna ")
	NWss("CondBra ")
	NWss1("bFFokc ")
	NWss1("FA=0 ")
	NWss1("FA=1 ")
	NWss1("bDoCBr ")
	NWss1("Link←BMuxa ")
	NWss1("B←Link ")
	NWss1("RIMorRTPCdly ")
	NWss1("MulStep "); return
case dFFEQ:
	NWss("FF=TaskingOn ",#100000)
	NWss("FF=TaskingOff ")
	NWss("FF=MidasOn ")
	NWss("FF=WriteLink ",#4000)
	NWss("FF=Link←CPReg ")
	NWss("FF=ReadLink ")
	NWss1("FF=UseDMD ",#40)
	NWss1("FF=TOffIsOk ")
	NWss1("FF=Notify ")
	NWss1("FF=MulStep ")
	NWss1("FF=BDispatch ")
	NWss1("FF=BigBDispatch "); return
case dCJNK3:
	NWss("Next=0 ",#4000)
	NWss("CTask=0 ")
	NWss("PEncGtTrueNext ")
	NWss("PEncLtTrueNext ")
	NWss("StopTasks ")
	NWss("PEnc=CT ")
	NWss1("TPCBypass ")
	NWss1("PreEmpting ")
	NWss1("bHoldA ")
	NWss1("RepeatCurz ")
	NWss1("bSwitcha ")
	NWss1("bSwitchUp "); return
case dREADY:
	PATTERN = PATTERN & 77777B
	Prin16("Ready."); return
default:
	MidasSwat(PrintDMXwbug)
	]
]


and Prin16(str) be
[	let T = 100000B
	for I = 0 to 7 do
	[ if (T & PATTERN) ne 0 do
	  [ WssCSS(str); WnsCSSD(I); PutsCSS($ )
	  ]
	  T = T rshift 1
	]
	for I = 8 to 15 do
	[ if (T & PATTERN) ne 0 do
	  [ WssCS1(str); WnsCS1D(I); PutsCS1($ )
	  ]
	  T = T rshift 1
	]
]