@Test public void shouldIncrementTheValueOfTheMemoryPointedByTheHLRegister() { z80.set16BitRegisterValue(Register.HL, ANY_16BIT_REGISTER_VALUE); when(mmu.readByte(ANY_16BIT_REGISTER_VALUE)).thenReturn(ANY_MEMORY_BYTE_VALUE); Instruction instruction = new DecHLAddress(z80, mmu); instruction.execute(); verify(mmu).writeByte(ANY_16BIT_REGISTER_VALUE, (byte) (ANY_MEMORY_BYTE_VALUE + -1)); }
@Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte result = (byte) (memoryValue - 1); mmu.writeByte(address, result); z80.setLastInstructionExecutionTime(3); boolean wasCEnabled = z80.isFlagCYEnabled(); z80.resetFlagF(); z80.enableFlagN(); if (wasCEnabled) { z80.enableFlagCY(); } if (result == 0) { z80.enableFlagZ(); } if ((result & 0xF) == 0xF) { z80.enableFlagH(); } }
DecHLAddress extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte result = (byte) (memoryValue - 1); mmu.writeByte(address, result); z80.setLastInstructionExecutionTime(3); boolean wasCEnabled = z80.isFlagCYEnabled(); z80.resetFlagF(); z80.enableFlagN(); if (wasCEnabled) { z80.enableFlagCY(); } if (result == 0) { z80.enableFlagZ(); } if ((result & 0xF) == 0xF) { z80.enableFlagH(); } } }
DecHLAddress extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte result = (byte) (memoryValue - 1); mmu.writeByte(address, result); z80.setLastInstructionExecutionTime(3); boolean wasCEnabled = z80.isFlagCYEnabled(); z80.resetFlagF(); z80.enableFlagN(); if (wasCEnabled) { z80.enableFlagCY(); } if (result == 0) { z80.enableFlagZ(); } if ((result & 0xF) == 0xF) { z80.enableFlagH(); } } DecHLAddress(GBZ80 z80, MMU mmu); }
DecHLAddress extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte result = (byte) (memoryValue - 1); mmu.writeByte(address, result); z80.setLastInstructionExecutionTime(3); boolean wasCEnabled = z80.isFlagCYEnabled(); z80.resetFlagF(); z80.enableFlagN(); if (wasCEnabled) { z80.enableFlagCY(); } if (result == 0) { z80.enableFlagZ(); } if ((result & 0xF) == 0xF) { z80.enableFlagH(); } } DecHLAddress(GBZ80 z80, MMU mmu); @Override void execute(); }
DecHLAddress extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte result = (byte) (memoryValue - 1); mmu.writeByte(address, result); z80.setLastInstructionExecutionTime(3); boolean wasCEnabled = z80.isFlagCYEnabled(); z80.resetFlagF(); z80.enableFlagN(); if (wasCEnabled) { z80.enableFlagCY(); } if (result == 0) { z80.enableFlagZ(); } if ((result & 0xF) == 0xF) { z80.enableFlagH(); } } DecHLAddress(GBZ80 z80, MMU mmu); @Override void execute();  }