コード例 #1
0
ファイル: Z80Test.cs プロジェクト: jo215/ZXSpectrum
 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");
 }
コード例 #2
0
ファイル: Z80Test.cs プロジェクト: jo215/ZXSpectrum
 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");
 }