Exemplo n.º 1
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");
 }