DIRECTORY DragOpsCross USING [FieldDescriptor, OnesWord, Word, ZerosWord], DragOpsCrossUtils USING [DoubleWordShiftLeft, DragAnd, DragNot, DragOr, SingleWordShiftLeft, SingleWordShiftRight]; FieldUnit: CEDAR PROGRAM IMPORTS DragOpsCrossUtils = BEGIN OPEN DragOpsCrossUtils; FieldDescriptor: TYPE = DragOpsCross.FieldDescriptor; Word: TYPE = DragOpsCross.Word; ZerosWord: Word = DragOpsCross.ZerosWord; OnesWord: Word = DragOpsCross.OnesWord; Operate: 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]; IF fd.insert THEN out _ DragOr[out, DragAnd[DragNot[mask], Right]]; }; END. FieldDescriptor: TYPE = MACHINE DEPENDENT RECORD [ reserved: [0..15] _ 0, insert: BOOL, mask: [0..31], shift: [0..32] ]; Word: TYPE = PACKED ARRAY [0..bitsPerWord) OF BOOL; ZerosWord: Word = LOOPHOLE[LONG[0]]; OnesWord: Word = LOOPHOLE[LONG[-1]]; DoubleWordShiftLeft: PROC [w0,w1: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { }; SingleWordShiftLeft: PROC [word: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { }; SingleWordShiftRight: PROC [word: Word, dist: SixBitIndex] RETURNS [Word] = TRUSTED INLINE { }; DragAnd: PROC [a,b: Word] RETURNS [Word] = INLINE { }; DragOr: PROC [a,b: Word] RETURNS [Word] = INLINE { }; ΔFieldUnit.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) January 23, 1986 12:05:14 pm PST 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 fd.insert => clear rightmost fd.shift bits of the mask 1 bits in the mask select the shifter output fd.backR => 0 bits in the mask select bits from Right to OR in to the result Definitions used from DragOpsCross reserved bits, not currently used, but must be 0s governs choice of background and low bits of mask 31-mask gives # of leading 0s in the mask gives # of bits to left-shift the double word Here is some pseudo-Mesa that describes the output of the FieldUnit. Assume that boolean operations work on type Word, and ** denotes exponentiation, and arithmetic is infinite precision. FieldUnit: PROC [Left, Right: Word, fd: FieldDescriptor] RETURNS [output: Word] = { background: Word = IF insert THEN Right ELSE ZerosWord; masker: Word = 2**(mask+1)-1 XOR IF insert THEN 2**MIN[shift, mask] - 1 ELSE ZerosWord; shifter: Word = (DoubleWord[Left, Right] * 2**shift) AND OnesWord; FOR i: FiveBitIndex IN FiveBitIndex DO output[i] _ IF masker[i] THEN shifter[i] ELSE background[i]; ENDLOOP; }; Definitions used from DragOpsCrossUtils This procedure shifts two Dragon words left by dist bits and returns the leftmost word. << code omitted >> This procedure shifts one Dragon word left by dist bits and returns the shifted word. << code omitted >> This procedure shifts one Dragon word right by dist bits and returns the shifted word. << code omitted >> This procedure is a 32-bit AND << code omitted >> This procedure is a 32-bit OR << code omitted >> ΚL˜codešœ™Kšœ Οmœ7™BK™4—K˜šΟk ˜ Kšœ žœ.˜@Kšœžœ\˜sK˜—šœ ž ˜Kšžœ˜Kšœž œž˜K˜Kšœžœ ˜5šœžœ˜Kšœ)˜)Kšœ'˜'——K˜šΟnœžœ)žœ˜Mšœ;˜;KšœJ™J—šœ8˜8Kšœ;™;—šžœ ž˜šœ>˜>Kšœ7™7——šœ˜Kšœ,™,—šžœ žœ2˜CKšœL™L—K˜K˜—Kšžœ˜K˜šœ"™"K˜š œžœžœž œžœ˜2–24 sp tabStopsšœ˜K–24 sp tabStopsšœ1™1—–24 sp tabStopsšœžœ˜ K–24 sp tabStopsšœ1™1—–24 sp tabStopsšœ˜K–24 sp tabStops™)—–24 sp tabStopsšœ˜K–24 sp tabStopsšœ-™-—K˜K˜KšœΌ™ΌK™šŸ œžœ*žœ™S–24 sp tabStopsšœ™K–24 sp tabStopsšžœžœžœ ™$—–24 sp tabStops™–24 sp tabStopsšœž™K–24 sp tabStopsšžœžœžœžœ ™6——–24 sp tabStops™K–24 sp tabStopsšœ%žœ ™2—šžœžœž™&Kšœ žœ žœ žœ™