Exemplo n.º 1
0
 public void ADC_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(0, 0x16);
     target.Set(Flag.Carry);
     target.Set16BitRegisters(2, 0x10);
     target.ADC_HL(0);
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x27, "Error: ADC HL");
 }
Exemplo n.º 2
0
 public void ADD_HL_ssTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x4242);
     target.Set16BitRegisters(1, 0x1111);
     target.ADD_HL_ss(1);
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x5353, "Error: ADD HL ss");
 }
Exemplo n.º 3
0
 public void LDDTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x1111);
     target.Memory[0x1111] = 0x88;
     target.Set16BitRegisters(1, 0x2222);
     target.Memory[0x2222] = 0x66;
     target.Set16BitRegisters(0, 0x7);
     target.LDD();
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x1110
         && target.Memory[0x1111] == 0x88
         && target.Get16BitRegisters(1) == 0x2221
         && target.Memory[0x2222] == 0x88
         && target.Get16BitRegisters(0) == 0x6, "Error: LDD");
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public void EX_SP_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x7012);
     target.SP = 0x8856;
     target.Memory[0x8856] = 0x11;
     target.Memory[0x8857] = 0x22;
     target.EX_SP_HL();
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x2211
         && target.Memory[0x8856] == 0x12
         && target.Memory[0x8857] == 0x70
         && target.SP == 0x8856, "Error: EX (SP), HL");
 }
Exemplo n.º 6
0
 public void CPITest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x1111);
     target.Memory[0x1111] = 0x3b;
     target.A = 0x3b;
     target.Set16BitRegisters(0, 0x0001);
     target.CPI();
     Assert.IsTrue(target.Get16BitRegisters(0) == 0
         && target.Get16BitRegisters(2) == 0x1112
         && (target.F & Flag.Zero) == Flag.Zero
         && (target.F & Flag.ParityOverflow) != Flag.ParityOverflow
         && target.A == 0x3b
         && target.Memory[0x1111] == 0x3b, "Error: CPI");
 }
Exemplo n.º 7
0
 public void EXXTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(0, 0x0988);
     target.Set16BitRegisters(1, 0x9300);
     target.Set16BitRegisters(2, 0x00e7);
     target.EXX();
     target.Set16BitRegisters(0, 0x445a);
     target.Set16BitRegisters(1, 0x3da2);
     target.Set16BitRegisters(2, 0x8859);
     target.EXX();
     Assert.IsTrue(target.Get16BitRegisters(0) == 0x0988
         && target.Get16BitRegisters(1) == 0x9300
         && target.Get16BitRegisters(2) == 0x00e7, "Error: EXX");
 }
Exemplo n.º 8
0
 public void OUTITest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.C = 0x07;
     target.B = 0x10;
     target.Set16BitRegisters(2, 0x1000);
     target.Memory[0x1000] = 0x59;
     target.OUTI();
     Assert.IsTrue(target.B == 0x0f && target.Get16BitRegisters(2) == 0x1001, "Error: OUTI");
 }
Exemplo n.º 9
0
 public void RLCTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Set16BitRegisters(2, 0x5828);
     target.Memory[0x5828] = 0x88;
     target.RLC(6);
     Assert.IsTrue((target.F & Flag.Carry) == Flag.Carry && target.Memory[0x5828] == 0x11, "Error: RLC(HL)");
 }
Exemplo n.º 10
0
 public void LD_SP_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x442e);
     target.LD_SP_HL();
     Assert.IsTrue(target.SP == 0x442e, "Error: LD SP, HL");
 }
Exemplo n.º 11
0
 public void OTIRTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.C = 0x07;
     target.B = 0x03;
     target.Set16BitRegisters(2, 0x1000);
     target.Memory[0x1000] = 0x51;
     target.Memory[0x1001] = 0xa9;
     target.Memory[0x1002] = 0x03;
     //  Simulate PC-=2 (repeat instruction)
     target.OTIR();
     target.OTIR();
     target.OTIR();
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x1003 && target.B == 0, "Error: OTIR");
 }
Exemplo n.º 12
0
 public void LD_r_rTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the H register contains the number 8AH, and the E register contains 10H,
     //  the instruction LD H, E results in both registers containing 10H.
     target.H = 0x8a;
     target.E = 0x10;
     target.LD_r_r(4, 3);
     Assert.IsTrue(target.GetRegister(4) == 0x10 && target.GetRegister(3) == 0x10, "Error: LD r, r");
     //  If register pair HL contains the number 75A1H, and memory address
     //  75A1H contains byte 58H, the execution of LD C, (HL) results in 58H in
     //  register C.
     target.Reset();
     target.Set16BitRegisters(2, 0x75a1);
     target.Memory[0x75a1] = 0x58;
     target.LD_r_r(1, 6);
     Assert.IsTrue(target.GetRegister(1) == 0x58, "Error: LD r, (HL)");
     //  If the Index Register IX contains the number 25AFH, the instruction LD B,
     //  (IX+19H) causes the calculation of the sum 25AFH + 19H, which points
     //  to memory location 25C8H. If this address contains byte 39H, the
     //  instruction results in register B also containing 39H.
     target.Reset();
     target.prefix = 0xDD;
     target.Set16BitRegisters(2, 0x25AF);
     target.Memory[0] = 0x19;
     target.Memory[0x25C8] = 0x39;
     target.LD_r_r(0, 6);
     Assert.IsTrue(target.GetRegister(0) == 0x39, "Error: LD r, (IX+d)");
     //  If the Index Register IY contains the number 25AFH, the instruction
     //  LD B, (IY+19H) causes the calculation of the sum 25AFH + 19H, which
     //  points to memory location 25C8H. If this address contains byte 39H, the
     //  instruction results in register B also containing 39H.
     target.Reset();
     target.prefix = 0xFD;
     target.Set16BitRegisters(2, 0x25AF);
     target.Memory[0] = 0x19;
     target.Memory[0x25C8] = 0x39;
     target.LD_r_r(0, 6);
     Assert.IsTrue(target.GetRegister(0) == 0x39, "Error: LD r, (IY+d)");
     //  If the contents of register pair HL specifies memory location 2146H, and
     //  the B register contains byte 29H, at execution of LD (HL), B memory
     //  address 2146H also contains 29H.
     target.Reset();
     target.Set16BitRegisters(2, 0x2146);
     target.B = 0x29;
     target.LD_r_r(6, 0);
     Assert.IsTrue(target.Memory[0x2146] == 0x29, "Error: LD (HL), r");
     //  If the C register contains byte 1CH, and the Index Register IX contains
     //  3100H, then the instruction LID (IX+6H), C performs the sum 3100H+
     //  6H and loads 1CH to memory location 3106H.
     target.Reset();
     target.prefix = 0xDD;
     target.C = 0x1C;
     target.Set16BitRegisters(2, 0x3100);
     target.Memory[0] = 0x6;
     target.LD_r_r(6, 1);
     Assert.IsTrue(target.Memory[0x3106] == 0x1C, "Error: LD (IX+d), r");
     //  If the C register contains byte 48H, and the Index Register IY contains
     //  2A11H, then the instruction LD (IY+4H), C performs the sum 2A11H+
     //  4H, and loads 48Hto memory location 2A15.
     target.Reset();
     target.prefix = 0xFD;
     target.C = 0x48;
     target.Set16BitRegisters(2, 0x2A11);
     target.Memory[0] = 0x4;
     target.LD_r_r(6, 1);
     Assert.IsTrue(target.Memory[0x2A15] == 0x48, "Error: LD (IY+d), r");
 }
Exemplo n.º 13
0
 public void LD_r_nTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  At execution of LD E, A5H the contents of register E are A5H.
     target.Memory[0] = 0xa5;
     target.LD_r_n(4);
     Assert.IsTrue(target.GetRegister(4) == 0xa5, "Error: LD E, n");
     //  If the HL register pair contains 4444H, the instructionLD (HL), 28H
     //  results in the memory location 4444Hcontaining byte 28H.
     target.Reset();
     target.Set16BitRegisters(2, 0x4444);
     target.Memory[0] = 0x28;
     target.LD_r_n(6);
     Assert.IsTrue(target.Memory[0x4444] == 0x28, "Error: LD (HL), n");
     //  If the Index Register IX contains the number 219AH, the instruction
     //  LD (IX+5H), 5AH results in byte 5AHin the memory address 219AH.
     target.Reset();
     target.prefix = 0xdd;
     target.Set16BitRegisters(2, 0x219a);
     target.Memory[0] = 0x5;
     target.Memory[1] = 0x5a;
     target.LD_r_n(6);
     Assert.IsTrue(target.Memory[0x219a] != 0x5a, "Error: LD (IX+d), n");
     //  If the Index Register IY contains the number A940H, the instruction
     //  LD (IY+10H), 97H results in byte 97Hin memory location A940H.
     target.Reset();
     target.prefix = 0xfd;
     target.Set16BitRegisters(2, 0xa940);
     target.Memory[0] = 0x10;
     target.Memory[1] = 0x97;
     target.LD_r_n(6);
     Assert.IsTrue(target.Memory[0xa940] != 0x97, "Error: LD (IY+d), n");
 }
Exemplo n.º 14
0
 public void LD_nn_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x483a);
     target.Memory[0] = 0x29;
     target.Memory[1] = 0xb2;
     target.LD_nn_HL();
     Assert.IsTrue(target.Memory[0xb229] == 0x3a
         && target.Memory[0xb22a] == 0x48, "Error: LD (nn), HL");
 }
Exemplo n.º 15
0
 public void ZeroTest()
 {
     //  8-bit Load group
      PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.I = 3;
     target.LD_A_I();
     Assert.IsTrue((target.F & Flag.Zero) != Flag.Zero);
     target.I = 0;
     target.LD_A_I();
     Assert.IsTrue((target.F & Flag.Zero) == Flag.Zero);
     target.R = 3;
     target.LD_A_R();
     Assert.IsTrue((target.F & Flag.Zero) != Flag.Zero);
     target.R = 0;
     target.LD_A_R();
     Assert.IsTrue((target.F & Flag.Zero) == Flag.Zero);
     //  Search Group
     target.A = 3;
     target.Set16BitRegisters(2, 0x1000);
     target.Memory[0x1000] = 3;
     target.CPI();
     Assert.IsTrue((target.F & Flag.Zero) == Flag.Zero);
     target.A = 4;
     target.CPI();
     Assert.IsTrue((target.F & Flag.Zero) != Flag.Zero);
 }
Exemplo n.º 16
0
 public void RLDTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Set16BitRegisters(2, 0x5000);
     target.A = 0x7a;
     target.Memory[0x5000] = 0x31;
     target.RLD();
     Assert.IsTrue(target.A == 0x73 && target.Memory[0x5000] == 0x1a, "Error: RLD");
 }
Exemplo n.º 17
0
 public void CPIRTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x1111);
     target.A = 0xf3;
     target.Set16BitRegisters(0, 0x0007);
     target.Memory[0x1111] = 0x52;
     target.Memory[0x1112] = 0x00;
     target.Memory[0x1113] = 0xf3;
     target.CPIR();
     target.CPIR();
     target.CPIR();
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x1114
         && target.Get16BitRegisters(0) == 0x0004
         && (target.F & Flag.ParityOverflow) == Flag.ParityOverflow
         && (target.F & Flag.Zero) == Flag.Zero, "Error: CPIR");
 }
Exemplo n.º 18
0
 public void RRDTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Set16BitRegisters(2, 0x5000);
     target.A = 0x84;
     target.Memory[0x5000] = 0x20;
     target.RRD();
     Assert.IsTrue(target.A == 128 && target.Memory[0x5000] == 0x42, "Error: RRD");
 }
Exemplo n.º 19
0
 public void CP_rTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.A = 0x63;
     target.Set16BitRegisters(2, 0x6000);
     target.Memory[0x6000] = 0x60;
     target.CP_r(6);
     Assert.IsTrue((target.F & Flag.Zero) != Flag.Zero, "Error: CP r");
 }
Exemplo n.º 20
0
 public void RRTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Set16BitRegisters(2, 0x4343);
     target.Memory[0x4343] = 0xdd;
     target.Reset(Flag.Carry);
     target.RR(6);
     Assert.IsTrue(target.Memory[0x4343] == 0x6e && (target.F & Flag.Carry) == Flag.Carry, "Error: RR");
 }
Exemplo n.º 21
0
 public void EX_DE_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(1, 0x2822);
     target.Set16BitRegisters(2, 0x499a);
     target.EX_DE_HL();
     Assert.IsTrue(target.Get16BitRegisters(1) == 0x499a
         && target.Get16BitRegisters(2) == 0x2822, "Error: EX DE, HL");
 }
Exemplo n.º 22
0
 public void SBC_A_rTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.A = 0x16;
     target.Set(Flag.Carry);
     target.Set16BitRegisters(2, 0x5433);
     target.Memory[0x5433] = 0x05;
     target.SBC_A_r(6);
     Assert.IsTrue(target.A == 0x10, "Error: SBC A r");
 }
Exemplo n.º 23
0
 public void INC_ssTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x1000);
     target.INC_ss(2);
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x1001, "Error: INC ss");
 }
Exemplo n.º 24
0
 public void SBC_HLTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Set16BitRegisters(2, 0x9999);
     target.Set16BitRegisters(1, 0x1111);
     target.Set(Flag.Carry);
     target.SBC_HL(1);
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x8887, "Error: SBC HL, ss");
 }
Exemplo n.º 25
0
 public void INITest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.C = 0x07;
     target.B = 0x10;
     target.Set16BitRegisters(2, 0x1000);
     target.INI();
     Assert.IsTrue(target.Memory[0x1000] == 0xc1
         && target.Get16BitRegisters(2) == 0x1001
         && target.B == 0x0f, "Error: INI");
 }
Exemplo n.º 26
0
 public void SRATest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.prefix = 0xdd;
     target.Set16BitRegisters(2, 0x5000);
     target.Memory[0x5003] = 0xb8;
     target.displacement = 3;
     target.SRA(6);
     Assert.IsTrue(target.Memory[0x5003] == 0xdc && (target.F & Flag.Carry) != Flag.Carry, "Error: SRA");
 }
Exemplo n.º 27
0
 public void JP_HLTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.PC = 0x1000;
     target.Set16BitRegisters(2, 0x4800);
     target.JP_HL();
     Assert.IsTrue(target.PC == 0x4800, "Error: JP (HL)");
 }
Exemplo n.º 28
0
        public void StackTest()
        {
            PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
            Z80_Accessor target = new Z80_Accessor(param0);
            target.Set16BitRegisters(0, 0x1234);
            Assert.IsTrue(target.B == 0x12
                && target.C == 0x34);

            target.SP = 0x504;
            target.PUSH_qq(0);

            Assert.IsTrue(target.Memory[0x503] == 0x12
                    && target.Memory[0x502] == 0x34
                    && target.SP == 0x502);

            target.LD_dd_nn(0);
            target.POP_qq(0);
            Assert.IsTrue(target.B == 0x12
                && target.C == 0x34
                && target.SP == 0x504);
        }
Exemplo n.º 29
0
 public void LDIRTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(2, 0x1111);
     target.Set16BitRegisters(1, 0x2222);
     target.Set16BitRegisters(0, 0x0003);
     target.Memory[0x1111] = 0x88;
     target.Memory[0x1112] = 0x36;
     target.Memory[0x1113] = 0xa5;
     target.Memory[0x2222] = 0x66;
     target.Memory[0x2223] = 0x59;
     target.Memory[0x2224] = 0xc5;
     target.LDIR();
     target.LDIR();
     target.LDIR();
     Assert.IsTrue(target.Get16BitRegisters(2) == 0x1114
         && target.Get16BitRegisters(1) == 0x2225
         && target.Get16BitRegisters(0) == 0x0000
         && target.Memory[0x1111] == 0x88
         && target.Memory[0x1112] == 0x36
         && target.Memory[0x1113] == 0xa5
         && target.Memory[0x2222] == 0x88
         && target.Memory[0x2223] == 0x36
         && target.Memory[0x2224] == 0xa5, "Error: LDIR");
 }
Exemplo n.º 30
0
 public void LD_nn_ddTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Set16BitRegisters(0, 0x4644);
     target.Memory[0] = 0x00;
     target.Memory[1] = 0x10;
     target.LD_nn_dd(0);
     Assert.IsTrue(target.Memory[0x1000] == 0x44
         && target.Memory[0x1001] == 0x46, "Error: LD (nn), dd");
 }