Load16BitRegisterHLIntoSP extends Instruction { @Override public void execute() { int registerValue = z80.get16BitRegisterValue(Register.HL); z80.setStackPointer(registerValue); z80.setLastInstructionExecutionTime(2); } Load16BitRegisterHLIntoSP(GBZ80 z80); @Override void execute();  }
@Test public void shouldUseTwoCyclesAsLastInstructionExecutionTime() { Instruction instruction = new Load16BitRegisterHLIntoSP(z80); instruction.execute(); assertEquals(2, z80.getLastInstructionExecutionTime()); }
@Test public void shouldUpdateStackPointerWithTheValueOfTheRegisterHL() { z80.set16BitRegisterValue(Register.HL, ANY_16BIT_REGISTER_VALUE); Instruction instruction = new Load16BitRegisterHLIntoSP(z80); instruction.execute(); assertEquals(ANY_16BIT_REGISTER_VALUE, z80.getStackPointer()); }