示例#1
0
def test_cpu_init():
    cpu = c64.CPU()
    assert cpu.reg.PC == 0
    assert cpu.reg.SP == 0x100
    assert cpu.ram.size == 0x10000
    assert cpu.ram.word_length == 8
    assert cpu.ram.get(0) == 0
示例#2
0
def test_cpu_init_with_defaults():
    cpu = c64.CPU(initial_registers={'PC': 0x1234}, initial_ram=[0xff, 0x02])
    assert cpu.reg.PC == 0x1234
    assert cpu.reg.SP == 0x100
    assert cpu.ram.size == 0x10000
    assert cpu.ram.word_length == 8
    assert cpu.ram.get(0) == 0xff
    assert cpu.ram.get(1) == 0x02
示例#3
0
def test_next_word():
    cpu = c64.CPU(initial_ram=[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0xff])
    cpu.reg.PC = 0x0002
    assert cpu.next_word() == 0x02
    assert cpu.next_word() == 0x03
    assert cpu.next_word() == 0x04
    assert cpu.next_word() == 0x05
    assert cpu.next_word() == 0xff
    assert cpu.reg.PC == 0x0007
    cpu.reg.PC = 0x0000
    assert cpu.next_word() == 0x00
    assert cpu.next_word() == 0x01
    assert cpu.next_word() == 0x02
    assert cpu.reg.PC == 0x0003
示例#4
0
def test_cpu_init_with_initialized_defaults():
    ram = c64.RAM(8, 0xffff, initial_contents=[0xff, 0x01, 0x02, 0x03])
    regbank = c64.RegisterBank({
        'A': 0xff,
        'Y': 0xffff,
        'X': 0x12,
        'N': 1,
        'V': 0,
        'PCH': 0xff,
        'SP': 0x123
    })
    cpu = c64.CPU(initial_registers=regbank, initial_ram=ram)
    assert cpu.reg.PC == 0xff00
    assert cpu.reg.SP == 0x123
    assert cpu.ram.size == 0xffff
    assert cpu.ram.word_length == 8
    assert cpu.ram.get(0) == 0xff
    assert cpu.ram.get(1) == 0x01
    assert cpu.ram.get(2) == 0x02
    assert cpu.ram.get(3) == 0x03
示例#5
0
def cpu():
    return c64.CPU()