DIRECTORY TargetArchitecture, RuntimeError; TargetArchitectureImpl: CEDAR PROGRAM IMPORTS RuntimeError EXPORTS TargetArchitecture ~ { IsNullAddress: PUBLIC PROCEDURE [address: TargetArchitecture.Address] RETURNS [BOOLEAN] ~ { isNullAddress: BOOLEAN ~ (address = TargetArchitecture.nullAddress); RETURN [isNullAddress]; }; AddressFromDisplacement: PUBLIC PROCEDURE [ address: TargetArchitecture.Address, displacement: TargetArchitecture.Displacement] RETURNS [TargetArchitecture.Address] ~ { ordAddress: CARD32 ~ LOOPHOLE[address]; ordTarget: CARD32 ¬ 0; displaced: TargetArchitecture.Address ¬ TargetArchitecture.nullAddress; IF displacement >= 0 THEN { absDisplacement: CARD32 ~ displacement; IF LAST[CARD32] - ordAddress < absDisplacement THEN { ERROR RuntimeError.BoundsFault; }; ordTarget ¬ ordAddress + absDisplacement; } ELSE { absDisplacement: CARD32 ~ -displacement; IF ordAddress < absDisplacement THEN { ERROR RuntimeError.BoundsFault; }; ordTarget ¬ ordAddress - absDisplacement; }; displaced ¬ LOOPHOLE[ordTarget]; RETURN [displaced]; }; DisplacementFromAddresses: PUBLIC PROCEDURE [ here: TargetArchitecture.Address, there: TargetArchitecture.Address] RETURNS [TargetArchitecture.Displacement] ~ { ordHere: CARD32 ~ LOOPHOLE[here]; ordThere: CARD32 ~ LOOPHOLE[there]; displacement: TargetArchitecture.Displacement ~ IF ordThere >= ordHere THEN ordThere - ordHere ELSE -(ordHere - ordThere); RETURN [displacement]; }; NextInstruction: PUBLIC PROCEDURE [pc: TargetArchitecture.Address] RETURNS [TargetArchitecture.Address] ~ { nextAddress: TargetArchitecture.Address ~ AddressFromDisplacement[ address: pc, displacement: +BYTES[TargetArchitecture.Instruction]]; RETURN [nextAddress]; }; PrevInstruction: PUBLIC PROCEDURE [pc: TargetArchitecture.Address] RETURNS [TargetArchitecture.Address] ~ { prevAddress: TargetArchitecture.Address ~ AddressFromDisplacement[ address: pc, displacement: -BYTES[TargetArchitecture.Instruction]]; RETURN [prevAddress]; }; InstructionFromContents: PUBLIC PROCEDURE [contents: TargetArchitecture.Contents] RETURNS [TargetArchitecture.Instruction] ~ { instruction: TargetArchitecture.Instruction ~ LOOPHOLE[contents]; RETURN [instruction]; }; ContentsFromInstruction: PUBLIC PROCEDURE [instruction: TargetArchitecture.Instruction] RETURNS [TargetArchitecture.Contents] ~ { contents: TargetArchitecture.Contents ~ LOOPHOLE[instruction]; RETURN [contents]; }; }. , TargetArchitectureImpl.mesa Copyright Σ 1989, 1991 by Xerox Corporation. All rights reserved. Peter B. Kessler, September 1, 1989 4:55:02 pm PDT Check first for possible overflow. Check first for possible underflow. See section 2.5.1.1 of the Mesa manual for rules on unsigned arithmetic. Κ!–(cedarcode) style•NewlineDelimiter ™code™Kšœ Πerœ7™BK™2K™šΟk ˜ K˜K˜ —K˜—unitšΠlnœžœž˜%Kšžœ ˜Kšžœ˜K˜K˜š Οn œžœž œ(žœžœ˜\Kšœžœ.˜DKšžœ˜K˜K˜—š œžœž œXžœ!˜©Kšœ žœžœ ˜'Kšœ žœ˜KšœG˜GK˜šžœ˜šžœ˜Kšœžœ˜'K˜šžœžœžœ!žœ˜5J™"Kšžœ˜K˜—Kšœ)˜)K˜—šžœ˜Kšœžœ˜(K˜šžœžœ˜&J™#Kšžœ˜K˜—Kšœ)˜)K˜——Kšœ žœ ˜ Kšžœ ˜Kšœ˜K˜—š œžœž œIžœ&˜‘K™HKšœ žœžœ˜!Kšœ žœžœ˜#šœ0˜0šžœ˜Kšžœ˜Kšžœ˜——K˜Kšžœ˜Kšœ˜K˜—š œžœž œ#žœ!˜lšœB˜BKšœžœ"˜C—K˜Kšžœ˜Kšœ˜K˜—š œžœž œ#žœ!˜lšœB˜BKšœžœ"˜C—K˜Kšžœ˜Kšœ˜K˜—š œžœž œ*žœ%˜Kšœ.žœ ˜AK˜Kšžœ˜Kšœ˜K˜—š œžœž œ0žœ"˜‚Kšœ(žœ˜>K˜Kšžœ ˜Kšœ˜K˜—K˜—K™—…— | Ι