Exemple #1
0
def machine_emu_cpustate_rw_test():
    cpu = emu.CPU(M68K_CPU_TYPE_68000)
    cpu.w_pc(0)
    cpu.w_sr(0x2700)
    for i in range(16):
        cpu.w_reg(i, i)
    # get state
    s = CPUState()
    s.get(cpu)
    assert s.pc == 0
    assert s.sr == 0x2700
    for i in range(8):
        assert s.dx[i] == i
    for i in range(8):
        assert s.ax[i] == i + 8
    # modify state
    for i in range(8):
        s.dx[i] = i + 0x100
        s.ax[i] = i + 0x200
    s.pc = 0x400
    s.sr = 0x2701
    # set state
    s.set(cpu)
    # check state
    assert cpu.r_sr() == s.sr
    assert cpu.r_pc() == s.pc
    for i in range(8):
        assert s.dx[i] == cpu.r_reg(i)
    for i in range(8):
        assert s.ax[i] == cpu.r_reg(i + 8)
def machine_emu_cpu_rw_reg_test():
    cpu = emu.CPU(M68K_CPU_TYPE_68000)
    cpu.w_reg(M68K_REG_D0, 0xDEADBEEF)
    assert cpu.r_reg(M68K_REG_D0) == 0xDEADBEEF
    # invalid values
    with pytest.raises(OverflowError):
        cpu.w_reg(M68K_REG_D0, 0xDEADBEEF12)
    with pytest.raises(OverflowError):
        cpu.w_reg(M68K_REG_D0, -1)
    with pytest.raises(TypeError):
        cpu.w_reg(M68K_REG_D0, "hello")
def machine_emu_cpu_rws_reg_test():
    cpu = emu.CPU(M68K_CPU_TYPE_68000)
    cpu.ws_reg(M68K_REG_D0, -123)
    assert cpu.rs_reg(M68K_REG_D0) == -123
    # invalid values
    with pytest.raises(OverflowError):
        cpu.ws_reg(M68K_REG_D0, 0x80000000)
    with pytest.raises(OverflowError):
        cpu.ws_reg(M68K_REG_D0, -0x80000001)
    with pytest.raises(TypeError):
        cpu.ws_reg(M68K_REG_D0, "hello")
Exemple #4
0
 def __init__(
     self,
     cpu_type=M68K_CPU_TYPE_68000,
     ram_size_kib=1024,
     use_labels=True,
     raise_on_main_run=True,
     cycles_per_run=1000,
     max_cycles=0,
     cpu_name=None,
 ):
     if cpu_name is None:
         cpu_name = self._get_cpu_name(cpu_type)
     # setup musashi components
     self.cpu_type = cpu_type
     self.cpu_name = cpu_name
     self.cpu = emu.CPU(cpu_type)
     self.mem = emu.Memory(ram_size_kib)
     self.traps = emu.Traps()
     # internal state
     if use_labels:
         self.label_mgr = LabelManager()
     else:
         self.label_mgr = None
     self.raise_on_main_run = raise_on_main_run
     self.ram_total = ram_size_kib * 1024
     self.ram_bytes = self.ram_total - self.ram_begin
     self.error_reporter = ErrorReporter(self)
     self.run_states = []
     self.instr_hook = None
     self.cycles_per_run = cycles_per_run
     self.max_cycles = max_cycles
     self.bail_out = False
     # call init
     self._setup_handler()
     self._setup_quick_traps()
     self._init_cpu()
     self._init_base_mem()
def machine_emu_cpu_rw_context_test():
    cpu = emu.CPU(M68K_CPU_TYPE_68000)
    ctx = cpu.get_cpu_context()
    cpu.set_cpu_context(ctx)