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

; last modified by Butterfield, March 27, 1980  9:26 PM
; - reversed #Orbit.Mu and #TriConBody.Mu  - 3/27/80

#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 -- used for GetFrame, Return
; This code derived from [*]<Altosource>BcplRunTimeSources.dm(RamTrap.mu)

; Trap handler and dispatcher for instructions that trap into the RAM.  In the following predefinition,
; the tags correspond to opcodes 60000, 60400, 61000, 61400, ... 77400. Note that opcodes 60000, 60400,
; 61000, 64400, 65000, 67000, and 77400 cannot be used since control never gets to the RAM for these.

;							61400     62000	62400
!37, 40, TrapDispatch,,,GetFrame, Return,BcplUtility;

RamTrap: T←37;
	L←XREG AND T;
TrapDispatch:	SINK←LREG, BUS, TASK;
;Can't loop here because opcode 60000 doesn't cause RamTrap
	SINK←LREG, BUS, TASK;
	:TrapDispatch;

#TriConBody.Mu;		From [*]<Altosource>TFSSources.dm  3/27
#Orbit.Mu;			The body of the Orbit microcode
;#TriConBody.Mu;		From [*]<Altosource>TFSSources.dm  3/27
#GetFrame.Mu;		From [*]<Altosource>BcplRuntimeSources.dm
#BcplUtil.mu;