コード例 #1
0
        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)));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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)));
        }
コード例 #5
0
 public void ToStringReturnsOperandStringRepresentation()
 {
     var operand = new NextWordOperand();
     Assert.That(operand.ToString(), Is.EqualTo("NW"));
 }