コード例 #1
0
        public void TestDecimalAdjustRegister()
        {
            var device = TestUtils.CreateTestDevice();
            var cpu    = device.CPU;
            var alu    = new ALU(cpu);

            cpu.Registers.A = 0x45;
            cpu.Registers.B = 0x38;
            alu.Add(ref cpu.Registers.A, cpu.Registers.B, false);
            alu.DecimalAdjustRegister(ref cpu.Registers.A);
            Assert.Equal(0x83, cpu.Registers.A);

            Assert.Equal(0x0, cpu.Registers.F); // All flags zero

            cpu.Registers.A = 0x83;
            alu.Sub(ref cpu.Registers.A, cpu.Registers.B, false);
            alu.DecimalAdjustRegister(ref cpu.Registers.A);
            Assert.Equal(0x45, cpu.Registers.A);

            Assert.Equal((byte)CpuFlags.SubtractFlag, cpu.Registers.F); // All flags zero
        }