{File: RumByteCodes.mc

	12-Dec-84 23:03:53

Lasr edited by Makoto Udagawa 22-Feb-85 13:33:10  Modify Bank value for 2MWord smalltalk-80.
}

{
	This file contains the code to switch from the Mesa bank to the Interpreter bank
	
}



{Register equates for saving the address of the Rum Communications Record -- these registers are completely unused by Mesa.  This is essential if we are to continue Rum microcode after going to the Mesa debugger (or any other non-smalltalk MDE volume).}

	RegDef [uRumRecordHigh, U, 49];
	RegDef [uRumRecordLow, U, 5f];

	Set [objectTableHighOffset, 12];
	Set [objectHeaderSize, 3];



doInitializationBytecode:
	Bank ← 5,								c1, at [0A, 10, ESC8n];
	Noop,									c2;
	GOTOABS [doInitialization],						c3;



returnFromRumBank:	
	TOS ← STK, pop, GOTO [IBDispOnly],					c1, at [returnFromRumBank];



doBytecodesBytecode:
	Bank ← 5, L0 ← 0, 							c1, at [0B, 10, ESC8n];
	Noop,									c2;
		
switchToRum:
	GOTOABS [doBytecodes],							c3;



doStabilizationBytecode:
	Bank ← 5, L0 ← 1,							c1, at [0C, 10, ESC8n];
	GOTO [switchToRum],							c2;



doCompress:
	Bank ← 5, L0 ← 2,							c1, at [0D, 10, ESC8n];
	GOTO [switchToRum],							c2;



pMemFetch:	{PMemFetch: PROCEDURE [address: VirtualAddress] RETURNS [Word]}
	rhT ← TOS LRot0,							c1, at [4, 10, ESC8n];
	T ← STK, fXpop, fZpop,							c2;
	Noop,									c3;

{	MAR ← [rhT, T + 0],							c1; {read word}
	CANCELBR [$, 2],							c2;
	TOS ← MD,								c3;

	Noop,									c1;
	IBDisp,									c2;
	DISPNI [OpTable],							c3;}

	MAR ← [rhT, T + 0],							c1; {read word}
	IBDisp, CANCELBR [$, 2],						c2;
	TOS ← MD, DISPNI [OpTable],						c3;


pMemSmash:	{PMemSmash: PROCEDURE [address: VirtualAddress, value: Word]}
	rhT ← STK, pop, {high address}						c1, at [5, 10, ESC8n];
	T ← STK, pop, {low address}						c2;
	Noop, {TOS = value}							c3;

{	MAR ← [rhT, T + 0],							c1; {smash word}
	MDR ← TOS, LOOPHOLE [wok], CANCELBR [$, 2],				c2;
	TOS ← STK, pop, 							c3;

	Noop,									c1;
	IBDisp,									c2;
	DISPNI [OpTable],							c3;}

	MAR ← [rhT, T + 0],							c1; {smash word}
	MDR ← TOS, LOOPHOLE [wok], IBDisp, CANCELBR [$, 2],			c2;
	TOS ← STK, pop, DISPNI [OpTable],					c3;


getBase:	{GetBase: PROCEDURE [oop: Word] RETURNS [RealAddress]}
	TT ← TOS, fXpop, push,							c1, at [6, 10, ESC8n];
	rhT ← uRumRecordHigh, push, 						c2;
	T ← uRumRecordLow,							c3;

	MAR ← [rhT, T + objectTableHighOffset],					c1; {read ot base}
	push, fZpop, CANCELBR [$, 2],						c2;
	rhTT ← MD, 								c3;

	MAR ← [rhTT, TT + 0],							c1; {index ot, get low addr}
	CANCELBR [$, 2],							c2;
	T ← MD,									c3;

	MAR ← [rhTT, TT + 1],							c1; {index ot, get high addr}
	T ← T + objectHeaderSize, IBDisp, CANCELBR [$, 2],			c2; {adjust low}
	STK ← T, TOS ← MD, DISPNI [OpTable],					c3;






{getBase:	{GetBase: PROCEDURE [oop: Word] RETURNS [RealAddress]}
	TT ← TOS, fXpop, push,							c1, at [6, 10, ESC8n];
	rhT ← uRumRecordHigh, 							c2;
	T ← uRumRecordLow, 							c3;

	MAR ← [rhT, T + objectTableHighOffset],					c1; {read ot base}
	CANCELBR [$, 2],							c2;
	rhTT ← MD, 								c3;

	MAR ← [rhTT, TT + 0],							c1; {index ot, get low addr}
	CANCELBR [$, 2],							c2;
	T ← MD,									c3;

	MAR ← [rhTT, TT + 1],							c1; {index ot, get high addr}
	T ← T + objectHeaderSize, CANCELBR [$, 2],				c2; {adjust low}
	TOS ← MD, push,								c3; {push high addr}

	STK ← T, push, fZpop,							c1; {push low addr}
	IBDisp,									c2;
	DISPNI [OpTable],							c3;}