; OrbitMc.Mu - Microcode for Orbit, TriCon
; PackMu OrbitMc.Mb OrbitMc.Br 77764

#AltoConsts23.mu;

; Predefinitions for task starting locations and emulator-level
; subroutine entry points.

%0, 1777, 0, EXITRAM;		Emulator task start
%0, 1777, 1, ORBIT;		Orbit start
%0, 1777, 3, LOC3;		Write task start
%0, 1777, 16, LOC16;		(See below)
%0, 1777, 17, LOC17;		Read task start
%0, 1777, 20, START;		(See below)
%0, 1777, 21, LOC21;		ModShift subroutine for ECC
%0, 1777, 22, LOC22;		SetBLV subroutine
%0, 1777, 37, RamTrap;		RamTrap subroutine

; There is a hack in the read microcode that causes the reset location
; for task 16 to be used.  This means that it is not possible to run
; task 16 (= Diablo disk word task) in the Ram.

; Lock out the Ram Utility Area

%7, 1777, 774, RU774, RU775, RU776, RU777, RU1000, RU1001, RU1002, RU1003;

RU774:	NOP;
RU775:	NOP;
RU776:	NOP;
RU777:	NOP;
RU1000:	NOP;
RU1001:	NOP;
RU1002:	NOP;
RU1003:	NOP;

; Stuff lifted from EmulatorDefs.mu:
; Standard R-registers usable by the emulator task

$AC3		$R0;	Accumulators
$AC2		$R1;
$AC1		$R2;
$AC0		$R3;
$NWW		$R4;	New wakeups waiting (communication between tasks)
$SAD		$R5;	Temporary private to emulator
$PC		$R6;	Program Counter for emulated Nova
$XREG		$R7;	Temporary private to emulator.
;			Contains instruction LCY 8 upon dispatch to TRAP1.
$XH		$R10;	Temporary private to emulator
$MTEMP		$R25;	Temporary usable by any task
$DWAX		$R35;	Temporary private to emulator
$MASK		$R36;	Temporary private to emulator

$LREG		$R40;	Another name for the M-register


;***THIS INSTRUCTION WILL CAUSE THE BOOT-LOCUS-VECTOR TO BE
;*** SET TO THE VALUE IN AC0 AT THE NEXT BOOT

LOC22:	RMR←AC0,:EXITRAM;


;***THIS CODE IS CAREFULL PLACED IN THE RAM
;***FOR AN EMULATOR "NO-OP BOOT".
;***THE LSB OF THE BOOT-LOCUS-VECTOR MUST BE 0 FOR THIS TO WORK
;
EXITRAM: SWMODE;	GO TO LOCATION 20 IN THE RAM, AND THEN
START:	:START;		RETURN TO LOCATION 20 IN THE ROM

; RAM TRAP -- return trap to software

RamTrap: T←37;
	L←XREG AND T;
	MAR← TRAPPC;
	T← LREG;
	MD← PC;
	MAR← TRAPPC+T+1;
	NOP;
	L← MD, TASK;
	PC← L, :EXITRAM;			**

#TriConBody.Mu;		From [*]<Altosource>TFSSources.dm
#Orbit.Mu;			The body of the Orbit microcode