Load8BitPortRegisterOfCAddressIntoA extends Instruction { @Override public void execute() { int address = (z80.get8BitRegisterValue(Register.C) & 0xFF) + 0xFF00; byte memoryValue = mmu.readByte(address); z80.set8BitRegisterValue(Register.A, memoryValue); z80.setLastInstructionExecutionTime(2); } Load8BitPortRegisterOfCAddressIntoA(GBZ80 z80, MMU mmu); @Override void execute();  }
@Test public void shouldLoad8BitPortRegisterOfCAddressIntoA() { z80.set8BitRegisterValue(Register.C, ANY_8BIT_REGISTER_VALUE); int address = (ANY_8BIT_REGISTER_VALUE & 0xFF) + 0XFF00; when(mmu.readByte(address)).thenReturn(ANY_MEMORY_BYTE_VALUE); Instruction instruction = new Load8BitPortRegisterOfCAddressIntoA(z80, mmu); instruction.execute(); assertEquals(ANY_MEMORY_BYTE_VALUE, z80.get8BitRegisterValue(Register.A)); }
@Test public void shouldUseTwoCyclesAsLastExecutionTime() { Instruction instruction = new Load8BitPortRegisterOfCAddressIntoA(z80, mmu); instruction.execute(); assertEquals(2, z80.getLastInstructionExecutionTime()); }