{File name:  <tajo>StartLisp4K.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
 }


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{0FF00} ← ~0FF,	c2;
	Rx ← 41,	c3;

	DCtl ← Rx LRot0,	c1;
	Rx ← 40,	c2;
	Rx ← Rx LRot8,	c3;

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

	ClrIntErr,	c1;
	IOPCtl ← IOPInMode,	c2;
	rhTT ← TT ← uIOPage,	c3;

{set all keys up; 1403D thru 14043 ← -1}
	stackP ← 0,	c1;
	TOSH ← 0,	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:
	PC ← 0+1, CANCELBR[$,0],	c2;
	uWDC ← PC,	c3;

	Rx ← 88, CANCELBR[$, 0F],	c1;
	Rx ← Rx LRot8,	c2;
	PC ← 1 + PC + PC16,	c3;

	MAR ← [rhTT, 0EB{WakeupLoc}+0],	c1;
	MDR ← 0,	c2;
	uWP ← 0,	c3;

	MAR ← [rhTT, 0EC{DBitsLoc}+0],	c1;
	MDR ← uFF00{was 0},	c2;
	Q ← 71,	c3;

	MAR ← [rhTT, 0ED{BorderLoc}+0],	c1;
	MDR ← Rx{8800} or 22,	c2;
	TOS ← LH.FMP,	c3;

	DCtl← Q LRot0,	c1;
	TOS ← TOS LRot8,	c2;
	TOS ← TOS or RH.FMP,	c3;

Stall:	MAR ← [rhTT, IOPage.MP+0], BRANCH[Stall0, StallContinue],	c1;
Stall0:	MDR ← TOS, GOTO[StallJn],	c2;
StallJn:	Rx ← Rx  - 1, ZeroBr, BRANCH[Stall, StallDone],	c3;

StallContinue:
	Q ← Q - 1, ZeroBr, GOTO[StallJn],	c2;

Burdock:
	IOPCtl ← 1, CANCELBR[$, 0F],	c1;
	Rx ← 41,	c2;
	DCtl ← Rx LRot0, TOSH ← 0,	c3;

StallDone:
	TOS ← KTval, CANCELBR[$],	c1;
	uSTATE ← Q ← 0,	c2;
	GOTO[EFCHaveLink],	c3;

	{END}