@Test public void shouldIncrementProgramCounter() { z80.setProgramCounter(ANY_16BIT_REGISTER_VALUE); Instruction instruction = new Add16BitRegisterSPPlus8BitImmPCIntoSP(z80, mmu); instruction.execute(); assertEquals(ANY_16BIT_REGISTER_VALUE + 1, z80.getProgramCounter()); }
@Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); int stackPointerValue = z80.getStackPointer(); int sum = (stackPointerValue + memoryValue) & 0xFFFF; z80.setStackPointer(sum); z80.incrementProgramCounter(); z80.setLastInstructionExecutionTime(4); z80.disableFlagZ(); z80.disableFlagN(); int check = stackPointerValue ^ memoryValue ^ ((stackPointerValue + memoryValue) & 0xFFFF); if ((check & 0x100) == 0x100) { z80.enableFlagCY(); } else { z80.disableFlagCY(); } if ((check & 0x10) == 0x10) { z80.enableFlagH(); } else { z80.disableFlagH(); } }
Add16BitRegisterSPPlus8BitImmPCIntoSP extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); int stackPointerValue = z80.getStackPointer(); int sum = (stackPointerValue + memoryValue) & 0xFFFF; z80.setStackPointer(sum); z80.incrementProgramCounter(); z80.setLastInstructionExecutionTime(4); z80.disableFlagZ(); z80.disableFlagN(); int check = stackPointerValue ^ memoryValue ^ ((stackPointerValue + memoryValue) & 0xFFFF); if ((check & 0x100) == 0x100) { z80.enableFlagCY(); } else { z80.disableFlagCY(); } if ((check & 0x10) == 0x10) { z80.enableFlagH(); } else { z80.disableFlagH(); } } }
Add16BitRegisterSPPlus8BitImmPCIntoSP extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); int stackPointerValue = z80.getStackPointer(); int sum = (stackPointerValue + memoryValue) & 0xFFFF; z80.setStackPointer(sum); z80.incrementProgramCounter(); z80.setLastInstructionExecutionTime(4); z80.disableFlagZ(); z80.disableFlagN(); int check = stackPointerValue ^ memoryValue ^ ((stackPointerValue + memoryValue) & 0xFFFF); if ((check & 0x100) == 0x100) { z80.enableFlagCY(); } else { z80.disableFlagCY(); } if ((check & 0x10) == 0x10) { z80.enableFlagH(); } else { z80.disableFlagH(); } } Add16BitRegisterSPPlus8BitImmPCIntoSP(GBZ80 z80, MMU mmu); }
Add16BitRegisterSPPlus8BitImmPCIntoSP extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); int stackPointerValue = z80.getStackPointer(); int sum = (stackPointerValue + memoryValue) & 0xFFFF; z80.setStackPointer(sum); z80.incrementProgramCounter(); z80.setLastInstructionExecutionTime(4); z80.disableFlagZ(); z80.disableFlagN(); int check = stackPointerValue ^ memoryValue ^ ((stackPointerValue + memoryValue) & 0xFFFF); if ((check & 0x100) == 0x100) { z80.enableFlagCY(); } else { z80.disableFlagCY(); } if ((check & 0x10) == 0x10) { z80.enableFlagH(); } else { z80.disableFlagH(); } } Add16BitRegisterSPPlus8BitImmPCIntoSP(GBZ80 z80, MMU mmu); @Override void execute(); }
Add16BitRegisterSPPlus8BitImmPCIntoSP extends Instruction { @Override public void execute() { int address = z80.getProgramCounter(); byte memoryValue = mmu.readByte(address); int stackPointerValue = z80.getStackPointer(); int sum = (stackPointerValue + memoryValue) & 0xFFFF; z80.setStackPointer(sum); z80.incrementProgramCounter(); z80.setLastInstructionExecutionTime(4); z80.disableFlagZ(); z80.disableFlagN(); int check = stackPointerValue ^ memoryValue ^ ((stackPointerValue + memoryValue) & 0xFFFF); if ((check & 0x100) == 0x100) { z80.enableFlagCY(); } else { z80.disableFlagCY(); } if ((check & 0x10) == 0x10) { z80.enableFlagH(); } else { z80.disableFlagH(); } } Add16BitRegisterSPPlus8BitImmPCIntoSP(GBZ80 z80, MMU mmu); @Override void execute();  }