DIRECTORY TargetArchitecture, RS6000Architecture, RuntimeError; RS6000ArchitectureImpl: CEDAR PROGRAM IMPORTS TargetArchitecture, RS6000Architecture, RuntimeError EXPORTS RS6000Architecture ~ { Ai: PUBLIC PROCEDURE [ rt: RS6000Architecture.Register, ra: RS6000Architecture.Register, si: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rsi: RS6000Architecture.Format2rsi ~ [ op: RS6000Architecture.Op.ai, rt: rt, ra: ra, si: si]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rsi]; RETURN [instruction]; }; B: PUBLIC PROCEDURE [ pc: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address, abs, link: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { displacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: pc, there: to]; instruction: RS6000Architecture.RS6000Instruction ¬ RS6000Architecture.nullRS6000Instruction; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF displacement NOT IN [RS6000Architecture.firstOffset26 .. RS6000Architecture.lastOffset26] THEN { ERROR RS6000Architecture.CantReach; }; { disp24: RS6000Architecture.Disp24 ~ displacement / BYTES[RS6000Architecture.RS6000Instruction]; msb: BOOLEAN ~ disp24 IN [RS6000Architecture.firstDisp24..0]; disp23: RS6000Architecture.Disp23 ~ IF msb THEN disp24 - RS6000Architecture.firstDisp24 ELSE disp24; formatBranch: RS6000Architecture.FormatBranch ~ [ op: RS6000Architecture.Op.b, limsb: msb, li: disp23, aa: abs, lk: link ]; instruction ¬ LOOPHOLE[formatBranch]; }; RETURN [instruction]; }; Brl: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatBOnCondCount: RS6000Architecture.FormatBOnCondCount ~ [ op: RS6000Architecture.Op.group19, bo: [TRUE, FALSE, TRUE, FALSE, FALSE], bi: 0, subOp: RS6000Architecture.SubOpFor19.bcr, lk: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatBOnCondCount]; RETURN [instruction]; }; Bctr: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatBOnCondCount: RS6000Architecture.FormatBOnCondCount ~ [ op: RS6000Architecture.Op.group19, bo: [TRUE, FALSE, TRUE, FALSE, FALSE], bi: 0, subOp: RS6000Architecture.SubOpFor19.bcc, lk: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatBOnCondCount]; RETURN [instruction]; }; Cror: PUBLIC PROCEDURE [bt: RS6000Architecture.CCBitPosition, ba: RS6000Architecture.CCBitPosition, bb: RS6000Architecture.CCBitPosition, lk: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatCondRegAnd: RS6000Architecture.FormatCondRegAnd ~ [ op: RS6000Architecture.Op.group19, bt: bt, ba: ba, bb: bb, subOp: RS6000Architecture.SubOpFor19.cror, lk: lk]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatCondRegAnd]; RETURN [instruction]; }; L: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.l, rt: rt, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Lil: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, low: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoadi: RS6000Architecture.FormatLoadi ~ [op: RS6000Architecture.Op.cal, rt: rt, zero: 0, si: low]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoadi]; RETURN [instruction]; }; Liu: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, upper: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoadui: RS6000Architecture.FormatLoadui ~ [op: RS6000Architecture.Op.cau, rt: rt, zero: 0, ui: upper]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoadui]; RETURN [instruction]; }; Lm: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.lm, rt: rt, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Mfspr: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, spr: RS6000Architecture.SpecialRegister, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatMoveSPR: RS6000Architecture.FormatMoveSPR ~ [ op: RS6000Architecture.Op.group31, rt: rt, spr: spr, subOp: RS6000Architecture.SubOpFor31withoutOE.mfspr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveSPR]; RETURN [instruction]; }; Mtspr: PUBLIC PROCEDURE [rt: RS6000Architecture.Register, spr: RS6000Architecture.SpecialRegister, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveSPR: RS6000Architecture.FormatMoveSPR ~ [ op: RS6000Architecture.Op.group31, rt: rt, spr: spr, subOp: RS6000Architecture.SubOpFor31withoutOE.mtspr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveSPR]; RETURN [instruction]; }; Mfcr: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveFromCR: RS6000Architecture.FormatMoveFromCR ~ [ op: RS6000Architecture.Op.group31, rt: rs, subOp: RS6000Architecture.SubOpFor31withoutOE.mfcr, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveFromCR]; RETURN [instruction]; }; Mtcrf: PUBLIC PROCEDURE [fxm: RS6000Architecture.FXM, rs: RS6000Architecture.Register, rc: BOOLEAN] RETURNS [RS6000Architecture.RS6000Instruction]~ { formatMoveToCRField: RS6000Architecture.FormatMoveToCRField ~ [ op: RS6000Architecture.Op.group31, rs: rs, fxm: fxm, subOp: RS6000Architecture.SubOpFor31withoutOE.mtcrf, rc: rc]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMoveToCRField]; RETURN [instruction]; }; Noop: PUBLIC PROCEDURE [] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatMask: RS6000Architecture.FormatMask ~ [ op: RS6000Architecture.Op.group31, rs: RS6000Architecture.Register.gpr0, ra: RS6000Architecture.Register.gpr0, rb: RS6000Architecture.Register.gpr0, subOp: RS6000Architecture.SubOpFor31withoutOE.or, rc: FALSE ]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatMask]; RETURN [instruction]; }; OrLConst: PUBLIC PROCEDURE [ ra: RS6000Architecture.Register, rs: RS6000Architecture.Register, ui: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rui: RS6000Architecture.Format2rui ~ [ op: RS6000Architecture.Op.oril, rt: rs, ra: ra, ui: ui]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rui]; RETURN [instruction]; }; OrUConst: PUBLIC PROCEDURE [ ra: RS6000Architecture.Register, rs: RS6000Architecture.Register, ui: RS6000Architecture.UI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rui: RS6000Architecture.Format2rui ~ [ op: RS6000Architecture.Op.oril, rt: rs, ra: ra, ui: ui]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rui]; RETURN [instruction]; }; St: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.st, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Stm: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.stm, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Stu: PUBLIC PROCEDURE [rs: RS6000Architecture.Register, offset: RS6000Architecture.Disp16, ra: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatLoad: RS6000Architecture.FormatLoad ~ [ op: RS6000Architecture.Op.stu, rt: rs, ra: ra, d: offset]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[formatLoad]; RETURN [instruction]; }; Si: PUBLIC PROCEDURE [ rt: RS6000Architecture.Register, ra: RS6000Architecture.Register, si: RS6000Architecture.SI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2rsi: RS6000Architecture.Format2rsi ~ [ op: RS6000Architecture.Op.ai, rt: rt, ra: ra, si: -si]; instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[format2rsi]; RETURN [instruction]; }; Relocate: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF from.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.dozi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.cmpli => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.cmpi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.ai => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.aiDot => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.cal => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.cau => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.bc => {relocated ¬ DoRelocateForBranch16bits[instruction, from, to];}; RS6000Architecture.Op.b => {relocated ¬ DoRelocateForBranch26bits[instruction, from, to];}; RS6000Architecture.Op.group19 => {relocated ¬ RelocateGroup19[instruction, from, to];}; RS6000Architecture.Op.rlimi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.rlinm => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.rlmi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.rlnm => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.oril => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.oriu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.xoril => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.xoriu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.andil => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.andiu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.group31 => {relocated ¬ RelocateGroup31[instruction, from, to];}; RS6000Architecture.Op.l => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lbz => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lbzu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.st => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stb => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lhz => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lhzu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lha => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lhau => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.sth => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lm => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stm => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lfs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lfsu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lfd => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.lfdu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stfs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stfsu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stfd => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.stfdu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.Op.group63 => {relocated ¬ RelocateGroup63[instruction, from, to];}; ENDCASE => {ERROR;}; RETURN [relocated]; }; RelocateGroup19: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; SELECT instruction.GetSubOp19[] FROM RS6000Architecture.SubOpFor19.mcrf => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.bcr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crnor => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crandc => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crxor => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crnand => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crand => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.creqv => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.crorc => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.cror => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor19.bcc => {relocated ¬ NoRelocate[instruction];}; ENDCASE => {ERROR;}; RETURN [relocated]; }; RelocateGroup31: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; SELECT instruction.GetSubOp31withoutOE[] FROM RS6000Architecture.SubOpFor31withoutOE.cmp => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.t => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfcr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sl => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.cntlz => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.and => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.maskg => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.cmpl => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.andc => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfmsr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbzx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbzux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.nor => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mtcrf => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.slq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sle => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sliq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sllq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sleq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.slliq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lscbx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhzx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhzux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.xor => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mfspr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhax => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhaux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.orc => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.or => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mtspr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.nand => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.mcrxr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lsx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lbrx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfsx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.rrib => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.maskir => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfsux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lsi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfdx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lfdux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stsx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stbrx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfsx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sre => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfsux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sriq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfdx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srlq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sreq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.stfdux => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srliq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.lhbrx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sra => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srai => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sthbrx => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sraq => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.srea => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withoutOE.sraiq => {relocated ¬ NoRelocate[instruction];}; ENDCASE => { SELECT instruction.GetSubOp31withOE[] FROM RS6000Architecture.SubOpFor31withOE.sf => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.a => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.mul => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfe => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.ae => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfze => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.aze => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.sfme => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.me => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.muls => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.doz => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.cax => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.eqv => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.adiv => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.abs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.divs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.SubOpFor31withOE.nabs => {relocated ¬ NoRelocate[instruction];}; ENDCASE => {ERROR;}; }; RETURN [relocated]; }; RelocateGroup63: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; SELECT instruction.GetSubOp3r63[] FROM RS6000Architecture.FSubOp3r63.fd => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fa => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fm => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fms => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fma => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fnms => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp3r63.fnma => {relocated ¬ NoRelocate[instruction];}; ENDCASE => { SELECT instruction.GetSubOp2r63[] FROM RS6000Architecture.FSubOp2r63.fcmpu => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.frsp => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fcmpo => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsb1 => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fneg => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mcrfs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsb0 => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fmr => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsfi => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fnabs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.fabs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mffs => {relocated ¬ NoRelocate[instruction];}; RS6000Architecture.FSubOp2r63.mtfsf => {relocated ¬ NoRelocate[instruction];}; ENDCASE => {ERROR;}; }; RETURN [relocated]; }; NoRelocate: PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.RS6000Instruction] ~ { RETURN [instruction]; }; DoRelocateForBranch16bits: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; instructionDisp14: RS6000Architecture.Disp14 ~ instruction.GetDisp14[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp14 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: to, there: targetAddress]; relocationDisp14: RS6000Architecture.Disp14 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp14 NOT IN [RS6000Architecture.firstDisp14..RS6000Architecture.lastDisp14] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated ¬ instruction.SetDisp14[disp14: relocationDisp14]; RETURN [relocated]; }; DoRelocateForBranch26bits: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction ¬ instruction; instructionDisp24: RS6000Architecture.Disp24 ~ instruction.GetDisp24[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp24 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses[here: to, there: targetAddress]; relocationDisp24: RS6000Architecture.Disp24 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp24 NOT IN [RS6000Architecture.firstDisp24..RS6000Architecture.lastDisp24] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated ¬ instruction.SetDisp24[disp24: relocationDisp24]; RETURN [instruction]; }; noopInstruction: RS6000Architecture.RS6000Instruction ~ RS6000Architecture.Noop[]; IsNoopInstruction: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { isNoopInstruction: BOOLEAN ~ instruction = noopInstruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [isNoopInstruction]; }; GetOp: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op] ~ { formatGeneric: RS6000Architecture.Format3rArith ~ LOOPHOLE[instruction]; op: RS6000Architecture.Op ~ formatGeneric.op; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op]; }; GetSubOp19: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor19] ~ { formatGeneric: RS6000Architecture.FormatCondRegAnd ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor19 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp31withoutOE: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor31withoutOE] ~ { formatGeneric: RS6000Architecture.FormatCmp ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor31withoutOE ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp31withOE: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.SubOpFor31withOE] ~ { formatGeneric: RS6000Architecture.Format2rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.SubOpFor31withOE ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp3r63: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.FSubOp3r63] ~ { formatGeneric: RS6000Architecture.FormatFl3rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.FSubOp3r63 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetSubOp2r63: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.FSubOp2r63] ~ { formatGeneric: RS6000Architecture.FormatFl2rArith ~ LOOPHOLE[instruction]; subOp: RS6000Architecture.FSubOp2r63 ~ formatGeneric.subOp; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [subOp]; }; GetDisp14: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp14] ~ { formatBOnCond: RS6000Architecture.FormatBOnCond ~ LOOPHOLE[instruction]; disp14: RS6000Architecture.Disp14 ~ IF formatBOnCond.bdmsb THEN formatBOnCond.bd + RS6000Architecture.firstDisp14 ELSE formatBOnCond.bd; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp14]; }; GetDisp24: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp24] ~ { formatBranch: RS6000Architecture.FormatBranch ~ LOOPHOLE[instruction]; disp24: RS6000Architecture.Disp24 ~ IF formatBranch.limsb THEN formatBranch.li + RS6000Architecture.firstDisp24 ELSE formatBranch.li; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp24]; }; High: PUBLIC PROCEDURE [value: CARD32] RETURNS [RS6000Architecture.UI] ~ { hi: RS6000Architecture.UI ~ value / (LAST[CARD16] + 1); RETURN [hi]; }; Low: PUBLIC PROCEDURE [value: CARD32] RETURNS [RS6000Architecture.UI] ~ { lo: RS6000Architecture.SI ~ value MOD (LAST[CARD16] + 1); RETURN [lo]; }; SetOp: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op: RS6000Architecture.Op] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatGeneric: RS6000Architecture.Format3rArith ¬ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; formatGeneric.op ¬ op; RETURN [LOOPHOLE[formatGeneric]]; }; SetDisp14: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp14: RS6000Architecture.Disp14] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatBOnCond: RS6000Architecture.FormatBOnCond ¬ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp14 NOT IN [RS6000Architecture.firstDisp14 ..RS6000Architecture.lastDisp14] THEN { ERROR RuntimeError.BoundsFault; }; formatBOnCond.bdmsb ¬ disp14 IN [RS6000Architecture.firstDisp14..0]; formatBOnCond.bd ¬ IF formatBOnCond.bdmsb THEN disp14 - RS6000Architecture.firstDisp14 ELSE disp14; RETURN [LOOPHOLE[formatBOnCond]]; }; SetDisp24: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp24: RS6000Architecture.Disp24] RETURNS [RS6000Architecture.RS6000Instruction] ~ { formatBranch: RS6000Architecture.FormatBranch ¬ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp24 NOT IN [RS6000Architecture.firstDisp24 ..RS6000Architecture.lastDisp24] THEN { ERROR RuntimeError.BoundsFault; }; formatBranch.limsb ¬ disp24 IN [RS6000Architecture.firstDisp24..0]; formatBranch.li ¬ IF formatBranch.limsb THEN disp24 - RS6000Architecture.firstDisp24 ELSE disp24; RETURN [LOOPHOLE[formatBranch]]; }; IsNullRS6000Address: PUBLIC PROCEDURE [address: RS6000Architecture.RS6000Address] RETURNS [BOOLEAN] ~ { isNullRS6000Address: BOOLEAN ~ address = RS6000Architecture.nullRS6000Address; RETURN [isNullRS6000Address]; }; RS6000AddressFromDisplacement: PUBLIC PROCEDURE [ address: RS6000Architecture.RS6000Address, displacement: TargetArchitecture.Displacement] RETURNS [RS6000Architecture.RS6000Address] ~ { targetAddress: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: address]; displaced: TargetArchitecture.Address ~ TargetArchitecture.AddressFromDisplacement[ address: targetAddress, displacement: displacement]; rs6000Displaced: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: displaced]; IF address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [rs6000Displaced]; }; DisplacementFromRS6000Addresses: PUBLIC PROCEDURE [ here: RS6000Architecture.RS6000Address, there: RS6000Architecture.RS6000Address] RETURNS [TargetArchitecture.Displacement] ~ { hereTarget: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: here]; thereTarget: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: there]; displacement: TargetArchitecture.Displacement ~ TargetArchitecture.DisplacementFromAddresses[ here: hereTarget, there: thereTarget]; IF here.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF there.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [displacement]; }; IsNullRS6000Instruction: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { isNullRS6000Instruction: BOOLEAN ~ instruction = RS6000Architecture.nullRS6000Instruction; RETURN [isNullRS6000Instruction]; }; NextRS6000Instruction: PUBLIC PROCEDURE [pc: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Address] ~ TRUSTED { targetPC: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: pc]; nextInstruction: TargetArchitecture.Address ~ TargetArchitecture.NextInstruction[pc: targetPC]; nextRS6000Instruction: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: nextInstruction]; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [nextRS6000Instruction]; }; PrevRS6000Instruction: PUBLIC PROCEDURE [pc: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Address] ~ { targetPC: TargetArchitecture.Address ~ RS6000Architecture.TargetAddressFromRS6000Address[rs6000Address: pc]; prevInstruction: TargetArchitecture.Address ~ TargetArchitecture.PrevInstruction[pc: targetPC]; prevRS6000Instruction: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromTargetAddress[address: prevInstruction]; IF pc.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [prevRS6000Instruction]; }; RS6000AddressFromTargetAddress: PUBLIC PROCEDURE [ address: TargetArchitecture.Address] RETURNS [RS6000Architecture.RS6000Address] ~ { rs6000Address: RS6000Architecture.RS6000Address ~ LOOPHOLE[address]; IF rs6000Address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [rs6000Address]; }; TargetAddressFromRS6000Address: PUBLIC PROCEDURE [ rs6000Address: RS6000Architecture.RS6000Address] RETURNS [TargetArchitecture.Address] ~ { address: TargetArchitecture.Address ~ LOOPHOLE[rs6000Address]; IF rs6000Address.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; RETURN [address]; }; RS6000ContentsFromTargetContents: PUBLIC PROCEDURE [ contents: TargetArchitecture.Contents] RETURNS [RS6000Architecture.RS6000Contents] ~ { rs6000Contents: RS6000Architecture.RS6000Contents ~ LOOPHOLE[contents]; RETURN [rs6000Contents]; }; TargetContentsFromRS6000Contents: PUBLIC PROCEDURE [ contents: RS6000Architecture.RS6000Contents] RETURNS [TargetArchitecture.Contents] ~ { targetContents: TargetArchitecture.Contents ~ LOOPHOLE[contents]; RETURN [targetContents]; }; RS6000InstructionFromTargetInstruction: PUBLIC PROCEDURE [ instruction: TargetArchitecture.Instruction] RETURNS [RS6000Architecture.RS6000Instruction] ~ { rs6000Instruction: RS6000Architecture.RS6000Instruction ~ LOOPHOLE[instruction]; IF rs6000Instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs6000Instruction]; }; TargetInstructionFromRS6000Instruction: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction] RETURNS [TargetArchitecture.Instruction] ~ { targetInstruction: TargetArchitecture.Instruction ~ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [targetInstruction]; }; RS6000RegisterClassFromTargetRegisterClass: PUBLIC PROCEDURE [ registerClass: TargetArchitecture.RegisterClass] RETURNS [RS6000Architecture.RegisterClass] ~ { rs6000RegisterClass: RS6000Architecture.RegisterClass ~ LOOPHOLE[registerClass]; SELECT rs6000RegisterClass FROM none, globals, globalsAndIns, globalsInsAndFloats, globalsInsFloatsOutsAndLocals, all => { NULL; }; ENDCASE => { ERROR RuntimeError.BoundsFault; }; RETURN [rs6000RegisterClass]; }; TargetRegisterClassFromRS6000RegisterClass: PUBLIC PROCEDURE [ registerClass: RS6000Architecture.RegisterClass] RETURNS [TargetArchitecture.RegisterClass] ~ { targetRegisterClass: TargetArchitecture.RegisterClass ~ LOOPHOLE[registerClass]; SELECT registerClass FROM none, globals, globalsAndIns, globalsInsAndFloats, globalsInsFloatsOutsAndLocals, all => { NULL; }; ENDCASE => { ERROR RuntimeError.BoundsFault; }; RETURN [targetRegisterClass]; }; CantRelocate: PUBLIC ERROR ~ CODE; CantReach: PUBLIC ERROR ~ CODE; NullRS6000Address: PUBLIC ERROR ~ CODE; NullRS6000Instruction: PUBLIC ERROR ~ CODE; }. k RS6000ArchitectureImpl.mesa Copyright Ó 1991, 1992, 1993 by Xerox Corporation. All rights reserved. Peter B. Kessler, April 9, 1990 3:31:21 pm PDT Operations the debugger performs on the RS6000. Udagawa, September 18, 1991 7:10 pm PDT Katsuyuki Komatsu March 5, 1992 1:16 pm PST Laurie Horton, February 24, 1993 8:30 pm PST Code Assembly. or instruction with rc bit off doesn't affect condition register. So, it can be used for nop with the same source and destination registers. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocates an instruction from the given address to another address. Relocate: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { Relocates an instruction from the given address to another address. relocated: RS6000Architecture.RS6000Instruction _ instruction; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF from.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; IF to.IsNullRS6000Address[] THEN { ERROR RS6000Architecture.NullRS6000Address; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { SELECT instruction.GetOp2[] FROM RS6000Architecture.Op2.bicc, RS6000Architecture.Op2.fbfcc, RS6000Architecture.Op2.cbccc => { RelocateFormat2: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp22: RS6000Architecture.Disp22 ~ instruction.GetDisp22[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp22 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses [here: to, there: targetAddress]; relocationDisp22: RS6000Architecture.Disp22 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp22 NOT IN [RS6000Architecture.firstDisp22..RS6000Architecture.lastDisp22] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp22[disp22: relocationDisp22]; RETURN [relocated]; }; relocated _ RelocateFormat2[instruction: instruction, from: from, to: to]; }; ENDCASE => { NULL; }; }; RS6000Architecture.Op.call => { RelocateFormat1: PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, from: RS6000Architecture.RS6000Address, to: RS6000Architecture.RS6000Address] RETURNS [RS6000Architecture.RS6000Instruction] ~ { relocated: RS6000Architecture.RS6000Instruction _ instruction; instructionDisp30: RS6000Architecture.Disp30 ~ instruction.GetDisp30[]; byteDisplacement: TargetArchitecture.Displacement ~ instructionDisp30 * BYTES[RS6000Architecture.RS6000Instruction]; targetAddress: RS6000Architecture.RS6000Address ~ RS6000Architecture.RS6000AddressFromDisplacement[ address: from, displacement: byteDisplacement]; relocationDisplacement: TargetArchitecture.Displacement ~ RS6000Architecture.DisplacementFromRS6000Addresses [here: to, there: targetAddress]; relocationDisp30: RS6000Architecture.Disp30 ~ relocationDisplacement / BYTES[RS6000Architecture.RS6000Instruction]; IF relocationDisp30 NOT IN [RS6000Architecture.firstDisp30..RS6000Architecture.lastDisp30] THEN { ERROR RS6000Architecture.CantRelocate; }; IF relocationDisplacement MOD BYTES[RS6000Architecture.RS6000Instruction] # 0 THEN { ERROR RS6000Architecture.CantRelocate; }; relocated _ instruction.SetDisp30[disp30: relocationDisp30]; RETURN [relocated]; }; relocated _ RelocateFormat1[instruction: instruction, from: from, to: to]; }; RS6000Architecture.Op.other2 => { NULL; }; RS6000Architecture.Op.other3 => { NULL; }; ENDCASE => ERROR; RETURN [relocated]; }; Instruction Classification. A sample noop instruction. Checks whether the instruction at the given pc is a noop. NeedsRelocation: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { Checks whether the instruction at the given pc has pc-relative operands. needsRelocation: BOOLEAN _ FALSE; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { SELECT instruction.GetOp2[] FROM RS6000Architecture.Op2.bicc, RS6000Architecture.Op2.fbfcc, RS6000Architecture.Op2.cbccc => { needsRelocation _ TRUE; }; ENDCASE => { needsRelocation _ FALSE; }; }; RS6000Architecture.Op.call => { needsRelocation _ TRUE; }; RS6000Architecture.Op.other2 => { needsRelocation _ FALSE; }; RS6000Architecture.Op.other3 => { needsRelocation _ FALSE; }; ENDCASE => ERROR; RETURN [needsRelocation]; }; IsCallInstruction: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [BOOLEAN] ~ { Checks whether the instruction is a call instruction. isCallInstruction: BOOLEAN _ FALSE; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => { isCallInstruction _ FALSE; }; RS6000Architecture.Op.call => { isCallInstruction _ TRUE; }; RS6000Architecture.Op.other2 => { isCallInstruction _ FALSE; }; RS6000Architecture.Op.other3 => { isCallInstruction _ FALSE; }; ENDCASE => ERROR; RETURN [isCallInstruction]; }; Field accessors for instructions. GetFormat: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Format] ~ { format: RS6000Architecture.Format ~ SELECT instruction.GetOp[] FROM RS6000Architecture.Op.branch => RS6000Architecture.Format.format2, RS6000Architecture.Op.call => RS6000Architecture.Format.format1, RS6000Architecture.Op.other2 => RS6000Architecture.Format.format2, RS6000Architecture.Op.other3 => RS6000Architecture.Format.format3, ENDCASE => ERROR; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [format]; }; GetDisp30: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp30] ~ { format1: RS6000Architecture.Format1 ~ LOOPHOLE[instruction]; disp30: RS6000Architecture.Disp30 ~ RS6000Architecture.Disp30FromUnbiased30[ unbiased30MS: format1.disp30MS, unbiased30LS: format1.disp30LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp30]; }; GetRd: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; rd: RS6000Architecture.Register ~ format2Imm22.rd; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rd]; }; GetOp2: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op2] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; op2: RS6000Architecture.Op2 ~ format2Imm22.op2; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op2]; }; GetImm22: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Imm22] ~ { format2Imm22: RS6000Architecture.Format2Imm22 ~ LOOPHOLE[instruction]; imm22: RS6000Architecture.Imm22 ~ RS6000Architecture.Imm22FromImm22ML[ imm22MS: format2Imm22.imm22MS, imm22LS: format2Imm22.imm22LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [imm22]; }; GetAnnul: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Annul] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; annul: RS6000Architecture.Annul ~ format2Disp22.a; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [annul]; }; GetCond: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Cond] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; cond: RS6000Architecture.Cond ~ format2Disp22.cond; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [cond]; }; GetDisp22: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Disp22] ~ { format2Disp22: RS6000Architecture.Format2Disp22 ~ LOOPHOLE[instruction]; disp22: RS6000Architecture.Disp22 ~ RS6000Architecture.Disp22FromUnbiased22[ unbiased22MS: format2Disp22.disp22MS, unbiased22LS: format2Disp22.disp22LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [disp22]; }; GetRs1: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; rs1: RS6000Architecture.Register ~ RS6000Architecture.RegisterFromRegisterML[registerMS: format3asi.rs1MS, registerLS: format3asi.rs1LS]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs1]; }; RegisterFromRegisterML: PUBLIC PROCEDURE [ registerMS: RS6000Architecture.RegisterMS, registerLS: RS6000Architecture.RegisterLS] RETURNS [RS6000Architecture.Register] ~ { register: RS6000Architecture.Register ~ VAL[ (registerMS * (LAST[RS6000Architecture.RegisterLS] + 1)) + registerLS ]; RETURN [register]; }; GetI: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.I] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; i: RS6000Architecture.I ~ format3asi.i; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [i]; }; GetASI: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.ASI] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; asi: RS6000Architecture.ASI ~ format3asi.asi; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [asi]; }; GetRs2: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Register] ~ { format3asi: RS6000Architecture.Format3asi ~ LOOPHOLE[instruction]; rs2: RS6000Architecture.Register ~ format3asi.rs2; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [rs2]; }; GetSimm13: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Simm13] ~ { format3Simm13: RS6000Architecture.Format3Simm13 ~ LOOPHOLE[instruction]; simm13: RS6000Architecture.Simm13 ~ RS6000Architecture.Simm13FromUnbiased13[unbiased13: format3Simm13.simm13]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [simm13]; }; GetOpF: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.OpF] ~ { format3OpF: RS6000Architecture.Format3OpF ~ LOOPHOLE[instruction]; opf: RS6000Architecture.OpF ~ format3OpF.opf; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [opf]; }; GetOp3: PUBLIC PROCEDURE [instruction: RS6000Architecture.RS6000Instruction] RETURNS [RS6000Architecture.Op3] ~ { format3TiccRs2: RS6000Architecture.Format3TiccRs2 ~ LOOPHOLE[instruction]; op3: RS6000Architecture.Op3 ~ format3TiccRs2.op3; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; RETURN [op3]; }; Op10Op3FromOp3: PUBLIC PROCEDURE [op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.Op10Op3] ~ { op10Op3: RS6000Architecture.Op10Op3 ~ VAL[ORD[op3]]; RETURN [op10Op3]; }; Op11Op3FromOp3: PUBLIC PROCEDURE [op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.Op11Op3] ~ { op11Op3: RS6000Architecture.Op11Op3 ~ VAL[ORD[op3]]; RETURN [op11Op3]; }; Disp30FromUnbiased30: PUBLIC PROCEDURE [ unbiased30MS: RS6000Architecture.Unbiased30MS, unbiased30LS: RS6000Architecture.Unbiased30LS] RETURNS [RS6000Architecture.Disp30] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ (unbiased30MS * (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1)) + unbiased30LS; disp30: RS6000Architecture.Disp30 ~ IF unbiased30 <= RS6000Architecture.Unbiased30[RS6000Architecture.lastDisp30] THEN unbiased30 ELSE -(RS6000Architecture.lastUnbiased30 + 1 - unbiased30); Since RS6000Architecture.Disp30 isn't a biased subrange any more, this can just sign-extend the unbiased the representation. IF unbiased30 NOT IN [RS6000Architecture.firstUnbiased30 .. RS6000Architecture.lastUnbiased30] THEN { ERROR RuntimeError.BoundsFault }; RETURN [disp30]; }; Disp22FromUnbiased22: PUBLIC PROCEDURE [ unbiased22MS: RS6000Architecture.Unbiased22MS, unbiased22LS: RS6000Architecture.Unbiased22LS] RETURNS [RS6000Architecture.Disp22] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ (unbiased22MS * (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1)) + unbiased22LS; disp22: RS6000Architecture.Disp22 ~ IF unbiased22 <= RS6000Architecture.Unbiased22[RS6000Architecture.lastDisp22] THEN unbiased22 ELSE -(RS6000Architecture.lastUnbiased22 + 1 - unbiased22); Since RS6000Architecture.Disp22 isn't a biased subrange any more, this can just sign-extend the unbiased the representation. IF unbiased22 NOT IN [RS6000Architecture.firstUnbiased22 .. RS6000Architecture.lastUnbiased22] THEN { ERROR RuntimeError.BoundsFault }; RETURN [disp22]; }; Imm22FromImm22ML: PUBLIC PROCEDURE [ imm22MS: RS6000Architecture.Imm22MS, imm22LS: RS6000Architecture.Imm22LS] RETURNS [RS6000Architecture.Imm22] ~ { imm22: RS6000Architecture.Imm22 ~ (imm22MS * (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1)) + imm22LS; IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22]; }; Imm22MSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Imm22MS] ~ { imm22MS: RS6000Architecture.Imm22MS ~ imm22 / (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1); IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22MS]; }; Imm22LSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Imm22LS] ~ { imm22LS: RS6000Architecture.Imm22LS ~ imm22 MOD (CARD32[LAST[RS6000Architecture.Imm22LS]] + 1); IF NOT imm22 IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [imm22LS]; }; Simm13FromUnbiased13: PUBLIC PROCEDURE [unbiased13: RS6000Architecture.Unbiased13] RETURNS [RS6000Architecture.Simm13] ~ { biased: INT32 ~ IF unbiased13 <= RS6000Architecture.lastSimm13 THEN unbiased13 ELSE -(RS6000Architecture.lastUnbiased13 + 1 - unbiased13); simm13: RS6000Architecture.Simm13 ~ biased; RETURN [simm13]; }; HiLo: PUBLIC PROCEDURE[hi: RS6000Architecture.Imm22, lo: RS6000Architecture.Imm10] RETURNS [CARD32] ~ { hiLo: CARD32 ~ (hi * (CARD32[RS6000Architecture.lastImm10] + 1)) + lo; IF hi NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; IF lo NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [hiLo]; }; Field assigners for instructions. SetDisp30: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format1: RS6000Architecture.Format1 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp30 NOT IN [RS6000Architecture.firstDisp30 ..RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; format1.disp30MS _ RS6000Architecture.Unbiased30MSFromDisp30[disp30: disp30]; format1.disp30LS _ RS6000Architecture.Unbiased30LSFromDisp30[disp30: disp30]; RETURN [LOOPHOLE[format1]]; }; SetRd: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rd: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Imm22.rd _ rd; RETURN [LOOPHOLE[format2Imm22]]; }; SetOp2: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op2: RS6000Architecture.Op2] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Imm22.op2 _ op2; RETURN [LOOPHOLE[format2Imm22]]; }; SetImm22: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Imm22: RS6000Architecture.Format2Imm22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF imm22 NOT IN [RS6000Architecture.firstImm22 .. RS6000Architecture.lastImm22] THEN { ERROR RuntimeError.BoundsFault; }; format2Imm22.imm22MS _ RS6000Architecture.Unbiased22MSFromImm22[imm22: imm22]; format2Imm22.imm22LS _ RS6000Architecture.Unbiased22LSFromImm22[imm22: imm22]; RETURN [LOOPHOLE[format2Imm22]]; }; SetAnnul: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, annul: RS6000Architecture.Annul] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Disp22.a _ annul; RETURN [LOOPHOLE[format2Disp22]]; }; SetCond: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, cond: RS6000Architecture.Cond] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format2Disp22.cond _ cond; RETURN [LOOPHOLE[format2Disp22]]; }; SetDisp22: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format2Disp22: RS6000Architecture.Format2Disp22 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; IF disp22 NOT IN [RS6000Architecture.firstDisp22 .. RS6000Architecture.lastDisp22] THEN { ERROR RuntimeError.BoundsFault; }; format2Disp22.disp22MS _ RS6000Architecture.Unbiased22MSFromDisp22[disp22: disp22]; format2Disp22.disp22LS _ RS6000Architecture.Unbiased22LSFromDisp22[disp22: disp22]; RETURN [LOOPHOLE[format2Disp22]]; }; SetRs1: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rs1: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.rs1MS _ RS6000Architecture.RegisterMSFromRegister[register: rs1]; format3asi.rs1LS _ RS6000Architecture.RegisterLSFromRegister[register: rs1]; RETURN [LOOPHOLE[format3asi]]; }; RegisterMSFromRegister: PUBLIC PROCEDURE [register: RS6000Architecture.Register] RETURNS [RS6000Architecture.RegisterMS] ~ { registerMS: RS6000Architecture.RegisterMS ~ ORD[register] / (LAST[RS6000Architecture.RegisterLS] + 1); RETURN [registerMS]; }; RegisterLSFromRegister: PUBLIC PROCEDURE [register: RS6000Architecture.Register] RETURNS [RS6000Architecture.RegisterLS]~ { registerLS: RS6000Architecture.RegisterLS ~ ORD[register] MOD (LAST[RS6000Architecture.RegisterLS] + 1); RETURN [registerLS]; }; SetI: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, i: RS6000Architecture.I] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.i _ i; RETURN [LOOPHOLE[format3asi]]; }; SetASI: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, asi: RS6000Architecture.ASI] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.asi _ asi; RETURN [LOOPHOLE[format3asi]]; }; SetRs2: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, rs2: RS6000Architecture.Register] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3asi: RS6000Architecture.Format3asi _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3asi.rs2 _ rs2; RETURN [LOOPHOLE[format3asi]]; }; SetSimm13: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, simm13: RS6000Architecture.Simm13] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3Simm13: RS6000Architecture.Format3Simm13 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3Simm13.simm13 _ RS6000Architecture.Unbiased13FromSimm13[simm13: simm13]; RETURN [LOOPHOLE[format3Simm13]]; }; SetOpF: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, opf: RS6000Architecture.OpF] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3OpF: RS6000Architecture.Format3OpF _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3OpF.opf _ opf; RETURN [LOOPHOLE[format3OpF]]; }; SetOp3: PUBLIC PROCEDURE [ instruction: RS6000Architecture.RS6000Instruction, op3: RS6000Architecture.Op3] RETURNS [RS6000Architecture.RS6000Instruction] ~ { format3TiccRs2: RS6000Architecture.Format3TiccRs2 _ LOOPHOLE[instruction]; IF instruction.IsNullRS6000Instruction[] THEN { ERROR RS6000Architecture.NullRS6000Instruction; }; format3TiccRs2.op3 _ op3; RETURN [LOOPHOLE[format3TiccRs2]]; }; Op3FromOp10Op3: PUBLIC PROCEDURE [op10Op3: RS6000Architecture.Op10Op3] RETURNS [RS6000Architecture.Op3] ~ { op3: RS6000Architecture.Op3 ~ VAL[ORD[op10Op3]]; RETURN [op3]; }; Op3FromOp11Op3: PUBLIC PROCEDURE [op11Op3: RS6000Architecture.Op11Op3] RETURNS [RS6000Architecture.Op3] ~ { op3: RS6000Architecture.Op3 ~ VAL[ORD[op11Op3]]; RETURN [op3]; }; Unbiased30FromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30] ~ { Since RS6000Architecture.Disp30 isn't a biased subrange any more, all I have to do is pick off the right bits. unbiased: CARD32 ~ LOOPHOLE[disp30]; unbiased30: RS6000Architecture.Unbiased30 ~ unbiased MOD (RS6000Architecture.lastUnbiased30 + 1); IF disp30 NOT IN [RS6000Architecture.firstDisp30 .. RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased30]; }; Unbiased30MSFromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30MS] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ RS6000Architecture.Unbiased30FromDisp30[disp30: disp30]; unbiased30MS: RS6000Architecture.Unbiased30MS ~ unbiased30 / (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1); IF disp30 NOT IN [RS6000Architecture.firstDisp30 .. RS6000Architecture.lastDisp30] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased30MS]; }; Unbiased30LSFromDisp30: PUBLIC PROCEDURE [disp30: RS6000Architecture.Disp30] RETURNS [RS6000Architecture.Unbiased30LS] ~ { unbiased30: RS6000Architecture.Unbiased30 ~ RS6000Architecture.Unbiased30FromDisp30[disp30: disp30]; unbiased30LS: RS6000Architecture.Unbiased30LS ~ unbiased30 MOD (CARD32[LAST[RS6000Architecture.Unbiased30LS]] + 1); RETURN [unbiased30LS]; }; Unbiased22FromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22] ~ { Since RS6000Architecture.Disp22 isn't a biased subrange any more, all I have to do is pick off the right bits. unbiased: CARD32 ~ LOOPHOLE[disp22]; unbiased22: RS6000Architecture.Unbiased22 ~ unbiased MOD (RS6000Architecture.lastUnbiased22 + 1); IF disp22 NOT IN [RS6000Architecture.firstDisp22 .. RS6000Architecture.lastDisp22] THEN { ERROR RuntimeError.BoundsFault; }; RETURN [unbiased22]; }; Unbiased22MSFromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22MS] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ RS6000Architecture.Unbiased22FromDisp22[disp22: disp22]; unbiased22MS: RS6000Architecture.Unbiased22MS ~ unbiased22 / (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22MS]; }; Unbiased22LSFromDisp22: PUBLIC PROCEDURE [disp22: RS6000Architecture.Disp22] RETURNS [RS6000Architecture.Unbiased22LS] ~ { unbiased22: RS6000Architecture.Unbiased22 ~ RS6000Architecture.Unbiased22FromDisp22[disp22: disp22]; unbiased22LS: RS6000Architecture.Unbiased22LS ~ unbiased22 MOD (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22LS]; }; Unbiased22MSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Unbiased22MS] ~ { unbiased22MS: RS6000Architecture.Unbiased22MS ~ imm22 / (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22MS]; }; Unbiased22LSFromImm22: PUBLIC PROCEDURE [imm22: RS6000Architecture.Imm22] RETURNS [RS6000Architecture.Unbiased22LS] ~ { unbiased22LS: RS6000Architecture.Unbiased22LS ~ imm22 MOD (CARD32[LAST[RS6000Architecture.Unbiased22LS]] + 1); RETURN [unbiased22LS]; }; Unbiased13FromSimm13: PUBLIC PROCEDURE [simm13: RS6000Architecture.Simm13] RETURNS [RS6000Architecture.Unbiased13] ~ { biased: INT32 ~ simm13; unbiased13: RS6000Architecture.Unbiased13 ~ IF biased >= 0 THEN biased ELSE RS6000Architecture.lastUnbiased13 + 1 + biased; RETURN [unbiased13]; }; Miscellaneous. Tests if its argument is the null RS6000Address. Tests if its argument is the null RS6000Instruction. Returns the instruction address after the given one. Returns a pointer to the previous instruction. Yeah for being able to back up in instruction streams, boo for needing to. Errors. Given for attempts to relocate an instruction too far, etc. Given for attempts to generate pc-relative instructions that don't reach. Given during code generation when null addresses are supplied. Given when supplied instruction is the null instruction. Ê/þ–"cedarcode" style•NewlineDelimiter ™code™Kšœ Ïeœ=™HKšœ.™.K™Kšœ(Ïkœ™/K™'K™+K™,K™šž ˜ K˜K˜K˜ K˜——unitšÐlnœžœžœ˜&Kšžœ5˜K˜šžœ'žœ˜/Kšžœ*˜/K˜—šžœžœ˜$Kšžœ&˜+K˜—šžœžœ˜"Kšžœ&˜+K˜—šžœž˜K˜EK˜FK˜EK˜CK˜FK˜DK˜DK˜\K˜[K˜WK˜FK˜FK˜EK˜EK˜EK˜EK˜FK˜FK˜FK˜FK˜WK˜BK˜CK˜DK˜EK˜CK˜DK˜DK˜DK˜EK˜DK˜EK˜DK˜CK˜DK˜DK˜EK˜DK˜EK˜EK˜FK˜EK˜FK˜WKšžœžœ˜—Kšžœ ˜K˜—K˜š œž œ‡žœ+˜ÓK™CK™K˜>šžœž˜$K˜MK˜LK˜NK˜OK˜NK˜OK˜NK˜NK˜NK˜MK˜LKšžœžœ˜K˜—Kšžœ ˜K˜—K˜š œž œ‡žœ+˜ÓK™CK™K˜>šžœ#ž˜-K˜UK˜SK˜VK˜TK˜TK˜WK˜UK˜WK˜VK˜UK˜VK˜WK˜VK˜WK˜UK˜WK˜UK˜UK˜UK˜VK˜VK˜VK˜VK˜VK˜WK˜WK˜WK˜VK˜WK˜UK˜WK˜VK˜WK˜VK˜UK˜WK˜TK˜WK˜VK˜WK˜UK˜VK˜VK˜TK˜VK˜XK˜WK˜UK˜VK˜WK˜VK˜WK˜WK˜UK˜UK˜XK˜VK˜WK˜VK˜VK˜XK˜WK˜WK˜UK˜VK˜XK˜VK˜VK˜WK˜—šžœ˜ šžœ ž˜*K˜QK˜PK˜RK˜RK˜QK˜SK˜RK˜SK˜QK˜SK˜RK˜RK˜RK˜SK˜RK˜SK˜SK˜—Kšžœžœ˜Kšœ˜K˜—Kšžœ ˜K˜—K˜š œž œ‡žœ+˜ÓK™CK™K˜>šžœž˜&K˜KK˜KK˜KK˜KK˜LK˜LK˜MK˜MK˜—šžœ˜ šžœž˜&K˜NK˜MK˜NK˜OK˜MK˜NK˜OK˜LK˜OK˜NK˜MK˜MK˜NK˜—Kšžœžœ˜K˜—Kšžœ ˜K˜K˜—š  œž œ5žœ+˜|K˜Kšžœ˜K˜—K˜š œž œ†žœ+˜ÜK˜K˜>KšœG˜Gšœ4˜4Kšœžœ'˜@—šœ2˜2šœ1˜1Kšœ/˜/——šœ:˜:KšœS˜S—šœ.˜.Kšœžœ'˜EK˜—šžœžœžœAžœ˜aKšžœ!˜&K˜—šžœžœžœ+žœ˜TKšžœ!˜&K˜—K˜KšœG˜Gšœ4˜4Kšœžœ'˜@—šœ2˜2šœ1˜1Kšœ/˜/——šœ:˜:KšœS˜S—šœ.˜.Kšœžœ'˜EK˜—šžœžœžœAžœ˜aKšžœ!˜&K˜—šžœžœžœ+žœ˜TKšžœ!˜&K˜—K˜™>K™šžœ'žœ™/Kšžœ*™/K™—šžœžœ™$Kšžœ&™+K™—šžœžœ™"Kšžœ&™+K™—šžœž™šœ!™!šžœž™ Kšœ™Kšœ™šœ!™!š œž œ‡žœ+™ÓKšœ>™>KšœG™Gšœ4™4Kšœžœ'™@—šœ2™2šœ1™1Kšœ/™/——šœ:™:šœ2™2Kšœ!™!——šœ.™.Kšœžœ'™E—K™šžœžœžœ@žœ™aKšžœ!™&K™—šžœžœžœ+žœ™TKšžœ!™&K™—Kšœ<™™>KšœG™Gšœ4™4Kšœžœ'™@—šœ2™2šœ1™1Kšœ/™/——šœ:™:šœ2™2Kšœ!™!——šœ.™.Kšœžœ'™E—K™šžœžœžœ@žœ™aKšžœ!™&K™—šžœžœžœ+žœ™TKšžœ!™&K™—Kšœ<™™>—K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ ™Kšœ™K™—š œžœž œ6žœ™vKšœ2žœ™HKšœ2™2K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ ™Kšœ™K™—š œžœž œ6žœ™tKšœ2žœ™HKšœ3™3K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™Kšœ™K™—š  œžœž œ6žœ ™xKšœ2žœ™Hšœ$™$šœ(™(KšœL™L——K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ ™Kšœ™K™—š œžœž œ6žœ"™wKšœ,žœ™BKšœ‰™‰K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™š œžœž œZžœ"™«šœ(žœ™,Kšœžœ2™EKšœ™K™—Kšžœ ™Kšœ™—K™—š œžœž œ6žœ™nKšœ,žœ™BKšœ'™'K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™—š  œžœž œ6žœžœ™rKšœ,žœ™BKšœžœ™-K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™—š œžœž œ6žœ"™wKšœ,žœ™BKšœ2™2K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™—š  œžœž œ6žœ ™xKšœ2žœ™Hšœ$™$KšœJ™J—K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ ™Kšœ™K™—š œžœž œ6žœ™rKšœ,žœ™BKšœ-™-K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™—š œžœž œ6žœ™rKšœ4žœ™JKšœ1™1K™šžœ'žœ™/Kšžœ*™/K™—Kšžœ™ Kšœ™K™š œžœž œ žœ!™hKšœ&žœžœ™4Kšžœ ™K™—š œžœž œ žœ!™hKšœ&žœžœ™4Kšžœ ™K™—K™—š œžœž œcžœ ™°šœ,™,Kšœžœžœ)™EKšœ™—šœ$™$šžœK™MKšžœ ™Kšžœ7™;Kšœ|™|——K™šžœ žœžœLžœ™fKšžœ™Kšœ™—Kšžœ ™Kšœ™K™—š œžœž œbžœ ™¯šœ,™,Kšœžœžœ)™EKšœ™—šœ$™$šžœK™MKšžœ ™Kšžœ7™;Kšœ|™|——K™šžœ žœžœLžœ™fKšžœ™Kšœ™—Kšžœ ™Kšœ™K™—š œžœž œOžœ™—šœ"™"Kšœ žœžœ.™E—K™šžœžœžœAžœ™VKšžœ™K™—Kšžœ ™Kšœ™K™—š œžœž œ$žœ!™nšœ&™&Kšœ žœžœ#™7—K™šžœžœžœAžœ™VKšžœ™K™—Kšžœ ™Kšœ™K™—š œžœž œ$žœ!™nšœ&™&Kšœžœžœžœ#™9—K™šžœžœžœAžœ™VKšžœ™K™—Kšžœ ™Kšœ™K™—š œžœž œ.žœ ™{šœžœžœ,™>Kšžœ ™Kšžœ7™;—Kšœ+™+K™Kšžœ ™Kšœ™K™—š  œžœž œ žœžœžœ˜JKšœžœ ¡œ¡œ˜7K˜Kšžœ˜ Kšœ˜K˜—š  œžœž œ žœžœžœ˜IKš œžœÏsœ¡œ¡œ¡œ˜9K˜Kšžœ˜ Kšœ˜K™—š  œžœž œ>žœžœ™hKšœžœ žœ*™FK™šžœžœžœAžœ™SKšžœ™K™—šžœžœžœAžœ™SKšžœ™K™—Kšžœ™K™K˜——™!š œžœž œRžœ+˜›Kšœ2žœ˜HK˜šžœ'žœ˜/Kšžœ*˜/K˜—K˜Kšžœžœ˜!Kšœ˜K˜—š  œžœž œZžœ+˜§Kšœ2žœ˜HK˜šžœ'žœ˜/Kšžœ*˜/K˜—šžœžœžœBžœ˜XKšžœ˜Kšœ˜—Kšœ¡œ%˜DKšœžœžœ)žœ˜cKšžœžœ˜!Kšœ˜K˜—K˜—š  œžœž œZžœ+˜§Kšœ0žœ˜FK˜šžœ'žœ˜/Kšžœ*˜/K˜—šžœžœžœBžœ˜XKšžœ˜Kšœ˜—Kšœ¡Ðlsœ£œ˜CKšœžœžœ)žœ˜aKšžœžœ˜ Kšœ˜K˜š  œžœž œZžœ+™§Kšœ&žœ™—K™Kšžœ™Kšœ™—K™—š œžœž œ&žœ$™wKšœžœ ™šœ,™,šžœ ™Kšžœ™ Kšžœ0™4——K™Kšžœ™K™K˜——™š  œžœž œ.žœžœ˜hK™0Kšœžœ2˜NK˜Kšžœ˜Kšœ˜K™—š œžœž œ^žœ'˜»šœ,˜,KšœJ˜J—šœ(˜(šœ+˜+Kšœ4˜4——Kšœz˜zK˜šžœžœ˜'Kšžœ&˜+K˜—Kšžœ˜Kšœ˜K˜—š œžœž œTžœ&˜²šœ)˜)KšœG˜G—šœ*˜*KšœH˜H—šœ0˜0šœ-˜-Kšœ&˜&——K˜šžœžœ˜$Kšžœ&˜+K˜—šžœžœ˜%Kšžœ&˜+K˜—Kšžœ˜Kšœ˜K˜—š  œžœž œ7žœžœ˜uK™4šœžœ˜#Kšœ7˜7—K˜Kšžœ˜!Kšœ˜K™—š  œžœž œ)žœ&žœ˜†K™4šœ'˜'KšœE˜E—šœ.˜.Kšœ1˜1—šœ:˜:KšœL˜L—K˜šžœžœ˜"Kšžœ&˜+K˜—Kšžœ˜Kšœ˜K˜—š œžœž œ)žœ'˜~™.K™J—šœ'˜'KšœE˜E—šœ.˜.Kšœ1˜1—šœ:˜:KšœL˜L—K˜šžœžœ˜"Kšžœ&˜+K˜—Kšžœ˜K˜K˜—š œžœž œ)žœ'˜‡Kšœ2žœ ˜DK˜šžœ%žœ˜-Kšžœ&˜+K˜—Kšžœ˜K˜K˜—š œžœž œ5žœ!˜Kšœ&žœ˜>K˜šžœ%žœ˜-Kšžœ&˜+K˜—Kšžœ ˜K˜K˜—š  œžœž œ*žœ(˜‹Kšœ4žœ ˜GK˜Kšžœ˜Kšœ˜K˜—š  œžœž œ0žœ"˜‹Kšœ.žœ ˜AK˜Kšžœ˜Kšœ˜K˜—š &œžœž œ0žœ+˜šKšœ:žœ˜PK˜šžœ-žœ˜5Kšžœ*˜/K˜—Kšžœ˜Kšœ˜K˜—š &œžœž œ6žœ%˜šKšœ4žœ˜JK˜šžœ'žœ˜/Kšžœ*˜/K˜—Kšžœ˜Kšœ˜K˜—š *œžœž œ4žœ'˜žKšœ8žœ˜PK˜šžœž˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜šœ˜Kšžœ˜Kšœ˜—šžœ˜ Kšžœ˜Kšœ˜——Kšžœ˜Kšœ˜K˜—š *œžœž œ4žœ'˜žKšœ8žœ˜PK˜šžœž˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜šœ˜Kšžœ˜Kšœ˜—šžœ˜ Kšžœ˜Kšœ˜——Kšžœ˜Kšœ˜K˜——™š  œžœžœžœ˜"K™;K™—š  œžœžœžœ˜K™IK™—š œžœžœžœ˜'K™>K™—š œžœžœžœ˜+K™8K™——L˜K™——…—”R/l