{File name nInitLisp.mc;    DandeLion Interlisp Emulator - Initialization
Author: Purcell
Last edited: 15-Jul-83 11:45:48 by don -- added uLispOptions ← 0
Last edited: April 6, 1983  1:35 PM; dont move display in new sysout
Created: January 17, 1983 out of NewLisp.mc
Last edited: February 5, 1983  11:42 AM
}

EFCHaveLink:  CANCELBR[$, 0F],    {from StartMesa with dispatch pending}
{**************************************************
STALL to test display and maintpanel: 			
**************************************************}
	Rx ← 040{~15 sec}{10/sec},	c1;
	rhTT ← 41, TT ← 41-1,	c2;
	TT{14000} ← TT LRot8,	c3;

	TT{14041} ← TT +41,	c1;
	Noop,	c2;
	Noop,	c3;

Stall:	MAR ← [rhTT, TT+0], BRANCH[Stall0, Stall1],	c1;

Stall0:	MDR ← Rx, GOTO[StallJn],	c2;
Stall1:	MDR ← 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:	Noop,	c3;

{ShowDisplay:}
BegSD:	Noop, CANCELBR[$, 0F],	c1;
	Rx ← 1 RRot1, rhRx ← 1, {CANCELBR[$, 1],}	c2;
	Rx{4000} ← Rx RShift1,	c3;

	MAR ← [rhRx, 0EB+0],	c1;
	Noop{MDR ← 0},	c2;
	TT ← 88,	c3;

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

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

	Noop, {MAR ← [rhRx, 0E9+0],}	c1;
	Q ← 41, {MDR ← 0,} {IBDisp,}	c2;
	DCtl←Q LRot0, {L2 ← L2.0, DISPNI[OpTable],}	c3;

Begin:	Rx{182} ← 0C1 LRot1,	c1;
	Rx ← Rx LRot1,	c2;
	uPcBreak ← Rx{304},	c3;

	Rx ← VALspace,	c1;
	uValHigh ← Rx,	c2;
	stackP ← 0,	c3;

BegA:	Rx ← Rx xor ~Rx,	c1;
	unboundPvar ← Rx,	c2;
	unboundFvar ← Rx,	c3;

BegB:	uStkLimO ← Rx,	c1;
	uWP ← 0,	c2;
	uWDC ← 0{uWDC inited by mesaInit},	c3;

	Rx ←  ~0FD,	c1;
	Rx ← Rx LRot8,	c2;
	uBfResidualRhmask ← Rx{2FF},	c3;

	Rx ←  0A0,	c1;
	Rx ← Rx LRot8,	c2;
	uFreeStackBlock ← Rx{0A000},	c3;

	Rx ←  0FF + 1,	c1;
	uFxNoPushReturn ← Rx{100h},	c2;
	Rx ←  LShift1(Rx + Rx), SE←0,	c3;

BegBB:	uFxInCall ← Rx{400h},	c1;
	Rx ←  7F,	c2;
	u7F ← Rx{7F},	c3;

BegBBB:	Rx ←  ~0FF,	c1;
	u0FF ← ~Rx{~0FF},	c2;
	uFF00 ← Rx{~0FF},	c3;

BegC:	TT ← Rx{0FF00} or 1,	c1;
	TT ← TT LRot8,	c2;
	u1FF ← TT{1FF},	c3;

	TT ← Rx{0FF00} or 3,	c1;
	TT ← TT LRot8,	c2;
	uTT3FF ← TT{3FF},	c3;

	TT ← Rx{0FF00} or 3,	c1;
	TT ← TT LRot8,	c2;
	u3FF ← TT{3FF},	c3;

	TT ← Rx{0FF00} or 0F,	c1;
	TT ← TT LRot8,	c2;
	u0FFF ← TT{0FFF},	c3;

	TT ← Rx{0FF00} or 1F,	c1;
	TT ← TT LRot8,	c2;
	u1FFF ← TT{1FFF},	c3;

	TT ← Rx{0FF00} or 3F,	c1;
	TT ← TT LRot8,	c2;
	uTT3FFF ← TT{3FFF},	c3;

	TT ← Rx{0FF00} or 3F,	c1;
	TT ← TT LRot8,	c2;
	u3FFF ← TT{3FFF},	c3;

	TT ← Rx{0FF00} or 7F,	c1;
	TT ← TT LRot8,	c2;
	u7FFF ← TT{7FFF},	c3;

defered:	TT ← Rx{0FF00} or 7,	c1;
	TT ← TT LRot8,	c2;
	u7FF ← TT{7FF},	c3;

	{TT}u7FF ← TT{7FF},	c1;
	TT ← TT xor 1,	c2;
	u7FE ← TT{7FF},	c3;

	TT ← 0,	c1;
	uLispOptions ← TT,	c2;
	c3;

	{rCount}RCnt ← 0,	c1;
	{rY}RAdr ← 0,	c2;
	Rx ← 80,	c3;

BegD:	Rx ←  Rx LRot8,	c1;
	Noop,	c2;
	uBFmark ← Rx{8000},	c3;

{compliance: using uSTACKspace with duplicated high byte for bind ptr}

BegE:	Rx ← STACKspace,	c1;
	Rx ← Rx LRot8,	c2;
	Rx ← Rx or STACKspace,	c3;

	Noop,	c1;
	uSTACKspace ← Rx,	c2;
	Rx ← 0C0,	c3;

BegF:	Rx ←  Rx LRot8,	c1;
	Noop,	c2;
	uFXmark ← Rx{C000},	c3;

	Set[UFNTablePageHalf, Rshift[UFNTablebase, 9]];
BegFF:	Rx ←  UFNTablePageHalf,	c1;
	Rx ←  Rx LRot8,	c2;
	uUFNTableBaseHalf ← Rx,	c3;

{Map IOPage to 0,FF00     %%why was it smashed?}
	rhTT ←  0, CANCELBR[$, 1],	c1;
	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,	c2;
	Q ← 0,	c3;

{change to context Q{fxp}}
FXP:	rhTT ←  INTERFACEspace, CANCELBR[$, 1],	c1;
	TT ← INTERFACEbasePage{20'b}{INTERFACEbase=10000'b},	c2;
	TT ← TT LRot8,	c3;

FXP1:	Map ← [rhTT,TT],	c1;
	rhS ← nRhS,	c2;
	Rx ← rhRx ← MD,{ XRefBr,}	c3;

	TOSH ← 0,{sysout returns true}	c1;
	TOS ← KTval,	c2;
	Noop,	c3;

FXP2:	MAR← [rhRx, Q + 0],	c1;
	rhPV ← nRhS,	c2;
	PV{FXP} ← MD, GOTO[RTN2],	c3;

Reset:	Noop, {CANCELBR[$, 0F],}	c1;
Reset2:	uPageFault ← 0,	c2;
	Q ← 1, GOTO[FXP],	c3;

	{ E N D }