{File name LispMapB00.mc
Created: 24-Apr-84 10:00:25 
}

{

Set[L0.RMAPB0.0, 00]; {used in PseudoColor}
Set[L0.RMAPB0.1, 01];
Set[L0.RMAPB0.2, 02];
Set[L0.RMAPB0.3, 03];
Set[L0.RMAPB0.4, 04];
Set[L0.RMAPB0.5, 05];
Set[L0.RMAPB0.6, 06];
Set[L0.RMAPB0.7, 07];
Set[L0.RMAPB0.8, 08];
Set[L0.RMAPB0.9, 09];
Set[L0.RMAPB0.A, 0A];
Set[L0.RMAPB0.B, 0B];
Set[L0.RMAPB0.C, 0C];
Set[L0.RMAPB0.D, 0D];
Set[L0.RMAPB0.E, 0E];
Set[L0.RMAPB0.F, 0F];

Set[L0.WMAPB0.0, 00];
Set[L0.WMAPB0.1, 01];
Set[L0.WMAPB0.2, 02];
Set[L0.WMAPB0.3, 03];
Set[L0.WMAPB0.4, 04];
Set[L0.WMAPB0.5, 05];
Set[L0.WMAPB0.6, 06];
Set[L0.WMAPB0.7, 07];
Set[L0.WMAPB0.8, 08];
Set[L0.WMAPB0.9, 09];
Set[L0.WMAPB0.A, 0A];
Set[L0.WMAPB0.B, 0B];
Set[L0.WMAPB0.C, 0C];
Set[L0.WMAPB0.D, 0D];
Set[L0.WMAPB0.E, 0E];
Set[L0.WMAPB0.F, 0F];

Set[L1.RMAPB0.0, 00];
Set[L1.RMAPB0.1, 01];
Set[L1.RMAPB0.2, 02];
Set[L1.RMAPB0.3, 03];
Set[L1.RMAPB0.4, 04];
Set[L1.RMAPB0.5, 05];
Set[L1.RMAPB0.6, 06];
Set[L1.RMAPB0.7, 07];
Set[L1.RMAPB0.8, 08];
Set[L1.RMAPB0.9, 09];
Set[L1.RMAPB0.A, 0A];
Set[L1.RMAPB0.B, 0B];
Set[L1.RMAPB0.C, 0C];
Set[L1.RMAPB0.D, 0D];
Set[L1.RMAPB0.E, 0E];
Set[L1.RMAPB0.F, 0F];

Set[L1.WMAPB0.0, 00]; {used in PseudoColor}
Set[L1.WMAPB0.1, 01]; {used in PseudoColor}
Set[L1.WMAPB0.2, 02];
Set[L1.WMAPB0.3, 03];
Set[L1.WMAPB0.4, 04];
Set[L1.WMAPB0.5, 05];
Set[L1.WMAPB0.6, 06];
Set[L1.WMAPB0.7, 07];
Set[L1.WMAPB0.8, 08];
Set[L1.WMAPB0.9, 09];
Set[L1.WMAPB0.A, 0A];
Set[L1.WMAPB0.B, 0B];
Set[L1.WMAPB0.C, 0C];
Set[L1.WMAPB0.D, 0D];
Set[L1.WMAPB0.E, 0E];
Set[L1.WMAPB0.F, 0F];

Set[L1.TrapFixesB0.0, 00]; {Already used in this file}
Set[L1.TrapFixesB0.1, 0]1; {Already used in this file}
Set[L1.TrapFixesB0.2, 02]; {used in PseudoColor}
Set[L1.TrapFixesB0.3, 03];
Set[L1.TrapFixesB0.4, 04];
Set[L1.TrapFixesB0.5, 05];
Set[L1.TrapFixesB0.6, 06];
Set[L1.TrapFixesB0.7, 07];
Set[L1.TrapFixesB0.8, 08];
Set[L1.TrapFixesB0.9, 09];
Set[L1.TrapFixesB0.A, 0A];
Set[L1.TrapFixesB0.B, 0B];
Set[L1.TrapFixesB0.C, 0C];
Set[L1.TrapFixesB0.D, 0D];
Set[L1.TrapFixesB0.E, 0E];
Set[L1.TrapFixesB0.F, 0F];

Set[L1.RegSaveRet.0, 00]; {used in PseudoColor}
Set[L1.RegSaveRet.1, 01];
Set[L1.RegSaveRet.2, 02];
Set[L1.RegSaveRet.3, 03];
Set[L1.RegSaveRet.4, 04];
Set[L1.RegSaveRet.5, 05];
Set[L1.RegSaveRet.6, 06];
Set[L1.RegSaveRet.7, 07];
Set[L1.RegSaveRet.8, 08];
Set[L1.RegSaveRet.9, 09];
Set[L1.RegSaveRet.A, 0A];
Set[L1.RegSaveRet.B, 0B];
Set[L1.RegSaveRet.C, 0C];
Set[L1.RegSaveRet.D, 0D];
Set[L1.RegSaveRet.E, 0E];
Set[L1.RegSaveRet.F, 0F];

Set[L1.RestoreTosB0, 00],
Set[L1.NoFixesB0, 01],
Set[L1.RestoreAndExitB0, 00],
Set[L1.RestoreAndPFB0, 01],

Stored in NewFuncDef.dfn
}

SetTask[0];

{*************************
	Read Map Update Subroutine 
**************************}
{Timing: 4 cycles}
{Enter at cycle 3, returns to cycle1}
{returns thru L0 if map fixed ok}
{returns thru L1 if wants to trap}


RLMapFixB0:

	Xbus ← Rx LRot0, XwdDisp,		c3;

	Map ← [rhTT,TT], DISP2[RFixRFlagsB0],	c1;

	MDR ← Rx or 10, L0Disp, GOTO[ReReadB0],	c2, at[0, 4, RFixRFlagsB0];
	MDR ← Rx or 10, L0Disp, GOTO[ReReadB0],	c2, at[1, 4, RFixRFlagsB0];
	MDR ← Rx or 10, L0Disp, GOTO[ReReadB0],	c2, at[2, 4, RFixRFlagsB0];
	L1Disp, GOTO[RWTrapB0],			c2, at[3, 4, RFixRFlagsB0];

ReReadB0:

	Xbus ← 1, XDisp, RET[RMapFixCallerB0],	c3;

{*************************
	Write Map Update Subroutine 
**************************}
{Timing: 4 cycles}
{Enter at cycle 3, returns to cycle1}
{returns thru L0 if map fixed ok}
{returns thru L1 if wants to trap}

WLMapFixB0:

	Xbus ← Rx LRot0, XwdDisp,			c3;
	Map ← [rhTT, TT], DISP2[FixWFlagsB0],		c1;

	MDR ← Rx or 030, L0Disp, GOTO[ReWriteB0],	c2, at[0, 4, FixWFlagsB0];
	MDR ← Rx or 030, L0Disp, GOTO[ReWriteB0],	c2, at[1, 4, FixWFlagsB0];
	L1Disp, GOTO[RWTrapB0],				c2, at[2, 4, FixWFlagsB0];
	L1Disp, GOTO[RWTrapB0],				c2, at[3, 4, FixWFlagsB0];

ReWriteB0:

	Xbus ← 1, XDisp, RET[WMapFixCallerB0],		c3;

RWTrapB0:

	DISP4[TrapFixesB0],				c3;

	GOTO[TrapFixesDoneB0c2],			c1, at[L1.NoFixesB0, 10, TrapFixesB0];

	TOS ← uTOS,					c1, at[L1.RestoreTosB0, 10, TrapFixesB0];
	TOSH ← uTOSH, GOTO[TrapFixesDoneB0c3],		c2;

ufnZ30:	Noop,				c3;

ufnZ10:	Noop,				c1;
ufnZ20:	TOS ← uTOS,			c2;
	TOSH ← uTOSH, GOTO[ufnX10],	c3;

ufnX20:	Noop,				c2;
ufnX30:	Noop,				c3;

ufnX10:	Bank ← EmuBank,			c1;
	Noop,				c2;
	S ← S + 1, CROSS[ufnB1],	c3;

OpTable0:

	Bank ← EmuBank,			c1, at[OpcodeBase];
	Noop,				c2;
	CROSS[OpcodeBase],		c3;

SaveAllRegsB0:
	Noop,				c*;
	
SaveAllRegsShB0:

	uTOS ← TOS,			c*;
	uTOSH ← TOSH,			c*;

SaveSomeRegsB0:

	uS ← S,				c*;{c1}
	uPVx ← PV, L1Disp,		c*;{c2}
	uPC ← PC, DISP4[SaveRegsB0Ret]	c*;{c3}

RestoreAllRegsAndExitB0:

	TOS ← uTOS, L1 ← L1.RestoreAndExitB0,	c2;
	TOSH ← uTOSH, GOTO[RestoreSomeRegsB0],	c3;

RestoreAllRegsAndPFB0:

	TOS ← uTOS, L1 ← L1.RestoreAndPFB0,	c2;
	TOSH ← uTOSH, GOTO[RestoreSomeRegsB0],	c3;

RestoreAllRegsB0:

	TOS ← uTOS,				c*;{c2}
	
RestoreMostRegsB0:

	TOSH ← uTOSH,				c*;{c3}
	
RestoreSomeRegsB0:

	rhS ← nRhS,				c*;{c1}
	rhPV ← nRhS,				c*;{c2}
	PV ← uPVx,				c*;{c3}
	
	S ←uS,					c*;{c1}{fix stack depth}	
	S ← S - Q, L1Disp,			c*;{c2}
	PC ← uPC, DISP4[RestoreRegsB0Ret],	c*;{c3}

	Bank ← EmuBank,				c1, at[L1.RestoreAndExitB0, 10, RestoreRegsB0Ret];
	PC ← PC + 1, L2 ← L2.0, IBDisp,		c2;
	L2 ← L2.0, DISPNI[OpTable0],		c3;

TrapFixesDoneB0c2:

	Noop,					c2;
	
TrapFixesDoneB0c3:

	Noop,					c3;

B0CrossToPFaultc1:

	Bank ← EmuBank,				c1, at[L1.RestoreAndPFB0, 10, RestoreRegsB0Ret];
	L1 ← L1.NoFixes,			c2;
	CROSS[PFaultB1],			c3;

	{ E N D }