<> <> <> <> <> <> <> <<`Old Code' replaced by `New Code'.>> <> <> <> <<>> <> DIRECTORY Basics USING [BITXOR, BITAND], DragOpsCross USING [Inst, XopBase, TrapBase, TrapWidthBytes, bytesPerWord, TrapIndex, Word], --Word, wordsPerPage, bytesPerWord, charsPerWord, bitsPerByte, bitsPerCharacter, bitsPerWord, bytesPerPage, logWordsPerPage, logBitsPerByte, logBitsPerChar, logBytesPerWord, logCharsPerWord, logBitsPerWord, logBytesPerPage, PageCount, PageNumber, maxPagesInVM, SixBitIndex, FiveBitIndex, TwoWords, FourBitIndex, Half, ThreeBitIndex, FourHalves, TwoHalves, Byte, ZerosByte, OnesByte, EightBytes, FourBytes, ByteIndex, BytesPerWord, TwoBytes, Comparison, ByteAddress, WordAddress, FieldDescriptor, RegIndex, PadByte, Lit8, Op4, Op8, JDist8, Inst, OIFormat, OQBformat, LRformat, QRformat, ShortRegQR, OBformat, LRBformat, RRformat, ODBformat, LRRBformat, RJBformat, ShortRegRJB, JBBformat, TrapWidthWords, TrapWidthBytes, XopBase, TrapBase, KernalLimit, TrapIndex, StackUnderflowTrap, IFUPageFaultTrap, ResetTrap, IFUStackOverflowTrap, EUStackOverflowTrap, RescheduleTrap, ALUCondFalse, ALUCondEZ, ALUCondLZ, ALUCondLE, ALUCondSpare, ALUCondNE, ALUCondGE, ALUCondGZ, ALUCondOver, ALUCondBC, ALUCondIL, ALUCondDO, ALUCondNotOver, ALUCondNB, ALUCondNI, ModeFault, MemAccessFault, IOAccessFault, EUPageFault, EUWriteFault, AUFault, euStack, euJunk, euToKBus, euMAR, euField, euConstant, euAux, euBogus, euLast, ifuYoungestL, ifuYoungestPC, ifuEldestL, ifuEldestPC, ifuSLimit, ifuBogus, ifuL, ifuS, ifuPC, ifuLast, EURegs, EULegalRegs, IFURegs, IFULegalRegs, StackedStatusWord, IFUStackIndex, IFUStackSize, IFUOverflow, EUStackIndex, EUStackSize, EULocalIndex, EULocals, EUAuxIndex, EUAuxRegs, EUConstIndex, EUConstants, IOLocation, ioRescheduleRequest, ioResetRequest, IOOperand, PCmdFormat, PCmdByteSelect, PCmdClass, PCmdSpace, PCmdDirection DragOpsCrossUtils USING [CardToWord, CardToByte, InstToBytes], --InstToBytes, InstToFormat, BytePCToWordAddress, WordAddressToBytePC, IOOperandToCard, CardToIOOperand, FieldDescriptorToCard, CardToFieldDescriptor, 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, XopToBytePC, TrapIndexToBytePC, FieldUnit HandCoding, --Has opcode and register defs. HandCodingPseudos, --Label, SetLabel, GenLabel, GenLabelHere, UseLabel8A, UseLabel8B, UseLabel16, UseLabel32, LReg, PReg, SReg, AddReg, SubReg, SetRegConst, MoveReg, MoveRegI, LRegI, IndexedJump, ProcedureEntry, ProcedureExit, SetupField, ExtractField, ShiftLeft, LoadProcessorReg, StoreProcessorReg, CauseReschedule, CauseReset, GetSPLimit, SetSPLimit, GetYoungestPC, GetYoungestStatus, GetEldestPC, GetEldestStatus, SetYoungestPC, SetYoungestStatus, SetEldestPC, SetEldestStatus, Pause, Halt HandCodingSupport, --Area, GetProc, PutProc, ProcList, NewArea, GenWithArea, Gen1WithArea, ForceOut, GetCurrentArea, LoadArea, GetOutputPC, SetOutputPC, WordAlign, ReserveData, OutputByte, OutputOneByte, OutputAlphaBeta, OutputAlphaBetaGammaDelta, OutputWord HandCodingUtil, Rope; GenXopLS: CEDAR PROGRAM IMPORTS Basics, DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport, HandCodingUtil, Rope = BEGIN OPEN DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport; XopBase: LONG CARDINAL = DragOpsCross.XopBase; TrapWidthBytes: NAT = DragOpsCross.TrapWidthBytes; bytesPerWord: CARDINAL = DragOpsCross.bytesPerWord; aux13: AuxRegSpec = [aux[13]]; names: HandCodingUtil.NameArray _ HandCodingUtil.GetInstArray[]; All: PROC = { <> FillXop: PROC [inst: CARDINAL, dest: Label] = { SetOutputPC[inst * DragOpsCross.TrapWidthBytes + DragOpsCross.XopBase * DragOpsCross.bytesPerWord]; drJDB[UseLabel16[dest]]; }; <> FillTrap: PROC [tx: DragOpsCross.TrapIndex, dest: Label] = { SetOutputPC[LOOPHOLE[tx, CARDINAL] * DragOpsCross.TrapWidthBytes + DragOpsCross.TrapBase * DragOpsCross.bytesPerWord]; drJDB[UseLabel16[dest]]; }; GetYoungestL: PROC = { GetYoungestStatus[]; drLIB[377B]; drAND[] }; area: Area = GetCurrentArea[]; savePC: LONG CARDINAL; enterXopTest: Label = GenLabel[]; enterALTest: Label = GenLabel[]; enterASTest: Label = GenLabel[]; enterDISTest: Label = GenLabel[]; enterASLTest: Label = GenLabel[]; enterALSTest: Label = GenLabel[]; <> GenXop: PROC [] ~ { Xop5Trap: Label = GenLabel[]; abgdPushed: Label = GenLabel[]; GenXop1Trap: PROC [I: CARDINAL] ~ { notBeingTested: Label = GenLabel[]; SetOutputPC[(I * TrapWidthBytes) + (XopBase * bytesPerWord)]; <> drLIB[I]; drRJNEB[popSrc, aux13, UseLabel8B[notBeingTested]]; drLIDB[12345B]; --Return value indicating trap routine was executed drRETN[]; --Return without changing S SetLabel[notBeingTested]; Pause[]; --Unexpected occurrence of Xop trap for opcode I }; GenXop1Test: PROC [I: CARDINAL] ~ { xop1OK: Label = GenLabel[]; drLIB[I]; drRAND[c: aux13, a: topSrc, b: popSrc]; --aux13 _ xop opcode OutputByte[area, CardToByte[I]]; drLIDB[12345B]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[xop1OK]]; Pause[]; SetLabel[xop1OK]; }; GenXop2Trap: PROC [I: CARDINAL] ~ { problem: Label = GenLabel[]; SetOutputPC[(I * TrapWidthBytes) + (XopBase * bytesPerWord)]; <> drLIB[I]; drRJNEB[popSrc, aux13, UseLabel8B[problem]]; --Being tested? drLIB[Basics.BITXOR[I, 377B]]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[problem]]; --Alpha pushed? drLIDB[23456B]; --Return value indicating trap routine was executed drRETN[]; --Return without changing S SetLabel[problem]; Pause[]; --Unexpected occurrence of Xop trap for opcode I }; GenXop2Test: PROC [I: CARDINAL] ~ { xop2OK: Label = GenLabel[]; drLIB[I]; drRAND[c: aux13, a: topSrc, b: popSrc]; --aux13 _ xop opcode OutputAlphaBeta[area, (I * 400B) + Basics.BITXOR[I, 377B]]; drLIDB[23456B]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[xop2OK]]; Pause[]; SetLabel[xop2OK]; }; GenXop3Trap: PROC [I: CARDINAL] ~ { problem: Label = GenLabel[]; SetOutputPC[(I * TrapWidthBytes) + (XopBase * bytesPerWord)]; <> drLIB[I]; drRJNEB[popSrc, aux13, UseLabel8B[problem]]; --Trap expected? drLIDB[177400B + I]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[problem]]; --AlphaBeta pushed? drLIDB[34567B]; --Return value indicating trap routine was executed drRETN[]; --Return without changing S SetLabel[problem]; Pause[]; --Unexpected occurrence of Xop trap for opcode I }; GenXop3Test: PROC [I: CARDINAL] ~ { xop3OK: Label = GenLabel[]; drLIB[I]; drRAND[c: aux13, a: topSrc, b: popSrc]; --aux13 _ xop opcode OutputByte[area, CardToByte[I]]; --Should take Xop trap OutputAlphaBeta[area, 177400B + I]; drLIDB[34567B]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[xop3OK]]; Pause[]; SetLabel[xop3OK]; }; GenXop5Trap: PROC [I: CARDINAL] ~ { notBeingTested: Label = GenLabel[]; SetOutputPC[(I * TrapWidthBytes) + (XopBase * bytesPerWord)]; <> drLIB[I]; drRJNEB[popSrc, aux13, UseLabel8B[notBeingTested]]; drLIQB[CardToWord[37777777400B + LONG[I]]]; drJDB[UseLabel16[Xop5Trap]]; SetLabel[notBeingTested]; Pause[]; --Unexpected occurrence of Xop trap for opcode I }; GenXop5Test: PROC [I: CARDINAL] ~ { xop5OK: Label = GenLabel[]; drLIB[I]; drRAND[c: aux13, a: topSrc, b: popSrc]; --aux13 _ xop opcode OutputByte[area, CardToByte[I]]; OutputWord[area, CardToWord[37777777400B + LONG[I]]]; --Should take Xop trap drLIDB[45670B]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[xop5OK]]; Pause[]; SetLabel[xop5OK]; }; <> SetLabel[Xop5Trap]; --Did Xop push AlphaBetaGammaDelta correctly? drRJEBJ[popSrc, belowSrcPop, UseLabel8B[abgdPushed]]; Pause[]; --Xop did not push AlphaBetaGammaDelta correctly. SetLabel[abgdPushed]; drLIDB[45670B]; drRETN[]; --Return without changing S <> <> <<>> <> <> savePC _ GetOutputPC[area]; FOR I: CARDINAL IN (0..377B) DO inst: DragOpsCross.Inst _ LOOPHOLE[I]; name: Rope.ROPE _ names[inst]; length: NAT _ DragOpsCrossUtils.InstToBytes[inst]; IF name.Fetch[]#'x THEN LOOP; SELECT I FROM 311B, 313B, 337B, 340B, 344B, 350B, 354B => LOOP; ENDCASE; SELECT length FROM 1 => GenXop1Trap[I]; 2 => GenXop2Trap[I]; 3 => GenXop3Trap[I]; 5 => GenXop5Trap[I]; ENDCASE => ERROR; ENDLOOP; SetOutputPC[savePC]; <<>> <> SetLabel[enterXopTest]; FOR I: CARDINAL IN (0..377B) DO inst: DragOpsCross.Inst _ LOOPHOLE[I]; name: Rope.ROPE _ names[inst]; length: NAT _ DragOpsCrossUtils.InstToBytes[inst]; IF name.Fetch[]#'x THEN LOOP; SELECT I FROM 311B, 313B, 337B, 340B, 344B, 350B, 354B => LOOP; ENDCASE; SELECT length FROM 1 => GenXop1Test[I]; 2 => GenXop2Test[I]; 3 => GenXop3Test[I]; 5 => GenXop5Test[I]; ENDCASE => ERROR; ENDLOOP }; <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<};>> <> GenAL: PROC [] ~ { TestAL: PROC [originalL, alpha: CARDINAL] ~ { pushL: Label = GenLabel[]; lOK: Label = GenLabel[]; alExit: Label = GenLabel[]; newL: CARDINAL = Basics.BITAND[originalL + alpha, 177B]; drAL[alpha]; drLFC[UseLabel16[pushL]]; drJDB[UseLabel16[alExit]]; SetLabel[pushL]; GetYoungestL[]; drJEBBJ[newL, UseLabel8B[lOK]]; Pause[]; --L was wrong SetLabel[lOK]; drRETN[]; SetLabel[alExit]; }; <> SetLabel[enterALTest]; TestAL[1, 127]; --L _ 0 TestAL[0, 1]; --L _ 1 TestAL[1, 2]; --L _ 3 TestAL[3, 4]; --L _ 7 TestAL[7, 8]; --L _ 15 TestAL[15, 16]; --L _ 31 TestAL[31, 32]; --L _ 63 TestAL[63, 64]; --L _ 127 TestAL[127, 128]; --L _ 127 TestAL[127, 0]; --L _ 127 TestAL[127, 64]; --L _ 63 TestAL[63, 32]; --L _ 95 TestAL[95, 16]; --L _ 111 TestAL[111, 8]; --L _ 119 TestAL[119, 4]; --L _ 123 TestAL[123, 2]; --L _ 125 TestAL[125, 1]; --L _ 126 drAL[3]; --L _ 1 }; <> GenALS: PROC [] ~ { TestALS: PROC [originalS, alpha: CARDINAL] ~ { pushL: Label = GenLabel[]; lOK: Label = GenLabel[]; alsExit: Label = GenLabel[]; newL: CARDINAL _ Basics.BITAND[originalS + alpha, 177B]; drALS[alpha]; --L _ newL drLFC[UseLabel16[pushL]]; --push L (= S) on the IFU stack for checking drJDB[UseLabel16[alsExit]]; SetLabel[pushL]; GetYoungestL[]; drJEBBJ[newL, UseLabel8B[lOK]]; Pause[]; --L was wrong, so S was wrong. SetLabel[lOK]; drRETN[]; SetLabel[alsExit]; }; <> SetLabel[enterALSTest]; <> TestALS[0, 1]; --[L, S] _ [1, 0] TestALS[0, 2]; --[L, S] _ [2, 0] TestALS[0, 4]; --[L, S] _ [4, 0] TestALS[0, 8]; --[L, S] _ [8, 0] TestALS[0, 16]; --[L, S] _ [16, 0] TestALS[0, 32]; --[L, S] _ [32, 0] TestALS[0, 64]; --[L, S] _ [64, 0] TestALS[0, 128]; --[L, S] _ [0, 0] <> drAS[127]; --[L, S] _ [0, 127] TestALS[127, 0]; --[L, S] _ [127, 127] TestALS[127, 128]; --[L, S] _ [127, 127] TestALS[127, 64]; --[L, S] _ [63, 127] TestALS[127, 32]; --[L, S] _ [31, 127] TestALS[127, 16]; --[L, S] _ [15, 127] TestALS[127, 8]; --[L, S] _ [7, 127] TestALS[127, 4]; --[L, S] _ [3, 127] TestALS[127, 2]; --[L, S] _ [1, 127] TestALS[127, 1]; --[L, S] _ [0, 127] drAS[1]; --[L, S] _ [0, 0] drALS[1]; --[L, S] _ [1, 0] restores original value }; <> GenAS: PROC [] ~ { TestAS: PROC [originalS, alpha: CARDINAL] ~ { pushL: Label = GenLabel[]; sOK: Label = GenLabel[]; asExit: Label = GenLabel[]; newS: CARDINAL = Basics.BITAND[originalS + alpha, 177B]; drAS[alpha]; drALS[0]; --L _ S drLFC[UseLabel16[pushL]]; drJDB[UseLabel16[asExit]]; SetLabel[pushL]; GetYoungestL[]; drJEBBJ[newS, UseLabel8B[sOK]]; Pause[]; --L was wrong, so S was wrong. SetLabel[sOK]; drRETN[]; SetLabel[asExit]; }; <> SetLabel[enterASTest]; TestAS[0, 1]; --[L, S] _ [1, 1] TestAS[1, 2]; --[L, S] _ [3, 3] TestAS[3, 4]; --[L, S] _ [7, 7] TestAS[7, 8]; --[L, S] _ [15, 15] TestAS[15, 16]; --[L, S] _ [31, 31] TestAS[31, 32]; --[L, S] _ [63, 63] TestAS[63, 64]; --[L, S] _ [127, 127] TestAS[127, 128]; --[L, S] _ [127, 127] TestAS[127, 0]; --[L, S] _ [127, 127] TestAS[127, 64]; --[L, S] _ [63, 63] TestAS[63, 32]; --[L, S] _ [95, 95] TestAS[95, 16]; --[L, S] _ [111, 111] TestAS[111, 8]; --[L, S] _ [119, 119] TestAS[119, 4]; --[L, S] _ [123, 123] TestAS[123, 2]; --[L, S] _ [125, 125] TestAS[125, 1]; --[L, S] _ [126, 126] drAS[2]; --[L, S] _ [126, 0] drALS[1]; --[L, S] _ [1, 0] restores original value }; <> GenDIS: PROC [] ~ { TestDIS: PROC [originalS: CARDINAL] RETURNS [newS: CARDINAL] ~ { pushL: Label = GenLabel[]; sOK: Label = GenLabel[]; disExit: Label = GenLabel[]; newS _ Basics.BITAND[originalS - 1, 177B]; drDIS[]; drALS[0]; --L _ S drLFC[UseLabel16[pushL]]; drJDB[UseLabel16[disExit]]; SetLabel[pushL]; GetYoungestL[]; drJEBBJ[newS, UseLabel8B[sOK]]; Pause[]; --L was wrong, so S was wrong. SetLabel[sOK]; drRETN[]; SetLabel[disExit]; }; <> SetLabel[enterDISTest]; { curS: CARDINAL _ 0; <<128 iterations restores original value of S.>> FOR I: CARDINAL IN [0..128) DO curS _ TestDIS[curS]; ENDLOOP; drALS[1]; --[L, S] _ [1, 0]. }; }; <> GenASL: PROC [] ~ { TestASL: PROC [originalL, alpha: CARDINAL] ~ { pushL: Label = GenLabel[]; sOK: Label = GenLabel[]; aslExit: Label = GenLabel[]; newS: CARDINAL _ Basics.BITAND[originalL + alpha, 177B]; drASL[alpha]; --S _ newS drALS[0]; --L _ S + 0 drLFC[UseLabel16[pushL]]; --push L (= S) on the IFU stack for checking drJDB[UseLabel16[aslExit]]; SetLabel[pushL]; GetYoungestL[]; drJEBBJ[newS, UseLabel8B[sOK]]; Pause[]; --L was wrong, so S was wrong. SetLabel[sOK]; drRETN[]; SetLabel[aslExit]; }; <> SetLabel[enterASLTest]; <> TestASL[1, 127]; --[L, S] _ [0, 0] <> TestASL[0, 1]; --[L, S] _ [1, 1] TestASL[1, 2]; --[L, S] _ [3, 3] TestASL[3, 4]; --[L, S] _ [7, 7] TestASL[7, 8]; --[L, S] _ [15, 15] TestASL[15, 16]; --[L, S] _ [31, 31] TestASL[31, 32]; --[L, S] _ [63, 63] TestASL[63, 64]; --[L, S] _ [127, 127] TestASL[127, 0]; --[L, S] _ [127, 127] <> TestASL[127, 64]; --[L, S] _ [63, 63] TestASL[63, 32]; --[L, S] _ [95, 95] TestASL[95, 16]; --[L, S] _ [111, 111] TestASL[111, 8]; --[L, S] _ [119, 119] TestASL[119, 4]; --[L, S] _ [123, 123] TestASL[123, 2]; --[L, S] _ [125, 125] TestASL[125, 1]; --[L, S] _ [126, 126] drAS[2]; --[L, S] _ [126, 0] drALS[1]; --[L, S] _ [1, 0] restores original value }; <> drJDB[UseLabel16[enterXopTest]]; GenXop[]; GenAL[]; GenALS[]; GenAS[]; GenDIS[]; GenASL[]; Halt[177777B]; --Terminate here at the end of the program }; END. <<>>