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

import pytest
from tests.cpu.insn.helpers import *
@pytest.mark.parametrize("rr", set(R16))
def test_ld_rr_nn(rr):
cpu = CPU()
LD_RR_NN(rr, 0x1234).exec(cpu)
assert cpu.get_reg16(rr) == 0x1234
def test_ld_nn_sp():
cpu = CPU()
cpu.set_reg16(R16.SP, 0xABCD)
LD_NN_SP(0x1234).exec(cpu)
assert cpu.get_mem16(0x1234) == 0xABCD
def test_ld_sp_hl():
cpu = CPU()
cpu.set_reg16(R16.HL, 0x1234)
LD_SP_HL().exec(cpu)
assert cpu.get_reg16(R16.SP) == 0x1234
@pytest.mark.parametrize("rr", R16_WITHOUT_SP)
def test_push_rr(rr):
cpu = CPU()
cpu.set_reg16(R16.SP, 0xFFFF)
cpu.set_reg16(rr, 0x1234)
PUSH_RR(rr).exec(cpu)
assert cpu.get_reg16(R16.SP) == 0xFFFD
assert cpu.get_mem16(0xFFFD) == 0x1234
@pytest.mark.parametrize("rr", R16_WITHOUT_SP)
def test_pop_rr(rr):
cpu = CPU()
cpu.set_reg16(R16.SP, 0xFFFD)
cpu.set_mem16(0xFFFD, 0x1234)
POP_RR(rr).exec(cpu)
assert cpu.get_reg16(R16.SP) == 0xFFFF
assert cpu.get_reg16(rr) == 0x1234