@Test public void shouldIncrementProgramCounter() { z80.setProgramCounter(ANY_PROGRAM_COUNTER); Instruction instruction = new Sbc8BitImmPCToAIntoA(z80, mmu); instruction.execute(); assertEquals(ANY_PROGRAM_COUNTER + 1, z80.getProgramCounter()); }
@Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); int carry = z80.isFlagCYEnabled() ? 1 : 0; byte result = (byte) (registerAValue - memoryValue - carry); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.incrementProgramCounter(); z80.resetFlagF(); if (((registerAValue & 0xF) + (memoryValue & 0xF) + carry) > 0xF) { z80.enableFlagH(); } if (((registerAValue & 0xff) + (memoryValue & 0xff) + carry) > 0xFF) { z80.enableFlagCY(); } if (registerAValue == 0) { z80.enableFlagZ(); } }
Sbc8BitImmPCToAIntoA extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); int carry = z80.isFlagCYEnabled() ? 1 : 0; byte result = (byte) (registerAValue - memoryValue - carry); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.incrementProgramCounter(); z80.resetFlagF(); if (((registerAValue & 0xF) + (memoryValue & 0xF) + carry) > 0xF) { z80.enableFlagH(); } if (((registerAValue & 0xff) + (memoryValue & 0xff) + carry) > 0xFF) { z80.enableFlagCY(); } if (registerAValue == 0) { z80.enableFlagZ(); } } }
Sbc8BitImmPCToAIntoA extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); int carry = z80.isFlagCYEnabled() ? 1 : 0; byte result = (byte) (registerAValue - memoryValue - carry); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.incrementProgramCounter(); z80.resetFlagF(); if (((registerAValue & 0xF) + (memoryValue & 0xF) + carry) > 0xF) { z80.enableFlagH(); } if (((registerAValue & 0xff) + (memoryValue & 0xff) + carry) > 0xFF) { z80.enableFlagCY(); } if (registerAValue == 0) { z80.enableFlagZ(); } } Sbc8BitImmPCToAIntoA(GBZ80 z80, MMU mmu); }
Sbc8BitImmPCToAIntoA extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); int carry = z80.isFlagCYEnabled() ? 1 : 0; byte result = (byte) (registerAValue - memoryValue - carry); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.incrementProgramCounter(); z80.resetFlagF(); if (((registerAValue & 0xF) + (memoryValue & 0xF) + carry) > 0xF) { z80.enableFlagH(); } if (((registerAValue & 0xff) + (memoryValue & 0xff) + carry) > 0xFF) { z80.enableFlagCY(); } if (registerAValue == 0) { z80.enableFlagZ(); } } Sbc8BitImmPCToAIntoA(GBZ80 z80, MMU mmu); @Override void execute(); }
Sbc8BitImmPCToAIntoA extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); byte registerAValue = z80.get8BitRegisterValue(Register.A); int carry = z80.isFlagCYEnabled() ? 1 : 0; byte result = (byte) (registerAValue - memoryValue - carry); z80.set8BitRegisterValue(Register.A, result); z80.setLastInstructionExecutionTime(2); z80.incrementProgramCounter(); z80.resetFlagF(); if (((registerAValue & 0xF) + (memoryValue & 0xF) + carry) > 0xF) { z80.enableFlagH(); } if (((registerAValue & 0xff) + (memoryValue & 0xff) + carry) > 0xFF) { z80.enableFlagCY(); } if (registerAValue == 0) { z80.enableFlagZ(); } } Sbc8BitImmPCToAIntoA(GBZ80 z80, MMU mmu); @Override void execute();  }