Beispiel #1
0
        public void ShouldEvaluateDeltaValue()
        {
            EvaluatorContext context = new EvaluatorContext();

            FakeConsoleRam ram = new FakeConsoleRam(0xFF);

            ram.Data[4] = 4;

            // 0xH0004 < d0xH004
            ReadMemoryValue readMemory = new ReadMemoryValue
            {
                Address = 0x0004,
                Kind    = MemoryAddressKind.Int8
            };

            DeltaValue deltaValue = new DeltaValue(readMemory);

            CompareInstruction compareInst = new CompareInstruction
            {
                Left      = readMemory,
                Right     = deltaValue,
                Operation = ConditionCompare.Less
            };

            Assert.False(compareInst.Evaluate(ram, context));

            ram.Data[4] = 2;

            Assert.True(compareInst.Evaluate(ram, context));
            Assert.False(compareInst.Evaluate(ram, context));
        }
Beispiel #2
0
        public void ShouldEvalEqualsMemoryWithConstValue()
        {
            EvaluatorContext context = new EvaluatorContext();

            FakeConsoleRam ram = new FakeConsoleRam(0xFF);

            ram.Data[4] = 42;

            // 0xH0004 == 42
            ReadMemoryValue readMemory = new ReadMemoryValue
            {
                Address = 0x0004,
                Kind    = MemoryAddressKind.Int8
            };

            ConstValue constValue = new ConstValue(42);

            CompareInstruction compareInst = new CompareInstruction
            {
                Left      = readMemory,
                Right     = constValue,
                Operation = ConditionCompare.Equals
            };

            var result = compareInst.Evaluate(ram, context);

            Assert.True(result);
        }