示例#1
0
 public void SUB_rTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.A = 0x29;
     target.D = 0x11;
     target.SUB_r(2);
     Assert.IsTrue(target.A == 0x18);
 }
示例#2
0
 public void JimmyTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(0, 0x0000);
     target.DEC_ss(0);
     Assert.IsTrue(target.Get16BitRegisters(0) == 0xffff);
     target.A = 199;
     target.CPL();
     Assert.IsTrue(target.A == 56);
     target.A = 100;
     target.NEG();
     Assert.IsTrue(target.A == 156);
     target.A = 16;
     target.B = 1;
     target.SUB_r(0);
     Assert.IsTrue(target.A == 15 && (target.F & Flag.HalfCarry) == Flag.HalfCarry);
 }
示例#3
0
        public void Arithmetic8BitTest()
        {
            //  8-bit Load group
             PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
            Z80_Accessor target = new Z80_Accessor(param0);
            target.A = 64;
            target.B = 65;
            target.ADD_A_r(0);
            //  129  / -127
            Assert.IsTrue(target.A == 129
                && (target.F & Flag.Carry) != Flag.Carry
                && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);

            target.A = 255;
            target.B = 255;
            target.ADD_A_r(0);
            //  510 -> 254 / -2
            Assert.IsTrue(target.A == 254
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);

            target.A = 192;
            target.B = 191;
            target.ADD_A_r(0);
            //  383 -> 127 / -129 -> 127
            Assert.IsTrue(target.A == 127
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 6;
            target.B = 8;
            target.ADD_A_r(0);
            //  14 / 14
            Assert.IsTrue(target.A == 14
                && (target.F & Flag.Carry) != Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 127;
            target.B = 1;
            target.ADD_A_r(0);
            //  128 / 128 -> -128
            Assert.IsTrue(target.A == 128
                && (target.F & Flag.Carry) != Flag.Carry
                && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);

            target.A = 4;
            target.B = 254;
            target.ADD_A_r(0);
            //  258 -> 2 / -2 -> 2
            Assert.IsTrue(target.A == 2
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 254;
            target.B = 252;
            target.ADD_A_r(0);
            //  506 -> 250 / -6
            Assert.IsTrue(target.A == 250
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);

            target.A = 129;
            target.B = 194;
            target.ADD_A_r(0);
            //  323 -> 67 / -189 -> 67
            Assert.IsTrue(target.A == 67
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 254;
            target.B = 129;
            target.SUB_r(0);
            //  125 / 125
            Assert.IsTrue(target.A == 125
                && (target.F & Flag.Carry) != Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 196;
            target.B = 91;
            target.SUB_r(0);
            //  105 / -151 -> 105
            Assert.IsTrue(target.A == 105
                && (target.F & Flag.Carry) != Flag.Carry
                && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
                && (target.F & Flag.Sign) != Flag.Sign);

            target.A = 12;
            target.B = 60;
            target.SUB_r(0);
            //  -48 -> 208 / -48
            Assert.IsTrue(target.A == 208
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);

            target.A = 146;
            target.B = 231;
            target.SUB_r(0);
            //  -85 -> 171 / -341 -> -85
            Assert.IsTrue(target.A == 171
                && (target.F & Flag.Carry) == Flag.Carry
                && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
                && (target.F & Flag.Sign) == Flag.Sign);
        }