So since the last post, I have been working my way through the Load Operations, which follow a very similar format to the ones we have already discussed.
However, the next operation I need to add is LD A, (nn
); which means populate the Accumulator register with the value in the memory address nn where nn is the operands of the operation.
When the address to use is specified as the operands of the operation it is known as Extended Addressing.
Addresses in the Z80 Architecture are made up of 16 Bits, which allows them to have a much greater addressable space (More Memory) than using just 8 Bits.
In terms of actually implementing this, it's very similar to the memory load operation we have already done, but instead of loading the values into registers, first we can simply get the address from the operands.
[TestMethod]
public void LoadNNAddressValueIntoA()
{
var memory = new ListOfActionsMemory();
var cpu = new CPU(memory);
var lowByte = new ZByte(Bit.Zero, Bit.One, Bit.Zero, Bit.Zero, Bit.Zero, Bit.Zero, Bit.One, Bit.Zero);
var highByte = new ZByte(Bit.Zero, Bit.Zero, Bit.Zero, Bit.One, Bit.One, Bit.One, Bit.Zero, Bit.Zero);
var value = new ZByte(Bit.Zero, Bit.One, Bit.Zero, Bit.One, Bit.Zero, Bit.One, Bit.Zero, Bit.Zero);
memory.ReadValues.Add(new SixteenBitAddress(highByte, lowByte), value);
cpu.PerformInstruction(LoadCommand.NNIntoA, lowByte, highByte);
cpu.PerformInstruction(LoadCommand.AIntoMemory, null, null);
Assert.AreEqual(value, memory.Saved[0].Item2);
}
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.