EncodeStatement:
PUBLIC
PROC [opNum:
INTEGER, tag: Value, immediate, indirect, indexed:
BOOL]
RETURNS [value: Value] ~ {
instruction: RobotDefs.Instruction ← [
immediate: immediate,
indirect: indirect,
indexed: indexed,
opNum: opNum,
tag: 0
];
insValue: INTEGER ← LOOPHOLE[instruction];
value ← RobotEvaluator.ApplyBinaryFcn[
RobotEvaluator.opPlus,
RobotEvaluator.ApplyBinaryFcn[RobotEvaluator.opMOD, tag, RobotEvaluator.NewValueFromInteger[256]],
RobotEvaluator.NewValueFromInteger[insValue]];
};
DecodeStatement:
PUBLIC
PROC [integer:
INTEGER]
RETURNS [opNum, tag:
INTEGER, immediate, indirect, indexed:
BOOL ←
FALSE] ~ {
instruction: RobotDefs.Instruction ← LOOPHOLE[integer];
RETURN [
opNum: instruction.opNum,
tag: instruction.tag,
immediate: instruction.immediate,
indirect: instruction.indirect,
indexed: instruction.indexed
];
};
}.