@Test public void shouldSubTheContentOfTheMemoryAddressPointedByTheHLRegisterAndStoreTheResultIntoA() { z80.set16BitRegisterValue(Register.HL, ANY_16BIT_REGISTER_VALUE); when(mmu.readByte(ANY_16BIT_REGISTER_VALUE)).thenReturn(ANY_MEMORY_BYTE_VALUE); z80.set8BitRegisterValue(Register.A, (byte) (ANY_MEMORY_BYTE_VALUE + 1)); Instruction instruction = new Sub8BitAddressHLToAIntoA(z80, mmu); instruction.execute(); assertEquals(1, z80.get8BitRegisterValue(Register.A)); }
@Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); byte result = (byte) (registerAValue - memoryValue); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.resetFlagF(); z80.enableFlagN(); if (result == 0) { z80.enableFlagZ(); } if (((result & 0xF) < (memoryValue & 0xF))) { z80.enableFlagH(); } if ((result & 0xff) < (memoryValue & 0xff)) { z80.enableFlagCY(); } }
Sub8BitAddressHLToAIntoA extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); byte result = (byte) (registerAValue - memoryValue); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.resetFlagF(); z80.enableFlagN(); if (result == 0) { z80.enableFlagZ(); } if (((result & 0xF) < (memoryValue & 0xF))) { z80.enableFlagH(); } if ((result & 0xff) < (memoryValue & 0xff)) { z80.enableFlagCY(); } } }
Sub8BitAddressHLToAIntoA extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); byte result = (byte) (registerAValue - memoryValue); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.resetFlagF(); z80.enableFlagN(); if (result == 0) { z80.enableFlagZ(); } if (((result & 0xF) < (memoryValue & 0xF))) { z80.enableFlagH(); } if ((result & 0xff) < (memoryValue & 0xff)) { z80.enableFlagCY(); } } Sub8BitAddressHLToAIntoA(GBZ80 z80, MMU mmu); }
Sub8BitAddressHLToAIntoA extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); byte result = (byte) (registerAValue - memoryValue); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.resetFlagF(); z80.enableFlagN(); if (result == 0) { z80.enableFlagZ(); } if (((result & 0xF) < (memoryValue & 0xF))) { z80.enableFlagH(); } if ((result & 0xff) < (memoryValue & 0xff)) { z80.enableFlagCY(); } } Sub8BitAddressHLToAIntoA(GBZ80 z80, MMU mmu); @Override void execute(); }
Sub8BitAddressHLToAIntoA extends Instruction { @Override public void execute() { int address = z80.get16BitRegisterValue(Register.HL); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); byte result = (byte) (registerAValue - memoryValue); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.resetFlagF(); z80.enableFlagN(); if (result == 0) { z80.enableFlagZ(); } if (((result & 0xF) < (memoryValue & 0xF))) { z80.enableFlagH(); } if ((result & 0xff) < (memoryValue & 0xff)) { z80.enableFlagCY(); } } Sub8BitAddressHLToAIntoA(GBZ80 z80, MMU mmu); @Override void execute();  }