import pytest from tests.insn.helpers import * @pytest.mark.parametrize("rr", set(R16) - {R16.AF, R16.HL}) def test_add_hl_rr(rr): cpu = CPU() cpu.set_reg16(R16.HL, 0xABCD) cpu.set_reg16(rr, 0x1234) ADD_HL_RR(rr).exec(cpu) assert cpu.get_reg16(R16.HL) == 0xBE01 assert cpu.carry == 0 assert cpu.cycles == 8 cpu.set_reg16(rr, 0xFFFF - 0xBE01 + 1) ADD_HL_RR(rr).exec(cpu) assert cpu.get_reg16(R16.HL) == 0 assert cpu.carry == 1 assert cpu.cycles == 16 @pytest.mark.parametrize("rr", set(R16) - {R16.AF}) def test_inc_rr(rr): cpu = CPU() cpu.set_reg16(rr, 0xABCD) INC_RR(rr).exec(cpu) assert cpu.get_reg16(rr) == 0xABCE assert cpu.cycles == 8 @pytest.mark.parametrize("rr", set(R16) - {R16.AF}) def test_dec_rr(rr): cpu = CPU() cpu.set_reg16(rr, 0xABCD) DEC_RR(rr).exec(cpu) assert cpu.get_reg16(rr) == 0xABCC assert cpu.cycles == 8