public void TestOpCodeInstructionParse(int startVal, int[] expectedResults) { OpCodeInstruction curInst = new OpCodeInstruction(startVal); // parammodes, then instruction Assert.Equal(expectedResults[0], (int)curInst.GetParamMode(0)); Assert.Equal(expectedResults[1], (int)curInst.GetParamMode(1)); Assert.Equal(expectedResults[2], (int)curInst.GetParamMode(2)); Assert.Equal(expectedResults[3], (int)curInst.GetInstruction()); }
public static OpCode ReadNextOpCode(IntComputer computer) { // 1002 //ABCDE //01002 = DE = opcode, c = mode for op 1, b mode for op 2 a, mode for op 3 long opCodeData = computer.ReadNextMemoryAddress(); OpCodeInstruction newInstruction = new OpCodeInstruction(opCodeData); switch (newInstruction.GetInstruction()) { case OpCodeInstruction.OPCODE_TYPES.ADD: return(new AddOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.MUL: return(new MulOpcode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.EXIT: return(new ExitOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.INPUT: return(new InputOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.OUTPUT: return(new OutputOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.JUMP_IF_TRUE: return(new JumpIfTrueOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.JUMP_IF_FALSE: return(new JumpIfFalseOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.LESS_THAN: return(new LessThanOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.EQUALS: return(new EqualsOpCode(newInstruction)); case OpCodeInstruction.OPCODE_TYPES.ADJUST_RELATIVE_BASE: return(new AdjustRelativeBaseOpCode(newInstruction)); default: Console.WriteLine("DER FARK?"); return(null); } }
public OpCode(OpCodeInstruction newInstruction) { curInstruction = newInstruction; }
public MulOpcode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public EqualsOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public AdjustRelativeBaseOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public LessThanOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public JumpIfFalseOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public OutputOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public ExitOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }
public AddOpCode(OpCodeInstruction newInstruction) : base(newInstruction) { }