Load8BitRegisterAIntoAddressPortRegisterOfC extends Instruction { @Override public void execute() { byte registerValue = z80.get8BitRegisterValue(Register.A); int address = (z80.get8BitRegisterValue(Register.C) & 0xFF) + 0xFF00; mmu.writeByte(address, registerValue); z80.setLastInstructionExecutionTime(2); } Load8BitRegisterAIntoAddressPortRegisterOfC(GBZ80 z80, MMU mmu); @Override void execute();  }
@Test public void shouldLoadTheContentOfAIntoThePortAddressPointedByTheRegisterC() { z80.set8BitRegisterValue(Register.A, ANY_8BIT_REGISTER_VALUE); z80.set8BitRegisterValue(Register.C, ANY_8BIT_REGISTER_VALUE); Instruction instruction = new Load8BitRegisterAIntoAddressPortRegisterOfC(z80, mmu); instruction.execute(); int expectedAddress = (ANY_8BIT_REGISTER_VALUE & 0xFF) + 0xFF00; verify(mmu).writeByte(expectedAddress, ANY_8BIT_REGISTER_VALUE); }
@Test public void shouldUseTwoCyclesAsLastExecutionTime() { Instruction instruction = new Load8BitRegisterAIntoAddressPortRegisterOfC(z80, mmu); instruction.execute(); assertEquals(2, z80.getLastInstructionExecutionTime()); }