DragonReset.mesa
Russ Atkinson, March 21, 1984 12:25:16 pm PST
DIRECTORY
DragOpsCross,
DragOpsCrossUtils,
HandCoding,
HandCodingPseudos,
HandCodingSupport;
DragonReset: CEDAR PROGRAM
IMPORTS DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport
= BEGIN OPEN DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport;
Word: TYPE = DragOpsCross.Word;
ZerosWord: Word = DragOpsCross.ZerosWord;
GenSetVectorConstant: PROC [entryLabel: Label] = {
addrLocal: RegSpec = reg0;
lenLocal: RegSpec = reg1;
wordLocal: RegSpec = reg2;
finishLabel: Label = GenLabel[];
ProcedureEntry[entryLabel, 3];
drLRn[lenLocal];
drRJLBJ[popLeft: FALSE, right: const4, dist: UseLabel8[finishLabel]];
{loopLabel: Label = GenLabelHere[];
exitLabel: Label = GenLabel[];
drSUBB[4];
drWRI[wordLocal, addrLocal, 0];
drWRI[wordLocal, addrLocal, 1];
drWRI[wordLocal, addrLocal, 2];
drWRI[wordLocal, addrLocal, 3];
drRVADD[c: addrLocal, a: addrLocal, b: const4];
drRJGEBJ[popLeft: FALSE, right: const4, dist: UseLabel8[loopLabel]];
SetLabel[finishLabel];
drRJLEB[popLeft: FALSE, right: const0, dist: UseLabel8[exitLabel]];
drWRI[wordLocal, addrLocal, 0];
drRJLEB[popLeft: FALSE, right: const1, dist: UseLabel8[exitLabel]];
drWRI[wordLocal, addrLocal, 1];
drRJLEB[popLeft: FALSE, right: const2, dist: UseLabel8[exitLabel]];
drWRI[wordLocal, addrLocal, 2];
SetLabel[exitLabel];
};
ProcedureExit[0];
};
GenMoveVector: PROC [entryLabel: Label] = {
srcLocal: RegSpec = reg0;
lenLocal: RegSpec = reg1;
dstLocal: RegSpec = reg2;
finishLabel: Label = GenLabel[];
ProcedureEntry[entryLabel, 3];
drLRn[lenLocal];
drRJLBJ[popLeft: FALSE, right: const4, dist: UseLabel8[finishLabel]];
{loopLabel: Label = GenLabelHere[];
exitLabel: Label = GenLabel[];
drSUBB[4];
drLRIn[srcLocal, 0];
drLRIn[srcLocal, 1];
drLRIn[srcLocal, 2];
drLRIn[srcLocal, 3];
drRVADD[c: srcLocal, a: srcLocal, b: const4];
drSRIn[dstLocal, 3];
drSRIn[dstLocal, 2];
drSRIn[dstLocal, 1];
drSRIn[dstLocal, 0];
drRVADD[c: dstLocal, a: dstLocal, b: const4];
drRJGEBJ[popLeft: FALSE, right: const4, dist: UseLabel8[loopLabel]];
SetLabel[finishLabel];
drRJLEB[popLeft: FALSE, right: const0, dist: UseLabel8[exitLabel]];
drLRIn[srcLocal, 0];
drSRIn[dstLocal, 0];
drRJLEB[popLeft: FALSE, right: const1, dist: UseLabel8[exitLabel]];
drLRIn[srcLocal, 1];
drSRIn[dstLocal, 1];
drRJLEB[popLeft: FALSE, right: const2, dist: UseLabel8[exitLabel]];
drLRIn[srcLocal, 2];
drSRIn[dstLocal, 2];
SetLabel[exitLabel];
};
ProcedureExit[0];
};
All: PROC = {
bytesPerTrap: CARDINAL = DragOpsCross.TrapWidth * DragOpsCross.bytesPerWord;
FillTrap: PROC [tx: DragOpsCross.TrapIndex, dest: Label] = {
oldPC: INT = GetOutputPC[area];
SetOutputPC[DragOpsCross.TrapBase+LOOPHOLE[tx, CARDINAL] * bytesPerTrap, area];
drJDB[UseLabel16[dest]];
SetOutputPC[oldPC];
};
FillXop: PROC [inst: DragOpsCross.Inst, dest: Label] = {
oldPC: INT = GetOutputPC[area];
SetOutputPC[DragOpsCross.XopBase+LOOPHOLE[inst, CARDINAL] * bytesPerTrap, area];
drJDB[UseLabel16[dest]];
SetOutputPC[oldPC];
};
area: Area = GetCurrentArea[];
start: Label = GenLabel[];
procSetVectorConstant: Label = GenLabel[];
SetOutputPC[20000B];
SetLabel[start];
drRXOR[c: const0, a: const0, b: const0];
drLIB[1]; drROR[c: const1, a: const0, b: popSrc];
drRVADD[c: const2, a: const1, b: const1];
drRVADD[c: const3, a: const2, b: const1];
drRVADD[c: const4, a: const3, b: const1];
drRVSUB[c: constN2, a: const0, b: const2];
drRVSUB[c: constN1, a: const0, b: const1];
drLIDB[100000B]; drROR[c: constNSI, a: const0, b: popSrc];
drLC1[]; drSHL[FieldDescriptorToCard[[insert: FALSE, mask: 32, shift: 31]]];
drROR[c: constNI, a: const0, b: popSrc];
drROR[c: constU, a: const0, b: const0];
drROR[c: global, a: const0, b: constNSI]; -- the base of global data
FOR i: NAT IN [1..15] DO
drROR[c: [aux[i]], a: const0, b: const0];
ENDLOOP;
drROR[c: pushDst, a: const0, b: global];
drLIDB[256];
drLC0[];
drLFC[UseLabel16[procSetVectorConstant]];
drJDB[UseLabel16[start]];
GenSetVectorConstant[procSetVectorConstant];
SetOutputPC[100000B, area];
OutputWord[area, ZerosWord]; -- force this page to exist
FillTrap[ResetTrap, start];
FillXop[dTrap, start];
FillXop[dLast, start];
};
END.