//D0Prin1a.Bcpl	Subroutines used by D0Prin1.Bcpl
//	Last edited: 20 October 1981

manifest [ get "d0regmem.d" ]

external
[
// MASM
	PutsCSS; @WssCSS

// MSYM
	SearchBlocks

// MCMD
	CmdCommentStream; WnsCSS

// D0VM
	LookUpVA

// Defined here
	CPrint; PrinC; PrinR; PrinVA
]


let CPrint(Str1,Str2; numargs NA) be
[	if Str1 eq 0 then return
	WssCSS(Str1); if (NA > 1) & (Str2 ne 0) then WssCSS(Str2)
]


and PrinC(Str1,Str2; numargs NA) be
[	if Str1 eq 0 then return
	WssCSS(", "); WssCSS(Str1)
	if (NA > 1) & (Str2 ne 0) then WssCSS(Str2)
]


and PrinR(RPred,Rsrc,ALUAvec,SFtype,SIZEcount,POSmask; numargs NA) be
[	if NA < 4 then SFtype = 0
	WssCSS(selecton SFtype into
	[ case 0: ""
	  case 1: "LdF["
	  case 2: "RSh["
	  case 3: "Dispatch["
	  case 4: "LSh["
	  case 5: "LCy["
	  case 7: "Zero"
	  case 8: "FixVA["
	  case 9: "Nib0Rsh8["
	  case 10: "LHMask["
	  case 11: "RHMask["
	  case 6:
	  case 12: "Form"
	] )
	if SFtype eq 6 do PutsCSS($-)
	if (SFtype eq 6) % (SFtype eq 12) do
	[ WnsCSS(POSmask); PutsCSS($[)
	]
	if SFtype ne 7 do
	[ CPrint(RPred)
	  test Rsrc ne 0
	  ifso WssCSS(Rsrc)
	  ifnot SearchBlocks(CmdCommentStream,RMx,ALUAvec)
	  if RPred ne 0 then PutsCSS($])
	]
	switchon SFtype into
	[
case 1:
case 3:   PutsCSS($,); WnsCSS(POSmask); PutsCSS($,)
	  WnsCSS(SIZEcount); PutsCSS($])
case 0:	  return
case 2:
case 4:
case 5:	  PutsCSS($,); WnsCSS(SIZEcount); PutsCSS($]); return
case 7:	  return
case 6:
case 8:
case 9:
case 10:
case 11:
case 12:  WssCSS("]"); return
	]
]


and PrinVA(BA,Point) be
[	let AVec = vec 1; AVec!0 = 0; AVec!1 = LookUpVA(BA)
	test AVec!1 ge 0
	ifso SearchBlocks(CmdCommentStream,IMx,AVec,Point)
	ifnot
	[ PutsCSS($a); WnsCSS(BA)
	]
]