Dec16BitRegister extends Instruction { @Override public void execute() { int registerValue = z80.get16BitRegisterValue(destinyRegister); z80.set16BitRegisterValue(destinyRegister, registerValue - 1); z80.setLastInstructionExecutionTime(2); } Dec16BitRegister(GBZ80 z80, Register destinyRegister); @Override void execute();  }
@Test public void shouldUseTwoCyclesAsLastInstructionExecutionTime() { Instruction instruction = new Dec16BitRegister(z80, ANY_16BIT_DESTINY_REGISTER); instruction.execute(); assertEquals(2, z80.getLastInstructionExecutionTime()); }
@Test public void shouldDecrementTheValueOfTheDestinyRegister() { z80.set16BitRegisterValue(ANY_16BIT_DESTINY_REGISTER, ANY_16BIT_REGISTER_VALUE); Instruction instruction = new Dec16BitRegister(z80, ANY_16BIT_DESTINY_REGISTER); instruction.execute(); assertEquals(ANY_16BIT_REGISTER_VALUE - 1, z80.get16BitRegisterValue(ANY_16BIT_DESTINY_REGISTER)); }