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.

47 lines
959 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. assert cpu.state.cycles == 8
  9. @pytest.mark.parametrize("n", range(8))
  10. def test_set_n_hl(n):
  11. cpu = CPU()
  12. cpu.set_reg16(R16.HL, 0x1234)
  13. SET_N_HL(n).exec(cpu)
  14. assert cpu.hl == 1 << n
  15. assert cpu.state.cycles == 16
  16. @pytest.mark.parametrize("n,r", [(n, r) for n in range(8) for r in R8])
  17. def test_res_n_r(n, r):
  18. cpu = CPU()
  19. cpu.set_reg8(r, 0xFF)
  20. RES_N_R(n, r).exec(cpu)
  21. assert cpu.get_reg8(r) == 0xFF - (1 << n)
  22. assert cpu.state.cycles == 8
  23. @pytest.mark.parametrize("n", range(8))
  24. def test_res_n_hl(n):
  25. cpu = CPU()
  26. cpu.set_reg16(R16.HL, 0x1234)
  27. cpu.set_mem8(0x1234, 0xFF)
  28. RES_N_HL(n).exec(cpu)
  29. assert cpu.hl == 0xFF - (1 << n)
  30. assert cpu.state.cycles == 16