Example #1
0
 public void CALL_cc_nnTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     target.Reset(Flag.Carry);
     target.PC = 0x1a48;
     target.SP = 0x3002;
     target.Memory[0x1a47] = 0xd4;
     target.Memory[0x1a48] = 0x35;
     target.Memory[0x1a49] = 0x21;
     target.CALL_cc_nn(2);
     Assert.IsTrue(target.Memory[0x3001] == 0x1a
         && target.Memory[0x3000] == 0x4a
         && target.SP == 0x3000
         && target.PC == 0x2135, "Error: CALL cc, nn");
 }
Example #2
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");
 }
Example #3
0
 public void SCFTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Reset(Flag.Carry);
     target.SCF();
     Assert.IsTrue((target.F & Flag.Carry) == Flag.Carry, "Error: SCF");
 }
Example #4
0
 public void RLTest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.Reset(Flag.Carry);
     target.D = 128 + 15;
     target.RL(2);
     Assert.IsTrue((target.F & Flag.Carry) == Flag.Carry && target.D == 30, "Error: RL");
 }
Example #5
0
 public void RRATest()
 {
     PrivateObject z = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(z);
     target.A = 0xe1;
     target.Reset(Flag.Carry);
     target.RRA();
     Assert.IsTrue(target.A == 0x70 && (target.F & Flag.Carry) == Flag.Carry, "Error: RRA");
 }
Example #6
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");
 }
Example #7
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");
 }
Example #8
0
 public void LD_DE_ATest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the contents of register pair DE are 1128H, and the Accumulator contains
     //  byte A0H, the instruction LD (DE), A results in A0H in memory location
     //  1128H.
     target.Reset();
     target.Set16BitRegisters(1, 0x1128);
     target.A = 0xa0;
     target.LD_DE_A();
     Assert.IsTrue(target.Memory[0x1128] == 0xa0, "Error: LD (DE), A");
 }
Example #9
0
 public void LD_BC_ATest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the Accumulator contains 7AH and the BC register pair contains 1212H
     //  the instruction LD (BC), A results in 7AH in memory location 1212H.
     target.Reset();
     target.A = 0x7a;
     target.Set16BitRegisters(0, 0x1212);
     target.LD_BC_A();
     Assert.IsTrue(target.Memory[0x1212] == 0x7a, "Error: LD (BC), A");
 }
Example #10
0
 public void LD_A_nnTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the contents of nn is number 8832H, and the content of memory address
     //  8832H is byte 04H, at instruction LD A, (nn) byte 04H is in the
     //  Accumulator.
     target.Reset();
     target.Memory[0] = 0x32;
     target.Memory[1] = 0x88;
     target.Memory[0x8832] = 0x04;
     target.LD_A_nn();
     Assert.IsTrue(target.A == 0x04, "Error: LD A, (nn)");
 }
Example #11
0
 public void LD_A_DETest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the DE register pair contains the number 30A2H and memory address
     //  30A2H contains byte 22H, then the instruction LD A, (DE) results in byte
     //  22H in register A.
     target.Reset();
     target.Set16BitRegisters(1, 0x30a2);
     target.Memory[0x30a2] = 0x22;
     target.LD_A_DE();
     Assert.IsTrue(target.A == 0x22, "Error: LD A, (DE)");
 }
Example #12
0
 public void LD_A_BCTest()
 {
     PrivateObject param0 = new PrivateObject(new Z80(new Memory48K()));
     Z80_Accessor target = new Z80_Accessor(param0);
     //  If the BC register pair contains the number 4747H, and memory address
     //  4747H contains byte 12H, then the instruction LD A, (BC) results in byte
     //  12H in register A.
     target.Reset();
     target.Set16BitRegisters(0, 0x4747);
     target.Memory[0x4747] = 0x12;
     target.LD_A_BC();
     Assert.IsTrue(target.A == 0x12, "Error: LD A, (BC)");
 }