DIRECTORY DragOpsCross, PrincOps; DragOpsCrossUtils: CEDAR DEFINITIONS = BEGIN OPEN DragOpsCross; InstToBytes: PROC [inst: Inst] RETURNS [NAT] = INLINE { SELECT ORD[inst] FROM < 40B => RETURN [1]; < 100B => RETURN [5]; ENDCASE => RETURN [ORD[inst] / 100B]; }; InstToFormat: PROC [inst: Inst] RETURNS [InstFormat] = INLINE { SELECT ORD[inst] / 8 FROM 2 => RETURN [OIformat]; 6 => RETURN [OQBformat]; 10B, 11B, 12B => RETURN [OIformat]; 14B, 15B, 16B, 17B => RETURN [LRformat]; 20B => RETURN [QRformat]; 21B, 22B, 23B => RETURN [OBformat]; 24B, 25B, 26B, 27B => RETURN [LRBformat]; 30B, 31B => RETURN [RRformat]; 32B => RETURN [ODBformat]; 33B => IF inst IN [dRAI..dWRI] THEN RETURN [LRRBformat] ELSE RETURN [ODBformat]; 34B, 35B => RETURN [RJBformat]; 36B => RETURN [JBBformat]; 37B => RETURN [ODBformat]; ENDCASE => RETURN [illegal]; }; InstFormat: TYPE = {OIformat, OQBformat, LRformat, QRformat, OBformat, LRBformat, RRformat, ODBformat, LRRBformat, RJBformat, JBBformat, illegal}; BytePCToWordAddress: PROC [pc: ByteAddress] RETURNS [addr: Word, index: [0..bytesPerWord)] = INLINE { index _ HalfToCard[HalfAnd[LowHalf[pc], CardToHalf[bytesPerWord-1]]]; addr _ HalvesToWord[[ HalfShift[HighHalf[pc], -2], HalfOr[HalfShift[LowHalf[pc], -2], HalfShift[HighHalf[pc], 14]] ]]; }; WordAddressToBytePC: PROC [addr: Word, index: [0..bytesPerWord) _ 0] RETURNS [pc: ByteAddress] = INLINE { card: CARD = WordToCard[addr]; RETURN [[CardToWord[card+card+card+card+index]]]; }; IOOperandToCard: PROC [ioop: IOOperand] RETURNS [CARDINAL] = TRUSTED INLINE { RETURN [LOOPHOLE[ioop]]; }; CardToIOOperand: PROC [card: CARDINAL] RETURNS [IOOperand] = TRUSTED INLINE { RETURN [LOOPHOLE[card]]; }; FieldDescriptorToCard: PROC [fd: FieldDescriptor] RETURNS [CARDINAL] = TRUSTED INLINE { RETURN [LOOPHOLE[fd]]; }; CardToFieldDescriptor: PROC [card: CARDINAL] RETURNS [FieldDescriptor] = TRUSTED INLINE { RETURN [LOOPHOLE[card]]; }; StatusToWord: PROC [status: IFUStatusRec] RETURNS [Word] = TRUSTED INLINE { RETURN [LOOPHOLE[status]]; }; WordToStatus: PROC [word: Word] RETURNS [IFUStatusRec] = TRUSTED INLINE { RETURN [LOOPHOLE[word]]; }; BytesToWord: PROC [fb: FourBytes] RETURNS [Word] = TRUSTED INLINE { RETURN[LOOPHOLE[fb, Word]]; }; BytesToHalf: PROC [tb: TwoBytes] RETURNS [Half] = TRUSTED INLINE { RETURN[LOOPHOLE[tb, Half]]; }; WordToBytes: PROC [w: Word] RETURNS [FourBytes] = TRUSTED INLINE { RETURN[LOOPHOLE[w, FourBytes]]; }; HalfToBytes: PROC [h: Half] RETURNS [TwoBytes] = TRUSTED INLINE { RETURN[LOOPHOLE[h, TwoBytes]]; }; HalvesToWord: PROC [th: TwoHalves] RETURNS [Word] = TRUSTED INLINE { RETURN[LOOPHOLE[th, Word]]; }; WordToHalves: PROC [w: Word] RETURNS [TwoHalves] = TRUSTED INLINE { RETURN[LOOPHOLE[w, TwoHalves]]; }; HighHalf: PROC [w: Word] RETURNS [Half] = TRUSTED INLINE { RETURN[LOOPHOLE[w, TwoHalves][0]]; }; LowHalf: PROC [w: Word] RETURNS [Half] = TRUSTED INLINE { RETURN[LOOPHOLE[w, TwoHalves][1]]; }; LeftHalf: PROC [w: Word] RETURNS [Half] = TRUSTED INLINE { RETURN[LOOPHOLE[w, TwoHalves][0]]; }; RightHalf: PROC [w: Word] RETURNS [Half] = TRUSTED INLINE { RETURN[LOOPHOLE[w, TwoHalves][1]]; }; SwapHalves: PROC [w: Word] RETURNS [Word] = TRUSTED MACHINE CODE { PrincOps.zEXCH; }; CARD: TYPE = LONG CARDINAL; WordToInt: PROC [w: Word] RETURNS [INT] = TRUSTED MACHINE CODE { PrincOps.zEXCH; }; IntToWord: PROC [int: INT] RETURNS [Word] = TRUSTED MACHINE CODE { PrincOps.zEXCH; }; WordToCard: PROC [w: Word] RETURNS [CARD] = TRUSTED MACHINE CODE { PrincOps.zEXCH; }; HalfToCard: PROC [h: Half] RETURNS [CARDINAL] = TRUSTED INLINE { RETURN [LOOPHOLE[h, CARDINAL]]; }; ByteToCard: PROC [b: Byte] RETURNS [[0..255]] = TRUSTED INLINE { RETURN [LOOPHOLE[b]]; }; CardToWord: PROC [card: CARD] RETURNS [Word] = TRUSTED MACHINE CODE { PrincOps.zEXCH; }; CardToHalf: PROC [card: CARDINAL] RETURNS [Half] = TRUSTED INLINE { RETURN [LOOPHOLE[card, Half]]; }; CardToByte: PROC [card: [0..255]] RETURNS [Byte] = TRUSTED INLINE { RETURN [LOOPHOLE[card, Byte]]; }; DragAnd: PROC [a,b: Word] RETURNS [Word] = INLINE { RETURN [HalvesToWord[[ HalfAnd[LeftHalf[a], LeftHalf[b]], HalfAnd[RightHalf[a], RightHalf[b]] ]]]; }; DragOr: PROC [a,b: Word] RETURNS [Word] = INLINE { RETURN [HalvesToWord[[ HalfOr[LeftHalf[a], LeftHalf[b]], HalfOr[RightHalf[a], RightHalf[b]] ]]]; }; DragXor: PROC [a,b: Word] RETURNS [Word] = INLINE { RETURN [HalvesToWord[[ HalfXor[LeftHalf[a], LeftHalf[b]], HalfXor[RightHalf[a], RightHalf[b]] ]]]; }; DragNot: PROC [w: Word] RETURNS [Word] = INLINE { RETURN [HalvesToWord[[ HalfNot[LeftHalf[w]], HalfNot[RightHalf[w]] ]]]; }; VanillaAdd: PROC [a,b: Word] RETURNS [Word] = INLINE { RETURN [IntToWord[WordToInt[a]+WordToInt[b]]]; }; VanillaSub: PROC [a,b: Word] RETURNS [Word] = INLINE { RETURN [IntToWord[WordToInt[a]-WordToInt[b]]]; }; AddDelta: PROC [delta: INT, w: Word] RETURNS [Word] = TRUSTED MACHINE CODE { PrincOps.zEXCH; PrincOps.zDADD; PrincOps.zEXCH; }; HalfNot: PROC [h: Half] RETURNS [nh: Half] = TRUSTED MACHINE CODE { PrincOps.zLIN1; PrincOps.zXOR }; HalfAnd: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED MACHINE CODE { PrincOps.zAND; }; HalfOr: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED MACHINE CODE { PrincOps.zOR; }; HalfXor: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED MACHINE CODE { PrincOps.zXOR; }; HalfShift: PROC [h: Half, dist: INTEGER] RETURNS [Half] = TRUSTED MACHINE CODE { PrincOps.zSHIFT; }; DoubleWordShiftLeft: PROC [w0,w1: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { SELECT dist FROM < 16 => RETURN [HalvesToWord[[ HalfOr[HalfShift[LeftHalf[w0], dist], HalfShift[RightHalf[w0], dist-16]], HalfOr[HalfShift[RightHalf[w0], dist], HalfShift[LeftHalf[w1], dist-16]]]]]; ENDCASE => { RETURN [HalvesToWord[[ HalfOr[HalfShift[RightHalf[w0], dist-16], HalfShift[LeftHalf[w1], dist-32]], HalfOr[HalfShift[LeftHalf[w1], dist-16], HalfShift[RightHalf[w1], dist-32]]]]]; }; }; SingleWordShiftLeft: PROC [word: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { SELECT dist FROM < 16 => RETURN [HalvesToWord[[ HalfOr[HalfShift[LeftHalf[word], dist], HalfShift[RightHalf[word], dist-16]], HalfShift[RightHalf[word], dist]]]]; ENDCASE => { RETURN [HalvesToWord[[HalfShift[RightHalf[word], dist-16], ZerosHalf]]]; }; }; SingleWordShiftRight: PROC [word: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { SELECT dist FROM < 16 => RETURN [HalvesToWord[[ HalfShift[LeftHalf[word], -dist], HalfOr[HalfShift[LeftHalf[word], 16-dist], HalfShift[RightHalf[word], -dist]] ]]]; ENDCASE => { RETURN [HalvesToWord[[ZerosHalf, HalfShift[LeftHalf[word], 16-dist]]]]; }; }; XopToBytePC: PROC [inst: Inst] RETURNS [LONG CARDINAL] = INLINE { RETURN [LOOPHOLE[inst, CARDINAL]*TrapWidthBytes+XopBase*bytesPerWord]; }; TrapIndexToBytePC: PROC [tx: TrapIndex] RETURNS [LONG CARDINAL] = INLINE { RETURN [LOOPHOLE[tx, CARDINAL]*TrapWidthBytes+TrapBase*bytesPerWord]; }; END. ’DragOpsCrossUtils.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) October 11, 1985 4:58:44 pm PDT These definitions provide INLINE and MACHINE CODE procedures for manipulating Dragon values using PrincOps machines. Instruction size A few type conversions Dragon unit conversions DragOps/PrincOps conversions Note: the Dragon convention is to have the low order half word (16 bits) in the right half of the word (32 bits), while the Dorado convention is to have the low order word (16 bits) in the left half of the doubleword (32 bits). Word basic operations This procedure is a 32-bit AND This procedure is a 32-bit OR This procedure is a 32-bit XOR This procedure is a 32-bit XOR This procedure is just a convenience to add without carry or overflow. This procedure is just a convenience to subtract without carry or overflow. This procedure is a convenience to use when adding a small delta to a word. It is faster than using VanillaAdd directly. Halfword basic operations This procedure is just a convenience to invert a half word. This procedure is just a convenience to AND two half words. This procedure is just a convenience to OR two half words. This procedure is just a convenience to OR two half words. This procedure is just a half word shift left (if dist >= 0) or right (if dist <= 0). Shift utility inlines This procedure shifts two Dragon words left by dist bits and returns the leftmost word. This procedure shifts one Dragon word left by dist bits and returns the shifted word. This procedure shifts one Dragon word right by dist bits and returns the shifted word. Utilities for calculating PCs from Xops and trap indexes Κ 3˜codešœ™Kšœ Οmœ7™BK™3—K˜Kšœt™tK™šΟk ˜ Kšœ ˜ Kšœ ˜ —K˜š œžœž œžœžœ˜?K™—K™™š Οn œžœžœžœžœ˜7šžœžœž˜Kšœ žœ˜Kšœ žœ˜Kšžœžœžœ˜%—K˜K˜—šŸ œžœžœžœ˜?šžœžœ ž˜Kšœžœ ˜Kšœžœ ˜Kšœžœ ˜#Kšœžœ ˜(Kšœžœ ˜Kšœžœ ˜#Kšœžœ ˜)Kšœ žœ ˜Kšœžœ ˜Kš œžœžœžœžœžœžœ ˜PKšœ žœ ˜Kšœžœ ˜Kšœžœ ˜Kšžœžœ ˜—K˜Kšœ žœ‚˜’K˜——šœ™K˜šŸœžœžœ*žœ˜eKšœE˜Ešœ˜Kšœ˜Kšœ?˜?K˜—K˜—šŸœžœ,žœžœ˜iKšœžœ˜Kšžœ+˜1K˜K˜—š Ÿœžœžœžœžœžœ˜MKšžœžœ˜K˜—š Ÿœžœžœžœžœžœ˜MKšžœžœ˜K˜K˜—š Ÿœžœžœžœžœžœ˜WKšžœžœ˜K˜—š Ÿœžœžœžœžœžœ˜YKšžœžœ˜K˜K˜—š Ÿ œžœžœ žœžœ˜LKšžœžœ ˜K˜—š Ÿ œžœžœžœžœ˜JKšžœžœ˜K˜K˜——šœ™K˜š Ÿ œžœžœ žœžœ˜CKšžœžœ ˜K˜K˜—š Ÿ œžœžœ žœžœ˜BKšžœžœ ˜K˜K˜—š Ÿ œžœ žœžœžœ˜BKšžœžœ˜K˜K˜—š Ÿ œžœ žœžœžœ˜AKšžœžœ˜K˜K˜—š Ÿ œžœžœ žœžœ˜DKšžœžœ ˜K˜K˜—š Ÿ œžœ žœžœžœ˜CKšžœžœ˜K˜K˜—š Ÿœžœ žœ žœžœ˜:Kšžœžœ˜"K˜K˜—š Ÿœžœ žœ žœžœ˜9Kšžœžœ˜"K˜K˜—š Ÿœžœ žœ žœžœ˜:Kšžœžœ˜"K˜K˜—š Ÿ œžœ žœ žœžœ˜;Kšžœžœ˜"K˜K˜—š Ÿ œžœ žœ žœžœžœ˜BK˜K˜—K˜—šœ™K™γK˜šžœžœžœžœ˜K˜—šŸ œžœ žœžœžœžœžœ˜@K˜K˜K˜—šŸ œžœžœžœ žœžœžœ˜BK˜K˜K˜—šŸ œžœ žœžœžœžœžœ˜BK˜K˜K˜—š Ÿ œžœ žœžœžœžœ˜@Kšžœžœžœ˜K˜K˜—š Ÿ œžœ žœžœžœ˜@Kšžœžœ˜K˜K˜—šŸ œžœžœžœ žœžœžœ˜EK˜K˜K˜—š Ÿ œžœžœžœ žœžœ˜CKšžœžœ˜K˜K˜—š Ÿ œžœžœ žœžœ˜CKšžœžœ˜K˜K˜——šœ™K™šŸœžœ žœ žœ˜3Kšœ™šžœ˜Kšœ"˜"Kšœ#˜#Kšœ˜—K˜K˜—šŸœžœ žœ žœ˜2Kšœ™šžœ˜Kšœ!˜!Kšœ"˜"Kšœ˜—K˜K˜—šŸœžœ žœ žœ˜3Kšœ™šžœ˜Kšœ"˜"Kšœ#˜#Kšœ˜—K˜K˜—šŸœžœ žœ žœ˜1Kšœ™šžœ˜Kšœ˜Kšœ˜Kšœ˜—K˜K˜—šŸ œžœ žœ žœ˜6KšœF™FKšžœ(˜.K˜K˜—šŸ œžœ žœ žœ˜6KšœK™KKšžœ(˜.K˜K˜—š Ÿœžœ žœ žœ žœžœ˜LKšœy™yK˜K˜K˜K˜K˜——šœ™K™š Ÿœžœ žœžœžœ˜CKšœ;™;K˜K˜ K˜K˜—š Ÿœžœžœ žœžœ˜FKšœ;™;Kšœ˜K˜K˜—š Ÿœžœžœ žœžœ˜EKšœ:™:Kšœ ˜ K˜K˜—š Ÿœžœžœ žœžœ˜FKšœ:™:Kšœ˜K˜K˜—š Ÿ œžœžœžœ žœžœ˜PKšœU™UKšœ˜K˜K˜——™K˜š Ÿœžœ"žœ žœžœ˜\KšœW™Wšžœž˜˜šžœ˜KšœI˜IKšœL˜L——šžœ˜ šžœ˜KšœL˜LKšœO˜O—K˜——K˜K˜—š Ÿœžœ!žœ žœžœ˜[KšœU™Ušžœž˜˜šžœ˜KšœM˜MKšœ$˜$——šžœ˜ KšžœB˜HK˜——K˜K˜—š Ÿœžœ!žœ žœžœ˜\KšœV™Všžœž˜˜šžœ˜Kšœ!˜!KšœM˜MKšœ˜——šžœ˜ KšžœA˜GK˜——K˜K˜——šœ8™8K˜š Ÿ œžœžœžœžœžœ˜AKšžœžœžœ'˜FK˜K˜—š Ÿœžœžœžœžœžœ˜JKšžœžœžœ(˜EK˜—K˜—Kšžœ˜K˜K˜—…—θ,½