GenSJ.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Edward Fiala February 7, 1986 1:46:58 pm PST
This diagnostic tests the JS (stack jump) opcode, the SFC opcode, and the 32 bits on the K bus path from the EU back to the IFU. When correctly executed, it terminates with a Halt[177777B] on instruction 112, cycle 804, PC = 6000B.
DIRECTORY
DragOpsCross USING [XopBase, TrapBase, TrapWidthBytes, bytesPerWord, TrapIndex, Word],
--XopBase, TrapBase, TrapWidthBytes, Inst, wordsPerPage, bytesPerWord, charsPerWord, bitsPerByte, bitsPerCharacter, bitsPerWord, logWordsPerPage, logBitsPerByte, logBitsPerChar, logBytesPerWord, logCharsPerWord, logBitsPerWord, logBytesPerPage, PageCount, PageNumber, maxPagesInVM, SixBitIndex, FiveBitIndex, Word, TwoWords, FourBitIndex, Half, ThreeBitIndex, FourHalves, TwoHalves, Byte, ZerosByte, OnesByte, EightBytes, FourBytes, ByteIndex, BytesPerWord, TwoBytes, Comparison, ByteAddress, WordAddress, FieldDescriptor, TrapWidthWords, KernalLimit, TrapIndex, StackUnderflowTrap, IFUPageFaultTrap, ResetTrap, IFUStackOverflowTrap, EUStackOverflowTrap, RescheduleTrap, ALUCondOver, ALUCondBC, ALUCondIL, ALUCondDO, EUPageFault, EUWriteFault, AUFault, euStack, euJunk, euMAR, euField, euConstant, euAux, euBogus, euLast, ifuXBus, ifuStatus, ifuSLimit, ifuYoungestL, ifuYoungestPC, ifuEldestL, ifuEldestPC, ifuBogus, ifuL, ifuS, ifuPC, ifuLast, IFUStatusRec, IFUStackIndex, IFUStackSize, IFUOverflow, EUStackIndex, EUStackSize, EULocalIndex, EULocals, EUAuxIndex, EUAuxRegs, EUConstIndex, EUConstants, IOLocation, ioRescheduleRequest, ioResetRequest
DragOpsCrossUtils USING [CardToWord],
--BytePCToWordAddress, WordAddressToBytePC, IOOperandToCard, CardToIOOperand, FieldDescriptorToCard, CardToFieldDescriptor, StatusToWord, WordToStatus, BytesToWord, BytesToHalf, WordToBytes, HalfToBytes, HalvesToWord, WordToHalves, HighHalf, LowHalf, LeftHalf, RightHalf, SwapHalves, WordToInt, IntToWord, WordToCard, HalfToCard, ByteToCard, CardToWord, CardToHalf, CardToByte, DragAnd, DragOr, DragXor, DragNot, VanillaAdd, VanillaSub, AddDelta, HalfNot, HalfAnd, HalfOr, HalfXor, HalfShift, DoubleWordShiftLeft, SingleWordShiftLeft, SingleWordShiftRight, TrapIndexToBytePC, XopToBytePC
HandCoding, --Has opcode and register defs.
HandCodingPseudos, --GenLabel, GenLabelHere, SetLabel, Halt, Pause, MakeLabelGlobal, UseLabel8B, UseLabel16, UseLabel32, ProcedureEntry, ProcedureExit, EnableTraps, IndexedJump, SetupField, ExtractField, ShiftLeft, LoadProcessorReg, StoreProcessorReg, DisableTraps, CauseReschedule, CauseReset, GetSPLimit, SetSPLimit, GetL, SetL, GetYoungestPC, GetYoungestL, GetEldestPC, GetEldestL, SetYoungestPC, SetYoungestL, SetEldestPC, SetEldestL
HandCodingSupport; --Area, GetCurrentArea, ReserveData, SetOutputPC, GetProc, PutProc, ProcList, NewArea, GenWithArea, Gen1WithArea, ForceOut, GetOutputPC, WordAlign, OutputByte, OutputOneByte, OutputAlphaBeta, OutputAlphaBetaGammaDelta, OutputWord
GenSJ: CEDAR PROGRAM
IMPORTS DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport
= BEGIN OPEN DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport;
Word: TYPE = DragOpsCross.Word;
All: PROC = {
area: Area = GetCurrentArea[];
savePC: LONG CARDINAL;
enterSJTestPC: LONG CARDINAL = 2000B;
enterSFCTestPC: LONG CARDINAL = 4000B;
endTestPC: LONG CARDINAL = 6000B;
start: Label = GenLabel[];
dummy: Label = GenLabel[];
enterSJTest: Label = GenLabel[];
enterSFCTest: Label = GenLabel[];
endTest: Label = GenLabel[];
Xops trap at opcode*TrapWidthBytes + xopBase*bytesPerWord = 4,000,000B + 20B * opcode.
FillXop: PROC [inst: CARDINAL, dest: Label] = {
SetOutputPC[inst * DragOpsCross.TrapWidthBytes + DragOpsCross.XopBase * DragOpsCross.bytesPerWord];
drJDB[UseLabel16[dest]];
};
A trap's location is TrapIndex*TrapWidthBytes + TrapBase*bytesPerWord =
4,002,000B + 20B * TrapIndex. TrapIndex definitions are in DragOpsCross.
FillTrap: PROC [tx: DragOpsCross.TrapIndex, dest: Label] = {
SetOutputPC[LOOPHOLE[tx, CARDINAL] * DragOpsCross.TrapWidthBytes + DragOpsCross.TrapBase * DragOpsCross.bytesPerWord];
drJDB[UseLabel16[dest]];
};
Exercises all PC adder bits with SJ.
GenSJ: PROC = {
DoSJ: PROC [destPC: LONG CARDINAL] = {
oldPC: LONG CARDINAL;
drLIQB[CardToWord[destPC]];
oldPC ← GetOutputPC[area];
drJS[];
SetOutputPC[oldPC + destPC];
};
Page creation automatically fills the unused bytes in each page with 0, so a trap will happen if a wild jump or non-jump occurs.
SetOutputPC[enterSJTestPC];
SetLabel[enterSJTest];
Exercise every bit position of the pc address; must avoid the vector for Xops and Traps between byte positions 4000000B and 4004000B. (DoSJ[d] changes the PC by d + 5 because of the 5 bytes in LIQB.)
DoSJ[ 200040B]; --PC = 202045B
DoSJ[ 400100B]; --PC = 602152B
DoSJ[ 1000200B]; --PC = 1602357B
DoSJ[ 2000400B]; --PC = 3602764B
DoSJ[ 4001000B]; --PC = 7603771B
DoSJ[ 10002000B]; --PC = 17605776B
DoSJ[ 20004001B]; --PC = 37612004B
DoSJ[ 40010002B]; --PC = 77622013B
DoSJ[ 100020004B]; --PC = 177642024B
DoSJ[ 200040010B]; --PC = 377702041B
DoSJ[ 400100020B]; --PC = 1000002066B
DoSJ[ 1000000000B]; --PC = 2000002073B
DoSJ[ 2000000000B]; --PC = 4000002100B
DoSJ[ 4000000000B]; --PC = 10000002105B
DoSJ[10000000000B]; --PC = 20000002112B
DoSJ[20000000000B]; --PC = 2117B
};
GenSFC: PROC = {
Define procedure for putting out a SFC opcode. Page creation automatically fills the unused bytes in each page with 0, so a trap will happen if a wild jump or non-jump occurs.
DoSFC: PROC [destPC: LONG CARDINAL] ~ {
drADDB[200B];
drLIQB[CardToWord[destPC]];
drSFC[];
drADDB[1];
drRETN[];
SetOutputPC[destPC];
};
okSFC: Label = GenLabel[];
drJQB[UseLabel32[enterSFCTest]];
SetOutputPC[enterSFCTestPC];
SetLabel[enterSFCTest];
Exercise every bit position of the pc address; must avoid the vector for Xops and Traps between byte positions 4000000B and 4004000B.
drLIB[0]; --Counter used to verify that the calls and returns have occurred.
drLIQB[CardToWord[400100B]];
drSFC[];
drLIQB[CardToWord[3416B]];
drRJEB[popSrc, belowSrcPop, UseLabel8B[okSFC]];
Pause[];
SetLabel[okSFC];
drJQB[UseLabel32[endTest]];
SetOutputPC[400100B];
DoSFC[ 1000200B]; --[s] = 200B after the SFC, 3416B after the RETN
DoSFC[ 2000400B]; --[s] = 400B after the SFC, 3415B after the RETN
DoSFC[ 4010000B]; --[s] = 600B after the SFC, 3414B after the RETN
DoSFC[ 10002000B]; --[s] = 1000B after the SFC, 3413B after the RETN
DoSFC[ 20004001B]; --[s] = 1200B after the SFC, 3412B after the RETN
DoSFC[ 40001002B]; --[s] = 1400B after the SFC, 3411B after the RETN
DoSFC[ 100020004B]; --[s] = 1600B after the SFC, 3410B after the RETN
DoSFC[ 200040010B]; --[s] = 2000B after the SFC, 3407B after the RETN
DoSFC[ 400100020B]; --[s] = 2200B after the SFC, 3406B after the RETN
DoSFC[ 1000000000B]; --[s] = 2400B after the SFC, 3405B after the RETN
DoSFC[ 2000000000B]; --[s] = 2600B after the SFC, 3404B after the RETN
DoSFC[ 4000000000B]; --[s] = 3000B after the SFC, 3403B after the RETN
DoSFC[10000000000B]; --[s] = 3200B after the SFC, 3402B after the RETN
DoSFC[20000200040B]; --[s] = 3400B after the SFC, 3401B after the RETN
drRETN[];
};
WordAlign[area];
SetLabel[dummy];
Pause[]; Pause[]; Pause[]; Pause[]; Pause[]; Halt[177777B];
Opcodes 0 and 377B are intercepted by the simulator, but make them trap to dummy here anyway.
savePC ← GetOutputPC[area];
FillTrap[ResetTrap, start];
FillXop[0, dummy];
FillXop[377B, dummy];
SetOutputPC[savePC];
WordAlign[area];
SetLabel[start]; --Simulator execution begins here on a Reset.
drJQB[UseLabel32[enterSJTest]];
GenSJ[];
GenSFC[];
SetOutputPC[endTestPC];
SetLabel[endTest];
Halt[177777B]; --PC = 2044B Terminate here at the end of the program
};
END.