{File name:  StartLisp12K.mc
 don 29-Dec-83 10:17:06
last modified by don    13-Mar-84 14:58:44 added logout
last modified by don    8-Feb-84 18:29:05 for LCS
 }

Reserve[0F6F]; Reserve[0F78]; Reserve[0F7F,0FFF];	{Kernel}

SetTask[0];

StartAddress[Germ];

Germ:
	rhTT ←  0, CANCELBR[SetMDS,0F],	c1, at[0,2,Germ];
	rhTT ←  0, CANCELBR[SetMDS,0F],	c1, at[1,2,Germ];

SetMDS:
	TT ← 0FF,	c2;
	TT{0FF00} ← TT LRot8,	c3;

	Rx ← 40,	c1;
	Rx ← Rx LRot8,	c2;
	uPageFault ← 0{notFaulting},	c3;

	Map ← [rhTT,TT],	c1;
	MDR ← Rx{4000} or {0B1}31,	c2;
	Q ← 0,	c3;

	L ← 41,	c1;
	IOPCtl ← IOPInMode,	c2;
	DCtl ← L LRot0,	c3;

	uWP ← 0, ClrIntErr,	c1;
	TOS ← 0, rhMDS ← 0	c2;
	rhTT ← TT ← uIOPage,	c3;

{set all keys up; 1403D thru 14043 ← -1}
	stackP ← 0,	c1;
	T ← 0FF LShift1, SE ← 1,	c2;
	Q ← 7,	c3;

KeyLoop:	MAR ← [rhTT,IOPage.keyBitsm1+Q], BRANCH[$,KeyDone],	c1;
	MDR ← L xor ~L, CANCELBR[$,0],	c2;
	Q ← Q - 1, ZeroBr, GOTO[KeyLoop],	c3;

KeyDone:
	{KCtl ← 0,} PC ← 0+0+1, CANCELBR[$,0],	c2;
	uWDC ← PC,	c3;

	MAR ← [rhTT, IOPage.DSCB.fieldCmd+0],	c1;
	MDR ← L,	c2;
	,	c3;

LastChance:
	MAR ← [rhTT, IOPage.DSCB.syncCmd+0],	c1;
	MDR ← L,	c2;
	L ← 0,	c3;

	Rx ← LH.FMP,	c1;
	Rx ← Rx LRot8,	c2;
	Rx ← Rx or RH.FMP,	c3;

	MAR ← [rhTT, IOPage.MP+0],	c1;
	MDR ← Rx or 1,	c2;
	Rx ← 080,	c3;

{ShowDisplay:}
BegSD:	rhRx ← Rx ← uIOPage, CANCELBR[$, 0F],	c1;
	TT ← 88,	c2;
	,	c3;

	MAR ← [rhRx, 0EC+0],	c1;
	MDR ← uFF00{was 0},	c2;
	TT ← TT LRot8,	c3;

	MAR ← [rhRx, 0ED{0EF}+0],	c1;
	MDR ← TT{88} or 22,	c2;
	PC ← 1 + PC + PC16,	c3;

	Q ← 71,	c1;
	DCtl←Q LRot0,	c2;
	Rx ← 080,	c3;


Stall:	BRANCH[Stall0, Stall1],	c1;

Stall0:	GOTO[StallJn],	c2;
Stall1:	Rx ← Rx  - 1, ZeroBr, GOTO[StallJn],	c2;

StallJn:	Q ← Q  - 1, ZeroBr, BRANCH[Stall, $],	c3;

SkipBurd:	Noop, CANCELBR[SkipBurdock, 0F],	c1;
Burdock:	IOPCtl ← 1, CANCELBR[$, 0F],	c1;
	Noop, GOTO[Burd3],	c2;
SkipBurdock:	Noop,	c2;
Burd3:	,	c3;

	Bank ← LispStartBank,				c1, at[LispStart];
	Noop,							c2;
	CROSS[LispStart],				c3;
	
Off:	MAR ← [rhRx, IOPage.ProcessorCommand+0],	c1, at[LOGOUT];
	MDR{4} ←  4,	c2;
	Noop,  GOTO[Off],	c3;

	
	{END}