gameboy superoptimizer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
933 B

  1. import pytest
  2. from tests.insn.helpers import *
  3. @pytest.mark.parametrize("rr", set(R16) - {R16.AF, R16.HL})
  4. def test_add_hl_rr(rr):
  5. cpu = CPU()
  6. cpu.set_reg16(R16.HL, 0xABCD)
  7. cpu.set_reg16(rr, 0x1234)
  8. ADD_HL_RR(rr).exec(cpu)
  9. assert cpu.get_reg16(R16.HL) == 0xBE01
  10. assert cpu.carry == 0
  11. assert cpu.cycles == 8
  12. cpu.set_reg16(rr, 0xFFFF - 0xBE01 + 1)
  13. ADD_HL_RR(rr).exec(cpu)
  14. assert cpu.get_reg16(R16.HL) == 0
  15. assert cpu.carry == 1
  16. assert cpu.cycles == 16
  17. @pytest.mark.parametrize("rr", set(R16) - {R16.AF})
  18. def test_inc_rr(rr):
  19. cpu = CPU()
  20. cpu.set_reg16(rr, 0xABCD)
  21. INC_RR(rr).exec(cpu)
  22. assert cpu.get_reg16(rr) == 0xABCE
  23. assert cpu.cycles == 8
  24. @pytest.mark.parametrize("rr", set(R16) - {R16.AF})
  25. def test_dec_rr(rr):
  26. cpu = CPU()
  27. cpu.set_reg16(rr, 0xABCD)
  28. DEC_RR(rr).exec(cpu)
  29. assert cpu.get_reg16(rr) == 0xABCC
  30. assert cpu.cycles == 8