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.

54 lines
1.0 KiB

  1. import pytest
  2. from tests.cpu.insn.helpers import *
  3. @pytest.mark.parametrize("rr", set(R16))
  4. def test_ld_rr_nn(rr):
  5. cpu = CPU()
  6. LD_RR_NN(rr, 0x1234).exec(cpu)
  7. assert cpu.get_reg16(rr) == 0x1234
  8. def test_ld_nn_sp():
  9. cpu = CPU()
  10. cpu.set_reg16(R16.SP, 0xABCD)
  11. LD_NN_SP(0x1234).exec(cpu)
  12. assert cpu.get_mem16(0x1234) == 0xABCD
  13. def test_ld_sp_hl():
  14. cpu = CPU()
  15. cpu.set_reg16(R16.HL, 0x1234)
  16. LD_SP_HL().exec(cpu)
  17. assert cpu.get_reg16(R16.SP) == 0x1234
  18. @pytest.mark.parametrize("rr", R16_WITHOUT_SP)
  19. def test_push_rr(rr):
  20. cpu = CPU()
  21. cpu.set_reg16(R16.SP, 0xFFFF)
  22. cpu.set_reg16(rr, 0x1234)
  23. PUSH_RR(rr).exec(cpu)
  24. assert cpu.get_reg16(R16.SP) == 0xFFFD
  25. assert cpu.get_mem16(0xFFFD) == 0x1234
  26. @pytest.mark.parametrize("rr", R16_WITHOUT_SP)
  27. def test_pop_rr(rr):
  28. cpu = CPU()
  29. cpu.set_reg16(R16.SP, 0xFFFD)
  30. cpu.set_mem16(0xFFFD, 0x1234)
  31. POP_RR(rr).exec(cpu)
  32. assert cpu.get_reg16(R16.SP) == 0xFFFF
  33. assert cpu.get_reg16(rr) == 0x1234