public void AssembleGeneratesCorrectValueIfOperandIsSecondOperand() { var operand = new NextWordOperand { NextWord = 0x20 }; const int Index = 1; const ushort Shift = (ushort)(OpcodeWidth + (Index * OperandWidth)); Assert.That( operand.AssembleOperand(Index), Is.EqualTo((ushort)((ushort)OperandType.ONextWord << Shift))); }
public void NoOpIncrementsProgramCounter() { var cpuStateManager = new Mock<ICpuStateOperations>(); var operand = new NextWordOperand(); cpuStateManager.Setup(m => m.IncrementProgramCounter()).Returns(0x1); operand.NoOp(cpuStateManager.Object); cpuStateManager.VerifyAll(); }
public void ReadIncrementsProgramCounterAndReturnMemoryValuePointedByProgramCounter() { var cpuStateManager = new Mock<ICpuStateOperations>(); var operand = new NextWordOperand(); cpuStateManager.Setup(m => m.IncrementProgramCounter()).Returns(0x1); cpuStateManager.Setup(m => m.ReadValueAtProgramCounter()).Returns(0x10); var nextWordValue = operand.Read(cpuStateManager.Object); operand.Read(cpuStateManager.Object); Assert.That(nextWordValue, Is.EqualTo(0x10)); }
public void AssembleGeneratesCorrectValueIfNextWordLessThan32AndOperandIsFirstOperand() { var operand = new NextWordOperand { NextWord = 0x10 }; const int Index = 0; const ushort Shift = (ushort)(OpcodeWidth + (Index * OperandWidth)); Assert.That( operand.AssembleOperand(Index), Is.EqualTo((ushort)((0x10 + OperandLiteralOffset) << Shift))); }
public void ToStringReturnsOperandStringRepresentation() { var operand = new NextWordOperand(); Assert.That(operand.ToString(), Is.EqualTo("NW")); }