import pytest
|
|
|
|
from tests.insn.helpers import *
|
|
|
|
|
|
@pytest.mark.parametrize("n,r", [(n, r) for n in range(8) for r in R8])
|
|
def test_set_n_r(n, r):
|
|
cpu = CPU()
|
|
|
|
SET_N_R(n, r).exec(cpu)
|
|
|
|
assert cpu.get_reg8(r) == 1 << n
|
|
assert cpu.cycles == 8
|
|
|
|
|
|
@pytest.mark.parametrize("n", range(8))
|
|
def test_set_n_hl(n):
|
|
cpu = CPU()
|
|
cpu.set_reg16(R16.HL, 0x1234)
|
|
|
|
SET_N_HL(n).exec(cpu)
|
|
|
|
assert cpu.get_mem8(0x1234) == 1 << n
|
|
assert cpu.cycles == 16
|
|
|
|
|
|
@pytest.mark.parametrize("n,r", [(n, r) for n in range(8) for r in R8])
|
|
def test_res_n_r(n, r):
|
|
cpu = CPU()
|
|
cpu.set_reg8(r, 0xFF)
|
|
|
|
RES_N_R(n, r).exec(cpu)
|
|
|
|
assert cpu.get_reg8(r) == 0xFF - (1 << n)
|
|
assert cpu.cycles == 8
|
|
|
|
|
|
@pytest.mark.parametrize("n", range(8))
|
|
def test_res_n_hl(n):
|
|
cpu = CPU()
|
|
cpu.set_reg16(R16.HL, 0x1234)
|
|
cpu.set_mem8(0x1234, 0xFF)
|
|
|
|
RES_N_HL(n).exec(cpu)
|
|
|
|
assert cpu.get_mem8(0x1234) == 0xFF - (1 << n)
|
|
assert cpu.cycles == 16
|