DIRECTORY DragOpsCross, DragOpsCrossUtils, PrincOps; DragOpsCrossHelp: CEDAR PROGRAM IMPORTS DragOpsCrossUtils = BEGIN OPEN DragOpsCross; InstToBytes: PROC [inst: Inst] RETURNS [NAT] = { SELECT ORD[inst] FROM < 40B => RETURN [1]; < 100B => RETURN [5]; ENDCASE => RETURN [ORD[inst] / 100B]; }; InstToFormat: PROC [inst: Inst] RETURNS [DragOpsCrossUtils.InstFormat] = { SELECT ORD[inst] / 8 FROM 2 => RETURN [OIformat]; 3 => IF inst IN [dLC8..dLC11] THEN 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]; }; BytePCToWordAddress: PROC [pc: ByteAddress] RETURNS [addr: Word, index: [0..bytesPerWord)] = { 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] = { card: CARD = WordToCard[addr]; RETURN [[CardToWord[card+card+card+card+index]]]; }; FieldDescriptorToCard: PROC [fd: FieldDescriptor] RETURNS [CARDINAL] = TRUSTED { RETURN [LOOPHOLE[fd]]; }; CardToFieldDescriptor: PROC [card: CARDINAL] RETURNS [FieldDescriptor] = TRUSTED { RETURN [LOOPHOLE[card]]; }; BytesToWord: PROC [fb: FourBytes] RETURNS [Word] = TRUSTED { RETURN[LOOPHOLE[fb, Word]]; }; BytesToHalf: PROC [tb: TwoBytes] RETURNS [Half] = TRUSTED { RETURN[LOOPHOLE[tb, Half]]; }; WordToBytes: PROC [w: Word] RETURNS [FourBytes] = TRUSTED { RETURN[LOOPHOLE[w, FourBytes]]; }; HalfToBytes: PROC [h: Half] RETURNS [TwoBytes] = TRUSTED { RETURN[LOOPHOLE[h, TwoBytes]]; }; HalvesToWord: PROC [th: TwoHalves] RETURNS [Word] = TRUSTED { RETURN[LOOPHOLE[th, Word]]; }; WordToHalves: PROC [w: Word] RETURNS [TwoHalves] = TRUSTED { RETURN[LOOPHOLE[w, TwoHalves]]; }; HighHalf: PROC [w: Word] RETURNS [Half] = TRUSTED { RETURN[LOOPHOLE[w, TwoHalves][0]]; }; LowHalf: PROC [w: Word] RETURNS [Half] = TRUSTED { RETURN[LOOPHOLE[w, TwoHalves][1]]; }; LeftHalf: PROC [w: Word] RETURNS [Half] = TRUSTED { RETURN[LOOPHOLE[w, TwoHalves][0]]; }; RightHalf: PROC [w: Word] RETURNS [Half] = TRUSTED { RETURN[LOOPHOLE[w, TwoHalves][1]]; }; SwapHalves: PROC [w: Word] RETURNS [Word] = TRUSTED { RETURN [DragOpsCrossUtils.SwapHalves[w]]; }; CARD: TYPE = LONG CARDINAL; WordToInt: PROC [w: Word] RETURNS [INT] = TRUSTED { RETURN [DragOpsCrossUtils.WordToInt[w]]; }; IntToWord: PROC [int: INT] RETURNS [Word] = TRUSTED { RETURN [DragOpsCrossUtils.IntToWord[int]]; }; WordToCard: PROC [w: Word] RETURNS [CARD] = TRUSTED { RETURN [DragOpsCrossUtils.WordToCard[w]]; }; HalfToCard: PROC [h: Half] RETURNS [CARDINAL] = TRUSTED { RETURN [LOOPHOLE[h, CARDINAL]]; }; ByteToCard: PROC [b: Byte] RETURNS [[0..255]] = TRUSTED { RETURN [LOOPHOLE[b]]; }; CardToWord: PROC [card: CARD] RETURNS [Word] = TRUSTED { RETURN [DragOpsCrossUtils.CardToWord[card]]; }; CardToHalf: PROC [card: CARDINAL] RETURNS [Half] = TRUSTED { RETURN [LOOPHOLE[card, Half]]; }; CardToByte: PROC [card: [0..255]] RETURNS [Byte] = TRUSTED { RETURN [LOOPHOLE[card, Byte]]; }; DragAnd: PROC [a,b: Word] RETURNS [Word] = { RETURN [HalvesToWord[[ HalfAnd[LeftHalf[a], LeftHalf[b]], HalfAnd[RightHalf[a], RightHalf[b]] ]]]; }; DragOr: PROC [a,b: Word] RETURNS [Word] = { RETURN [HalvesToWord[[ HalfOr[LeftHalf[a], LeftHalf[b]], HalfOr[RightHalf[a], RightHalf[b]] ]]]; }; DragXor: PROC [a,b: Word] RETURNS [Word] = { RETURN [HalvesToWord[[ HalfXor[LeftHalf[a], LeftHalf[b]], HalfXor[RightHalf[a], RightHalf[b]] ]]]; }; DragNot: PROC [w: Word] RETURNS [Word] = { RETURN [HalvesToWord[[ HalfNot[LeftHalf[w]], HalfNot[RightHalf[w]] ]]]; }; VanillaAdd: PROC [a,b: Word] RETURNS [Word] = { RETURN [IntToWord[WordToInt[a]+WordToInt[b]]]; }; VanillaSub: PROC [a,b: Word] RETURNS [Word] = { RETURN [IntToWord[WordToInt[a]-WordToInt[b]]]; }; AddDelta: PROC [w: Word, delta: INT] RETURNS [Word] = { RETURN [IntToWord[WordToInt[w]+delta]]; }; HalfNot: PROC [h: Half] RETURNS [nh: Half] = TRUSTED { RETURN [DragOpsCrossUtils.HalfNot[h]]; }; HalfAnd: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED { RETURN [DragOpsCrossUtils.HalfAnd[h0,h1]]; }; HalfOr: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED { RETURN [DragOpsCrossUtils.HalfOr[h0,h1]]; }; HalfXor: PROC [h0,h1: Half] RETURNS [h: Half] = TRUSTED { RETURN [DragOpsCrossUtils.HalfXor[h0,h1]]; }; HalfShift: PROC [h: Half, dist: INTEGER] RETURNS [Half] = TRUSTED { RETURN [DragOpsCrossUtils.HalfShift[h, dist]]; }; DoubleWordShiftLeft: PROC [w0,w1: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED { 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 { 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 { 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] = { RETURN [LOOPHOLE[inst, CARDINAL]*TrapWidthBytes+XopBase*bytesPerWord]; }; TrapIndexToBytePC: PROC [tx: TrapIndex] RETURNS [LONG CARDINAL] = { RETURN [LOOPHOLE[tx, CARDINAL]*TrapWidthBytes+TrapBase*bytesPerWord]; }; FieldUnit: PROC [Left,Right: Word, fd: FieldDescriptor] RETURNS [out: Word] = { shifter: Word = DoubleWordShiftLeft[Left, Right, fd.shift]; mask: Word _ SingleWordShiftRight[OnesWord, 32-fd.mask]; IF fd.insert THEN { mask _ DragAnd[mask, SingleWordShiftLeft[OnesWord, fd.shift]]; out _ DragAnd[mask, shifter]; out _ DragOr[out, DragAnd[DragNot[mask], Right]]; } ELSE out _ DragAnd[mask, shifter]; }; END. DragOpsCrossHelp.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) September 11, 1986 1:39:56 pm PDT These definitions provide procedures for manipulating Dragon values using PrincOps machines. It is an image of DragOpsCrossUtils, except that we do not use INLINES. 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. 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. dist >= 32 This procedure shifts one Dragon word right by dist bits and returns the shifted word. Utilities for calculating PCs from Xops and trap indexes Field unit definition The shifter output has the input double word shifted left by fd.shift bits The default mask has fd.mask 1s right-justified in the word clear rightmost fd.shift bits of the mask 1 bits in the mask select the shifter output 0 bits in the mask select bits from Right to OR in to the result 1 bits in the mask select the shifter output Κ °˜codešœ™Kšœ Οmœ7™BK™5—K˜Kšœ₯™₯K™šΟk ˜ Kšœ ˜ Kšœ˜Kšœ ˜ —K˜šœžœž˜Kšžœ˜Kšœžœžœ˜K™—™K™šΟn œžœžœžœ˜0šžœžœž˜Kšœ žœ˜Kšœ žœ˜Kšžœžœžœ˜%—K˜K˜—šŸ œžœžœ#˜Jšžœžœ ž˜Kšœžœ ˜Kš œžœžœžœžœ ˜5Kšœžœ ˜Kšœžœ ˜#Kšœžœ ˜(Kšœžœ ˜Kšœžœ ˜#Kšœžœ ˜)Kšœ žœ ˜Kšœžœ ˜Kš œžœžœžœžœžœžœ ˜PKšœ žœ ˜Kšœžœ ˜Kšœžœ ˜Kšžœ˜—Kšžœ ˜K˜K˜——šœ™K˜šŸœžœžœ+˜^KšœE˜Ešœ˜Kšœ˜Kšœ?˜?K˜—K˜—šŸœžœ,žœ˜bKšœžœ˜Kšžœ+˜1K˜K˜—š Ÿœžœžœžœžœ˜PKšžœžœ˜K˜—š Ÿœžœžœžœžœ˜RKšžœžœ˜K˜K˜——šœ™K˜šŸ œžœžœ žœ˜˜>Kšœ*™*—šœ˜Kšœ,™,—šœ1˜1Kšœ@™@—K˜—šžœ˜šœ˜Kšœ,™,———K˜K˜—K˜—Kšžœ˜K˜K˜—…—6,ϊ