{File name:  StartCedar1.mc
 Description: Cedar emulator initialization,

 Last Edited:
  Trow	28-Oct-87  2:44:31 Created.
}


Set[xtFC0, 1] {see description of bits in Xfer};


	GOTOABS[B1MP799],					c3, at[BxMP799];

{write 799 in maintenance panel}
MP799:
	TT ← uMaintPanel, {maint panel code}			c1, at[B1MP799];
	rhTT ← uIORgnHigh,					c2;
	Noop,							c3;

	TOS ← 1F,						c1;
	TOS ← TOS LRot8,					c2;
	TOS ← TOS or 3 {1F03 byteswapped = 799'd},		c3;

	MAR ← [rhTT, TT + 0],					c1;
	MDR ← TOS,						c2;
	TT ← TT + 1, {maint panel down-notify mask}		c3;

	MAR ← [rhTT, TT + 0],					c1;
	Noop,							c2;
	TOS ← MD,						c3;

{TOS contains notify mask: byte-mask in high byte, byte offset in low}
	T ← uMesaProc,						c1;
	rhT ← uIORgnHigh,					c2;
	TT ← LShift1 (T + downNotifyBits),
		LOOPHOLE[niblTiming],				c3;

	MAR ← [rhT, T + notifiersLockMask],			c1;
	STK ← TOS, T ← TOS and ~0FF, CANCELBR[$,0],		c2;
	TOS ← MD, L4 ← SoftwareLockRets.StartCedar,		c3;

	rhTT ← STK, XLDisp,					c1;
{the following branch is reversal of Mesa byte order to do byte-swapping for IOP}
	TT ← RShift1 (TT + rhTT), LOOPHOLE[niblTiming],
		BRANCH[LowByteMask,$,2],			c2;
	rhT ← lock.or, SetMPIntIOP, CALL[SoftwareLock],		c3;
LowByteMask:
	rhT ← lock.or, SetMPIntIOP,				c3;

	MAR ← [rhIORgn, rIORgn + iopRequestsLock],		c1;
	T ← T LRot8, CANCELBR[SoftwareLockSideDoor,0],		c2;

	MDR ← 0, CANCELBR[$,0],					c2, at[SoftwareLockRets.StartCedar,10,SoftwareLockRets];
	TOS ← rhMDS, ClrMPIntIOP,				c3;

LastChance:
	Noop,							c1;
	SetIE,							c2;
	rhT ← xtFC0,						c3;

	TT ← uSDAddr,						c1;
	T ← TT + 276'b {T ← 1376'b},				c2;
	Udest ← T, L ← 0, YDisp, GOTO[EFCHaveLink],		c3;