Load8BitRegisterInto8BitRegister extends Instruction { @Override public void execute() { byte registerValue = z80.get8BitRegisterValue(sourceRegister); z80.set8BitRegisterValue(destinyRegister, registerValue); z80.setLastInstructionExecutionTime(1); } Load8BitRegisterInto8BitRegister(GBZ80 z80, Register destinyRegister, Register sourceRegister); @Override void execute();  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAccept16BitRegistersAsSource() { Instruction load8BitRegister = new Load8BitRegisterInto8BitRegister(z80, ANY_8BIT_DESTINY_REGISTER, ANY_16BIT_SOURCE_REGISTER); load8BitRegister.execute(); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAccept16BitRegistersAsDestiny() { Instruction load8BitRegister = new Load8BitRegisterInto8BitRegister(z80, ANY_16BIT_DESTINY_REGISTER, ANY_8BIT_SOURCE_REGISTER); load8BitRegister.execute(); }
@Test public void shouldLoadSourceRegisterIntoDestinyRegister() { z80.set8BitRegisterValue(ANY_8BIT_SOURCE_REGISTER, ANY_8BIT_REGISTER_VALUE); Instruction load8BitRegister = new Load8BitRegisterInto8BitRegister(z80, ANY_8BIT_DESTINY_REGISTER, ANY_8BIT_SOURCE_REGISTER); load8BitRegister.execute(); assertEquals(ANY_8BIT_REGISTER_VALUE, z80.get8BitRegisterValue(ANY_8BIT_DESTINY_REGISTER)); }
@Test public void shouldNotModifyTheSourceRegister() { z80.set8BitRegisterValue(ANY_8BIT_SOURCE_REGISTER, ANY_8BIT_REGISTER_VALUE); Instruction load8BitRegister = new Load8BitRegisterInto8BitRegister(z80, ANY_8BIT_DESTINY_REGISTER, ANY_8BIT_SOURCE_REGISTER); load8BitRegister.execute(); assertEquals(ANY_8BIT_REGISTER_VALUE, z80.get8BitRegisterValue(ANY_8BIT_SOURCE_REGISTER)); }
@Test public void shouldUseOneCycleAsExecutionTime() { Instruction load8BitRegister = new Load8BitRegisterInto8BitRegister(z80, ANY_8BIT_DESTINY_REGISTER, ANY_8BIT_SOURCE_REGISTER); load8BitRegister.execute(); assertEquals(1, z80.getLastInstructionExecutionTime()); }