DIRECTORY DragOpsCross USING [EURegs, FieldDescriptor, FourBytes, IFURegs, Inst, JBBformat, LRRBformat, ProcessorRegister, QRformat, RJBformat, RRformat, TwoBytes, Word, ZerosByte], DragOpsCrossUtils USING [ByteToCard, InstToBytes, InstToFormat, WordToBytes, WordToCard, WordToInt], HandCodingUtil USING [NameArray, NameArrayRep, RegNameArray, RegNameArrayRep], IO USING [PutF, PutFR, PutRope, STREAM], Rope USING [ROPE]; HandCodingUtilImpl: CEDAR PROGRAM IMPORTS DragOpsCrossUtils, IO EXPORTS HandCodingUtil = BEGIN OPEN DragOpsCross, HandCodingUtil; ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; ToStream: PUBLIC PROC [stream: STREAM, inst: Inst, rest: Word, pc: Word] = { code: CARDINAL = ORD[inst]; len: CARDINAL _ DragOpsCrossUtils.InstToBytes[inst]; PutArg: PROC [prefix: ROPE, aux,opt: BOOL, reg: [0..15], dst: BOOL _ FALSE] = { IO.PutRope[stream, prefix]; IF NOT opt THEN IO.PutF[stream, IF aux THEN "a%g" ELSE "r%g", [cardinal[reg]]] ELSE SELECT reg FROM 12 => IO.PutRope[stream, "[S]"]; 13 => IO.PutRope[stream, "[S-1]"]; 14 => IO.PutRope[stream, IF dst THEN "[S+1]+" ELSE "[S]-"]; 15 => IO.PutRope[stream, IF dst THEN "[S+1]+" ELSE "[S-1]-"]; ENDCASE => IO.PutF[stream, "c%g", [cardinal[reg]]] }; IO.PutRope[stream, nameArray[inst]]; SELECT len FROM 1 => RETURN; 2 => { alphaZ: CARDINAL = DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][3]]; SELECT inst FROM IN [dLRI0..dLRI15], IN [dSRI0..dSRI15] => { IO.PutF[stream, " %w (%g)", [cardinal[alphaZ]], [cardinal[alphaZ]]]; }; IN [dQOR..dQLSUB] => { form: DragOpsCross.QRformat = LOOPHOLE[DragOpsCross.TwoBytes[ ZerosByte, LOOPHOLE[alphaZ]]]; IO.PutRope[stream, SELECT form.aOp FROM topAtop => " [S], [S]", pushAtop => " [S+1]+, [S]", pushA0 => " [S+1]+, c0", pushA1 => " [S+1]+, c1", ENDCASE => ERROR]; PutArg[", ", form.aux, form.opt, form.reg]; }; dJB => { dest: INT _ alphaZ; IF alphaZ > 127 THEN dest _ dest - 256; dest _ DragOpsCrossUtils.WordToInt[pc] + dest; IO.PutF[stream, " %w (pc: %w)", [cardinal[alphaZ]], [cardinal[LOOPHOLE[dest]]]]; }; dLIP, dSIP => { rName: ROPE = regNameArray[LOOPHOLE[alphaZ]]; IO.PutF[stream, " %g (%g)", [cardinal[alphaZ]], [rope[rName]]]; }; ENDCASE => IO.PutF[stream, " %w (%g)", [cardinal[alphaZ]], [cardinal[alphaZ]]]; }; 3 => { alphaZ: CARDINAL = DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][2]]; betaZ: CARDINAL = DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][3]]; alphaBetaZ: CARDINAL = alphaZ*256 + betaZ; OneByteOffset: PROC [byte: CARDINAL] RETURNS [LONG CARDINAL] = { dest: INT _ byte; IF byte > 127 THEN dest _ dest - 256; dest _ DragOpsCrossUtils.WordToInt[pc] + dest; RETURN [LOOPHOLE[dest, LONG CARDINAL]]; }; SELECT DragOpsCrossUtils.InstToFormat[inst] FROM RRformat => { form: DragOpsCross.RRformat = LOOPHOLE[DragOpsCross.FourBytes[ ZerosByte, LOOPHOLE[alphaZ], LOOPHOLE[betaZ], ZerosByte]]; PutArg[" ", form.aux, form.cOpt, form.c, TRUE]; PutArg[", ", form.aux, form.aOpt, form.a]; PutArg[", ", form.aux, form.bOpt, form.b]; }; RJBformat => { form: DragOpsCross.RJBformat = LOOPHOLE[DragOpsCross.FourBytes[ ZerosByte, LOOPHOLE[alphaZ], LOOPHOLE[betaZ], ZerosByte]]; IO.PutRope[stream, SELECT form.aOp FROM c0 => " c0", c1 => " c1", top => " [S]", popTop => " [S]-", ENDCASE => ERROR]; PutArg[", ", form.aux, form.opt, form.reg]; IO.PutF[stream, ", %w (pc: %w)", [cardinal[form.dist]], [cardinal[OneByteOffset[form.dist]]]]; }; LRRBformat => { form: DragOpsCross.LRRBformat = LOOPHOLE[DragOpsCross.FourBytes[ ZerosByte, LOOPHOLE[alphaZ], LOOPHOLE[betaZ], ZerosByte]]; IO.PutF[stream, " r%g, r%g, %w (%g)", [cardinal[form.reg1]], [cardinal[form.reg2]], [cardinal[form.disp]], [cardinal[form.disp]]]; }; JBBformat => { form: DragOpsCross.JBBformat = LOOPHOLE[DragOpsCross.FourBytes[ ZerosByte, LOOPHOLE[alphaZ], LOOPHOLE[betaZ], ZerosByte]]; IO.PutF[stream, " %w (%g), %w (pc: %w)", [cardinal[form.lit]], [cardinal[form.lit]], [cardinal[form.dist]], [cardinal[OneByteOffset[form.dist]]]]; }; ENDCASE => SELECT inst FROM dJDB, dLFC => { destPC: LONG CARDINAL = LOOPHOLE[ LOOPHOLE[alphaBetaZ, INTEGER] + DragOpsCrossUtils.WordToInt[pc], LONG CARDINAL]; IO.PutF[stream, " %w (pc: %w)", [cardinal[alphaBetaZ]], [cardinal[destPC]]]; }; dSHL, dSHR, dSHD, dFSDB => { fd: DragOpsCross.FieldDescriptor = LOOPHOLE[alphaBetaZ]; IO.PutF[stream, " %w (", [cardinal[alphaBetaZ]]]; IF fd.reserved # 0 THEN IO.PutF[stream, "reserved: %g, ", [cardinal[fd.reserved]]]; IF fd.insert THEN IO.PutRope[stream, "insert: TRUE, "]; IO.PutF[stream, "mask: %g, shift: %g)", [cardinal[fd.mask]], [cardinal[fd.shift]]]; }; ENDCASE => IO.PutF[stream, " %w (%g)", [cardinal[alphaBetaZ]], [cardinal[alphaBetaZ]]]; }; 5 => { card: LONG CARDINAL = DragOpsCrossUtils.WordToCard[rest]; int: INT = DragOpsCrossUtils.WordToInt[rest]; IO.PutF[stream, " %w (%g)", [cardinal[card]], [integer[int]]]; }; ENDCASE => ERROR; }; GetInstArray: PUBLIC PROC RETURNS [array: NameArray] = { RETURN [nameArray]; }; GetRegArray: PUBLIC PROC RETURNS [array: RegNameArray] = { RETURN [regNameArray]; }; InitArray: PROC RETURNS [array: NameArray] = { array _ NEW[NameArrayRep]; FOR inst: Inst IN Inst DO instName: ROPE _ SELECT inst FROM dDFC => "DFC", dLIQB => "LIQB", dJ5 => "J5", dJQB => "JQB", dOR => "OR", dAND => "AND", dRX => "RX", dBC => "BC", dADD => "ADD", dSUB => "SUB", dLADD => "LADD", dLSUB => "LSUB", dDUP => "DUP", dDIS => "DIS", dEXDIS => "EXDIS", dSFC => "SFC", dSFCI => "SFCI", dRETN => "RETN", dKFC => "KFC", dJ1 => "J1", dJS => "JS", dLC0 => "LC0", dLC1 => "LC1", dLC2 => "LC2", dLC3 => "LC3", dLC4 => "LC4", dLC5 => "LC5", dLC6 => "LC6", dLC7 => "LC7", dLR0 => "LR0", dLR1 => "LR1", dLR2 => "LR2", dLR3 => "LR3", dLR4 => "LR4", dLR5 => "LR5", dLR6 => "LR6", dLR7 => "LR7", dLR8 => "LR8", dLR9 => "LR9", dLR10 => "LR10", dLR11 => "LR11", dLR12 => "LR12", dLR13 => "LR13", dLR14 => "LR14", dLR15 => "LR15", dSR0 => "SR0", dSR1 => "SR1", dSR2 => "SR2", dSR3 => "SR3", dSR4 => "SR4", dSR5 => "SR5", dSR6 => "SR6", dSR7 => "SR7", dSR8 => "SR8", dSR9 => "SR9", dSR10 => "SR10", dSR11 => "SR11", dSR12 => "SR12", dSR13 => "SR13", dSR14 => "SR14", dSR15 => "SR15", dQOR => "QOR", dQAND => "QAND", dQRX => "QRX", dQBC => "QBC", dQADD => "QADD", dQSUB => "QSUB", dQLADD => "QLADD", dQLSUB => "QLSUB", dALS => "ALS", dAL => "AL", dASL => "ASL", dAS => "AS", dCST => "CST", dRET => "RET", dRETK => "RETK", dLIP => "LIP", dSIP => "SIP", dLIB => "LIB", dADDB => "ADDB", dSUBB => "SUBB", dJ2 => "J2", dJB => "JB", dRB => "RB", dWB => "WB", dRSB => "RSB", dWSB => "WSB", dPSB => "PSB", dLRI0 => "LRI0", dLRI1 => "LRI1", dLRI2 => "LRI2", dLRI3 => "LRI3", dLRI4 => "LRI4", dLRI5 => "LRI5", dLRI6 => "LRI6", dLRI7 => "LRI7", dLRI8 => "LRI8", dLRI9 => "LRI9", dLRI10 => "LRI10", dLRI11 => "LRI11", dLRI12 => "LRI12", dLRI13 => "LRI13", dLRI14 => "LRI14", dLRI15 => "LRI15", dSRI0 => "SRI0", dSRI1 => "SRI1", dSRI2 => "SRI2", dSRI3 => "SRI3", dSRI4 => "SRI4", dSRI5 => "SRI5", dSRI6 => "SRI6", dSRI7 => "SRI7", dSRI8 => "SRI8", dSRI9 => "SRI9", dSRI10 => "SRI10", dSRI11 => "SRI11", dSRI12 => "SRI12", dSRI13 => "SRI13", dSRI14 => "SRI14", dSRI15 => "SRI15", dROR => "ROR", dRAND => "RAND", dRRX => "RRX", dRBC => "RBC", dRADD => "RADD", dRSUB => "RSUB", dRLADD => "RLADD", dRLSUB => "RLSUB", dRXOR => "RXOR", dRFU => "RFU", dRVADD => "RVADD", dRVSUB => "RVSUB", dRUADD => "RUADD", dRUSUB => "RUSUB", dLGF => "LGF", dLFC => "LFC", dLIDB => "LIDB", dADDDB => "ADDDB", dSUBDB => "SUBDB", dJ3 => "J3", dJDB => "JDB", dRAI => "RAI", dWAI => "WAI", dRRI => "RRI", dWRI => "WRI", dIOS => "IOS", dIOL => "IOL", dION => "ION", dRJEB => "RJEB", dRJEBJ => "RJEBJ", dRJGB => "RJGB", dRJGBJ => "RJGBJ", dRJGEB => "RJGEB", dRJGEBJ => "RJGEBJ", dRJLB => "RJLB", dRJLBJ => "RJLBJ", dRJLEB => "RJLEB", dRJLEBJ => "RJLEBJ", dRJNEB => "RJNEB", dRJNEBJ => "RJNEBJ", dJEBB => "JEBB", dJEBBJ => "JEBBJ", dJNEBB => "JNEBB", dJNEBBJ => "JNEBBJ", dSHL => "SHL", dSHR => "SHR", dSHD => "SHD", dFSDB => "FSDB", ENDCASE => NIL; IF instName = NIL THEN { instName _ IO.PutFR["X%b", [cardinal[LOOPHOLE[inst, CARDINAL]]]]; }; array[inst] _ instName; ENDLOOP; }; InitRegArray: PROC RETURNS [array: RegNameArray] = { array _ NEW[RegNameArrayRep]; FOR reg: ProcessorRegister IN ProcessorRegister DO name: ROPE _ NIL; regc: CARDINAL = LOOPHOLE[reg]; SELECT reg FROM IN [euStack..euJunk) => name _ IO.PutFR["s%g", [cardinal[regc]]]; euJunk => name _ "euJunk"; euToKBus => name _ "euToKBus"; euMAR => name _ "euMAR"; euField => name _ "euField"; IN [euConstant..euAux) => { base: ProcessorRegister = euConstant; name _ IO.PutFR["c%g", [cardinal[regc - LOOPHOLE[base, CARDINAL]]]]}; IN [euAux..euBogus) => { base: ProcessorRegister = euAux; name _ IO.PutFR["a%g", [cardinal[regc - LOOPHOLE[base, CARDINAL]]]]}; ifuYoungestL => name _ "ifuYoungestL"; ifuYoungestPC => name _ "ifuYoungestPC"; ifuEldestL => name _ "ifuEldestL"; ifuEldestPC => name _ "ifuEldestPC"; ifuStatus => name _ "ifuStatus"; ifuSLimit => name _ "ifuSLimit"; ifuL => name _ "ifuL"; ifuS => name _ "ifuS"; ifuPC => name _ "ifuPC"; IN DragOpsCross.EURegs => name _ IO.PutFR["eu#%g", [cardinal[regc]]]; IN DragOpsCross.IFURegs => name _ IO.PutFR["ifu#%g", [cardinal[regc]]]; ENDCASE => ERROR; array[reg] _ name; ENDLOOP; }; nameArray: NameArray = InitArray[]; regNameArray: RegNameArray = InitRegArray[]; END. ΒHandCodingUtilImpl.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) January 23, 1986 12:02:09 pm PST McCreight, November 7, 1985 11:35:35 am PST Κ \˜codešœ™Kšœ Οmœ7™BK™4K™+—K˜šΟk ˜ Kšœ žœ™˜«KšœžœM˜dKšœžœ:˜NKšžœžœžœ˜(Kšœžœžœ˜K˜—šœžœž˜!Kšžœž˜Kšžœ˜Kšœž œž˜*K˜Kšžœžœžœ˜Kšžœžœžœžœ˜K˜—šΟnœž œ žœ'˜LKšœžœžœ˜Kšœžœ'˜4š Ÿœžœ žœ žœžœžœ˜OKšžœ˜šžœžœ˜ Kš žœžœžœžœžœ˜Cšžœžœž˜Kšœžœ˜ Kšœžœ˜"Kš œžœžœžœ žœ ˜;Kš œžœžœžœ žœ ˜=Kšžœžœ(˜5———Kšžœ"˜$šžœž˜Kšœžœ˜ ˜šœžœ˜KšœE˜E—šžœž˜šžœžœ˜+KšžœB˜DK˜—šžœ˜šœžœ˜=Kšœ žœ ˜—šžœžœ ž˜'Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšžœžœ˜—Kšœ+˜+K˜—˜Kšœžœ ˜Kšžœžœ˜'Kšœ.˜.šžœ˜Kšœžœ ˜0—K˜—˜Kšœžœžœ ˜-Kšžœ=˜?K˜—šžœ˜ KšžœB˜D——K˜—˜šœžœ˜KšœE˜E—šœžœ˜KšœE˜E—Kšœ žœ˜*š Ÿ œžœžœžœžœžœ˜@Kšœžœ˜Kšžœ žœ˜%Kšœ.˜.Kšžœžœžœžœ˜'K˜—šžœ&ž˜0šœ ˜ šœžœ˜>Kšœ žœ žœ˜:—Kšœ)žœ˜/Kšœ*˜*Kšœ*˜*K˜—šœ˜šœžœ˜?Kšœ žœ žœ˜:—šžœžœ ž˜'Kšœ<žœžœ˜N—Kšœ+˜+šžœ˜!Kšœ=˜=—K˜—šœ˜šœ žœ˜@Kšœ žœ žœ˜:—šžœ#˜%Kšœ-˜-Kšœ.˜.—K˜—šœ˜šœžœ˜?Kšœ žœ žœ˜:—šžœ'˜)Kšœ+˜+Kšœ=˜=—K˜—šžœžœž˜šœ˜šœžœžœžœ˜!Kšžœ žœ$˜@Kšžœžœ˜—KšžœK˜MK˜—šœ˜Kšœ#žœ ˜8Kšžœ0˜2Kšžœžœžœ9˜SKšžœ žœžœ#˜7KšžœQ˜SK˜—šžœ˜ KšžœJ˜L———K˜—˜Kšœžœžœ&˜9Kšœžœ%˜-Kšžœ<˜>K˜—Kšžœžœ˜—K˜K˜—šŸ œž œžœ˜8Kšžœ ˜K˜K˜—šŸ œž œžœ˜:Kšžœ˜K˜K˜—šŸ œžœžœ˜.Kšœžœ˜šžœ žœž˜šœ ž˜šžœž˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜K˜K˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšžœžœ˜——šžœ žœžœ˜Kšœ žœžœžœ˜AK˜—Kšœ˜Kšžœ˜—K˜K˜—šŸ œžœžœ˜4Kšœžœ˜šžœžœž˜2Kšœžœžœ˜Kšœžœžœ˜šžœž˜šžœ˜Kšœžœ ˜)—Kšœ˜Kšœ˜Kšœ˜Kšœ˜šžœ˜Kšœ%˜%Kšœžœžœžœ˜E—šžœ˜Kšœ ˜ Kšœžœžœžœ˜E—Kšœ&˜&Kšœ(˜(Kšœ"˜"Kšœ$˜$Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšžœžœ"˜EKšžœ žœ#˜GKšžœžœ˜—Kšœ˜Kšžœ˜—K˜K˜—šœ#˜#K˜—šœ,˜,K˜—Kšžœ˜K˜—…—$>1\