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.

43 lines
825 B

  1. import pytest
  2. from tests.insn.helpers import *
  3. @pytest.mark.parametrize("n,r", [(n, r) for n in range(8) for r in R8])
  4. def test_set_n_r(n, r):
  5. cpu = CPU()
  6. SET_N_R(n, r).exec(cpu)
  7. assert cpu.get_reg8(r) == 1 << n
  8. @pytest.mark.parametrize("n", range(8))
  9. def test_set_n_hl(n):
  10. cpu = CPU()
  11. cpu.set_reg16(R16.HL, 0x1234)
  12. SET_N_HL(n).exec(cpu)
  13. assert cpu.hl == 1 << n
  14. @pytest.mark.parametrize("n,r", [(n, r) for n in range(8) for r in R8])
  15. def test_res_n_r(n, r):
  16. cpu = CPU()
  17. cpu.set_reg8(r, 0xFF)
  18. RES_N_R(n, r).exec(cpu)
  19. assert cpu.get_reg8(r) == 0xFF - (1 << n)
  20. @pytest.mark.parametrize("n", range(8))
  21. def test_res_n_hl(n):
  22. cpu = CPU()
  23. cpu.set_reg16(R16.HL, 0x1234)
  24. cpu.set_mem8(0x1234, 0xFF)
  25. RES_N_HL(n).exec(cpu)
  26. assert cpu.hl == 0xFF - (1 << n)