INSERT[D0LANG];
:TITLE[d0rdt];
*Edit by ERF 1 May 1981
*Edit by CT June 10, 1979
SETTASK[17];

RV[REFR,77];	*memory refresh address

*The following registers hold the volatile state of the processor on a fault: 
RV[RXALU,76];	*ALU result and SALUF
RV[RXAPC,75];	*APCTask&APC
RV[RXCTASK,74];	*CTASK.NCIA
RV[RXPPB,73];	*Page,Parity,BootReason
RV[RXSTK,72];	*Stackpointer

RV[RTMP,71];	*temporary

*The following registers are used for D0-Midas communication (RTMP is also used):
RV[RWSTAT,70];	*status register
RV[RDATA,67];	*holds data

*FFault determines how faults will be treated when programs are running.  If it is
*zero, all faults will be reported to Midas.  If FFault is nonzero, the kernel will
*send control through location 120 when a fault occurs and PARITY # 0 (faults with
*PARITY = 0 are breakpoints).
RV[FFAULT,66];

*Registers between 360 and 367 are used by the Midas overlays.  The following 
*registers, used by WriteMI,  are also in this range.
RV[RADDR,65];

RV[RCNT,64];
RV[STACK4,64];

RV[RW0,63];
RV[STACK3,63];

RV[RW1,62];
RV[STACK2,62];

RV[STACK1,61];
MC[pStk1,361]; *pointer to stack1
RV[STACK0,60];


*Constants for Recv and Send
MC[RecvByte,12];
MC[RecvWord,16];
MC[SendByte,21];
MC[SendWord,25];

*The following are at fixed locations in Kernel.mc:
UserFault:	Return, At[120];
NextCom:	Return, At[7404];
ReadRX:	Return, At[7406];
Send:	Return, At[7460];
Recv:	Return, At[7464];

*d0rdt overlay
*Used by Midas to read T for any task.

*Notify task n to do the read
OverlayArea:
	RWSTAT ← RecvByte, Call[Recv], At[7500];	*get task number
	Stack1 ← T, At[7501];
	T ← 7400C, At[7502];
	Stack1 ← (LSh[Stack1,14]) + T, At[7503];
*Point Stack1 at task n, location GetT (7511)
	Stack1 ← (Stack1) + (111C), At[7504];
	RTMP ← pStk1,At[7505];
	StkP ← RTMP, At[7506];	*Point StkP at Stack1
*Point Stack0 at task 17, location 7515
	Stack0 ← 177400C, At[7507];
	Stack0 ← (Stack0) + (115C), GoTo[NotifyBothWays], At[7510];

GetT:	Stack&+1 ← T, At[7511];	*Stack1 ← T
	Stack&-1, At[7512];	*point to Return address
NotifyBothWays:
	APC&APCTask ← Stack&-1, At[7513];
	Return, At[7514];
*Back in task 17; get recovered T and send it.
	T ← Stack1, GoTo[ReadRX], At[7515];

:END;