DIRECTORY DragOpsCross USING [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 [IntToWord], --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 GenLisp: CEDAR PROGRAM IMPORTS DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport = BEGIN OPEN DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport; Word: TYPE = DragOpsCross.Word; aux0: AuxRegSpec = [aux[0]]; aux1: AuxRegSpec = [aux[1]]; aux2: AuxRegSpec = [aux[2]]; aux3: AuxRegSpec = [aux[3]]; aux4: AuxRegSpec = [aux[4]]; aux5: AuxRegSpec = [aux[5]]; aux6: AuxRegSpec = [aux[6]]; aux14: AuxRegSpec = [aux[14]]; aux15: AuxRegSpec = [aux[15]]; const4: ConstSpec = [const[4]]; const5: ConstSpec = [const[5]]; const6: ConstSpec = [const[6]]; const7: ConstSpec = [const[7]]; const8: ConstSpec = [const[8]]; const9: ConstSpec = [const[9]]; const10: ConstSpec = [const[10]]; const11: ConstSpec = [const[11]]; LMaxNum: INT = 3777777777B; LMinNum: INT = -4000000000B; 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]]; }; area: Area = GetCurrentArea[]; savePC: LONG CARDINAL; IllegalLispNum: Label = GenLabel[]; LNaNUnexpected: Label = GenLabel[]; enterRLADDTest: Label = GenLabel[]; enterRLSUBTest: Label = GenLabel[]; GenRLADD: PROC = { RLADDTest: PROC [a, b: INT] ~ { ax: Word _ IntToWord[a]; bx: Word _ IntToWord[b]; apb: INT _ a + b; IF a > LMaxNum OR a < LMinNum OR b > LMaxNum OR b < LMinNum OR apb > LMaxNum OR apb < LMinNum THEN { rlaOK: Label = GenLabel[]; rlaBad: Label = GenLabel[]; drROR[const5, const7, const7]; --Indicate NaN trap expected drLIQB[bx]; drLIQB[ax]; drRLADD[topDst, reg1, reg0]; Pause[]; drQLADD[pushAtop, reg0]; Pause[]; Pause[]; drLADD[]; Pause[]; Pause[]; Pause[]; drLIQB[ax]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[rlaOK]]; SetLabel[rlaBad]; Pause[]; SetLabel[rlaOK]; drLIQB[bx]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlaBad]]; } ELSE { rlaOK: Label = GenLabel[]; rlaBad: Label = GenLabel[]; apbx: Word _ IntToWord[apb]; drROR[const5, const0, const0]; --Indicate no NaN trap expected drLIQB[bx]; drLIQB[ax]; drQLADD[pushAtop, reg0]; drRLADD[pushDst, reg1, reg0]; drLIQB[apbx]; drRJEBJ[popSrc, belowSrc, UseLabel8B[rlaOK]]; SetLabel[rlaBad]; Pause[]; SetLabel[rlaOK]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlaBad]]; drLADD[]; drLIQB[apbx]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlaBad]]; drRUADD[pushDst, const0, const0]; drJNEBB[0, UseLabel8B[rlaBad]]; }; }; SetLabel[enterRLADDTest]; RLADDTest[ 1B, LMaxNum]; --Just barely overflows RLADDTest[ LMaxNum, 1B]; RLADDTest[ 0B, LMinNum]; --Just barely doesn't underflow RLADDTest[ LMinNum, 0B]; RLADDTest[ 0B, LMaxNum]; --Just barely doesn't overflow RLADDTest[ LMaxNum, 0B]; RLADDTest[ -1B, LMinNum]; --Just barely underflows RLADDTest[ LMinNum, -1B]; RLADDTest[0, 0]; --Other misc. test values drRUADD[const4, const7, const7]; RLADDTest[ 1252525252B, -1515151515B]; drRUADD[const4, const7, const7]; RLADDTest[-1000000000B, -1000000000B]; drRUADD[const4, const7, const7]; RLADDTest[ LMinNum, LMaxNum]; RLADDTest[ LMaxNum, LMinNum]; RLADDTest[ 777777777B, 1000000000B]; RLADDTest[ 1000000000B, 777777777B]; }; GenRLSUB: PROC = { RLSUBTest: PROC [a, b: INT] ~ { ax: Word _ IntToWord[a]; bx: Word _ IntToWord[b]; amb: INT _ a - b; IF a > LMaxNum OR a < LMinNum OR b > LMaxNum OR b < LMinNum OR amb > LMaxNum OR amb < LMinNum THEN { rlsOK: Label = GenLabel[]; rlsBad: Label = GenLabel[]; drROR[const5, const7, const7]; --Indicate NaN trap expected drLIQB[bx]; drLIQB[ax]; drQLSUB[pushAtop, reg0]; Pause[]; Pause[]; drRLSUB[topDst, reg1, reg0]; Pause[]; drEXDIS[]; drLIQB[bx]; --Reverse the args drLSUB[]; Pause[]; Pause[]; Pause[]; drLIQB[bx]; drRJEBJ[popSrc, belowSrcPop, UseLabel8B[rlsOK]]; SetLabel[rlsBad]; Pause[]; SetLabel[rlsOK]; drLIQB[ax]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlsBad]]; } ELSE { rlsOK: Label = GenLabel[]; rlsBad: Label = GenLabel[]; ambx: Word _ IntToWord[amb]; drROR[const5, const0, const0]; --Indicate no NaN trap expected drLIQB[bx]; drLIQB[ax]; drQLSUB[pushAtop, reg0]; drRLSUB[pushDst, reg1, reg0]; drLIQB[ambx]; drRJEBJ[popSrc, belowSrc, UseLabel8B[rlsOK]]; SetLabel[rlsBad]; Pause[]; SetLabel[rlsOK]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlsBad]]; drEXDIS[]; drLIQB[bx]; --Reverse the args drLSUB[]; drLIQB[ambx]; drRJNEB[popSrc, belowSrcPop, UseLabel8B[rlsBad]]; drRUADD[pushDst, const0, const0]; drJNEBB[0, UseLabel8B[rlsBad]]; }; }; SetLabel[enterRLSUBTest]; RLSUBTest[ 1B, -LMaxNum]; --Just barely overflows RLSUBTest[ LMaxNum, -1B]; RLSUBTest[ -1B, -1-LMinNum]; --Just barely doesn't underflow RLSUBTest[ LMinNum, 0B]; RLSUBTest[ 0B, -LMaxNum]; --Just barely doesn't overflow RLSUBTest[ -LMaxNum, 0B]; RLSUBTest[ -2B, -1-LMinNum]; --Just barely underflows RLSUBTest[ LMinNum, 1B]; RLSUBTest[0, 0]; --Other misc. test values drRUADD[const4, const7, const7]; RLSUBTest[ 1252525252B, 1515151515B]; drRUADD[const4, const7, const7]; RLSUBTest[-1000000000B, -1000000000B]; drRUADD[const4, const7, const7]; RLSUBTest[ LMinNum, -LMaxNum]; RLSUBTest[ LMaxNum, -1-LMinNum]; RLSUBTest[ 777777777B, 1000000000B]; RLSUBTest[ 1000000000B, 777777777B]; }; savePC _ GetOutputPC[area]; FillTrap[ALUCondIL, IllegalLispNum]; SetOutputPC[savePC]; drLIQB[IntToWord[-1]]; drROR[const7, topSrc, popSrc]; --Put -1 in const7. drLIB[4]; drROR[const6, topSrc, popSrc]; --Put 4 in const6 for NaN trap GenRLADD[]; GenRLSUB[]; Halt[177777B]; --Terminate here at the end of the program WordAlign[area]; SetLabel[IllegalLispNum]; drALS[1]; --ALS[1 - nargs] drLC5[]; drRJNEB[popSrc, const7, UseLabel8B[LNaNUnexpected]]; GetYoungestPC[]; drRVADD[topDst, topSrc, const6]; SetYoungestPC[]; --Advance return PC by 4 drRET[377B]; --RET[nResults - 1] SetLabel[LNaNUnexpected]; Pause[]; }; END. šGenLisp.mesa Copyright c 1985, 1986, 1987 by Xerox Corporation. All rights reserved. Edward Fiala February 7, 1986 5:13:45 pm PST Curry, September 11, 1986 11:34:35 pm PDT Curry, September 11, 1986 2:15:07 pm PDT RETK => RET, const1 => const7, const3 => const8, LC3 => LC8 Fiala November 5, 1986 3:58:37 pm PST Fix ALS at entry to IllegalLispNum trap. Fiala March 23, 1987 4:56:04 pm PST Eliminate Reset, Halt, and Pause stuff to run with GenDebugger. Fiala April 9, 1987 2:15:25 pm PST Change LC8 to LC5 for chip debugging (const8-11 don't work on chip). Load with "quad -cx GenDebugger GenLisp". This diagnostic tests the arithmetic opcodes RLADD, RLSUB, LADD, LSUB, QLADD, and QLSUB. When correctly executed it terminates with a HALT[177777b] at PC = 4042647B on instruction 582 cycle 1112. In this diagnostic, the auxiliary registers are called aux0, aux1, ..., aux15; the locals are called reg0, reg1, ..., reg15; and the constants are called const0, const1, ..., const15. The Xop trap locations assigned to each opcode are at at opcode*TrapWidthBytes + xopBase*bytesPerWord = 4,000,000B + 20B * opcode, and the trap location assigned to each trap are at TrapIndex*TrapWidthBytes + TrapBase*bytesPerWord = 4,002,000B + 20B * TrapIndex. The TrapIndex definitions are in DragOpsCross. Lisp arithmetic: The Carry is not used as an input, and is always set to 0. If either operand or the result is not in the range [LMinNum..LMaxNum], a Lisp NaN (Not a Number) trap is taken. This procedure generates tests RLADD, QLADD, and LADD. A Lisp NaN trap will abort the RLADD, and the trap subroutine will skip over the Pause[] below. Verify that the registers weren't disturbed. No Lisp NaN trap should occur; check the result. Verify that Carry = 0 after a Lisp arithmetic operation. Set Carry = 1 to verify it has no effect and to test that Carry = 0 after a Lisp arithmetic operation. This procedure tests RLSUB, QLSUB, and LSUB. A Lisp NaN trap will abort the RLADD, and the trap subroutine will skip over the Pause[] below. Verify that the registers weren't disturbed. No Lisp NaN trap should occur; check the result. Verify that Carry = 0 after a Lisp arithmetic operation. Set Carry = 1 to verify it has no effect and to test that Carry = 0 after a Lisp arithmetic operation. Begin at PC = userBasePC = 1010000B * 4, L = 1, S = 0 as established in GenDebugger. const0 is in a ROM, so it requires no initialization; const7 is initialized to -1 here; the other constants require no initialization for this diagnostic. Arrive here with the YoungestPC pointing at an opcode which experienced a Lisp NaN trap; this trap is always enabled, so no special enabling or disabling action is necessary. Unless const5 = -1 do a Pause[] (Lisp NaN not expected); otherwise, increment the PC by 4 and return. Advance the PC by 4 without smashing or using Carry (so use RVADD instead of ADDB). An enableable trap would push IFU status and exit with RET[nResults - 1]. Κ[˜codešœ ™ Kšœ Οmœ=™HK™,K™)Kšœd™dK™NK™cK™gK™Kšœο™οK™—šΟk ˜ Kšœ žœEΟcε ˜Ό KšœžœŸΥ˜ϊKšœ Ÿ˜,KšœŸΪ˜ξKšœŸο˜ƒK˜—šœ žœž˜KšžœD˜KKšœžœžœE˜QK˜K–20 sp tabStopsšœžœ˜K–20 sp tabStops˜K–40 sp tabStopsšœ·™·K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStopsšœ˜K–40 sp tabStops˜K–40 sp tabStops˜K–40 sp tabStops˜K–40 sp tabStops˜K–40 sp tabStops˜K–40 sp tabStops˜!K–40 sp tabStops˜!K–40 sp tabStops˜K–40 sp tabStopsšœ žœ˜K–40 sp tabStopsšœ žœ˜K–20 sp tabStops˜šΟnœžœ˜ K˜KšœΆ™Άš œžœžœ˜/Kšœc˜cKšœ˜K˜K˜—š œžœ.˜Kšœ˜K˜Kšœ˜K˜;K˜K˜K˜1K˜IKšœ8™8K˜!K˜K˜—K˜—K˜K˜Kšœ#Ÿ˜:K˜!Kšœ"Ÿ˜AK˜!Kšœ#Ÿ˜AK˜!Kšœ"Ÿ˜:K˜!K˜KšœŸ˜+Kšœf™fKšœ ˜ K˜&Kšœ ˜ K˜&Kšœ ˜ K˜K˜Kšœ&˜&K˜&K˜—K˜Kšœ,™,š œžœ˜š  œžœžœ˜J˜J˜Kšœžœ ˜šžœ žœ žœ žœ žœžœžœ˜dKšœ_™_K˜K˜KšœŸ˜;Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜KšœŸ˜)K˜ K˜Kšœ,™,K˜hK˜=K˜—šžœ˜Kšœ0™0K˜K˜K˜KšœŸ˜>Kšœ˜Kšœ˜Kšœ˜K˜;K˜K˜K˜1KšœŸ˜)K˜ K˜?Kšœ8™8K˜!K˜K˜—K˜—K˜K˜Kšœ$Ÿ˜;K˜!K˜Kšœ&Ÿ˜EK˜!K˜Kšœ$Ÿ˜BK˜"K˜Kšœ$Ÿ˜